1# Expect script for x86-64 no-PLT tests. 2# Copyright (C) 2016 Free Software Foundation, Inc. 3# 4# This file is part of the GNU Binutils. 5# 6# This program is free software; you can redistribute it and/or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 3 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 19# MA 02110-1301, USA. 20# 21 22# The following tests require running the executable generated by ld, 23# or enough of a build environment to create a fully linked executable. 24# This is not commonly available when testing a cross-built linker. 25if ![isnative] { 26 return 27} 28 29if ![is_elf_format] { 30 return 31} 32 33if ![istarget "x86_64-*-*"] { 34 return 35} 36 37# Check to see if the C compiler works 38if { [which $CC] == 0 } { 39 return 40} 41 42run_cc_link_tests [list \ 43 [list \ 44 "Build no-plt-func1.o no-plt-main1.o" \ 45 "" \ 46 "-fPIE" \ 47 {no-plt-func1.c no-plt-main1.c} \ 48 ] \ 49 [list \ 50 "Build no-plt-check1.o no-plt-extern1.o" \ 51 "" \ 52 "-Wa,-mrelax-relocations=yes" \ 53 {no-plt-check1.S no-plt-extern1.S} \ 54 ] \ 55 [list \ 56 "Build libno-plt-1a.so" \ 57 "-shared tmpdir/no-plt-func1.o" \ 58 "" \ 59 {dummy.s} \ 60 {} \ 61 "libno-plt-1a.so" \ 62 ] \ 63 [list \ 64 "Build libno-plt-1b.so" \ 65 "-shared tmpdir/no-plt-extern1.o" \ 66 "" \ 67 {dummy.s} \ 68 {{readelf -Wr libno-plt-1b.rd} \ 69 {objdump -dwrj.text libno-plt-1b.dd}} \ 70 "libno-plt-1b.so" \ 71 ] \ 72 [list \ 73 "No PLT (dynamic 1a)" \ 74 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 75 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \ 76 "" \ 77 {dummy.s} \ 78 {{readelf -Wr no-plt-1a.rd} {objdump -dwrj.text no-plt-1a.dd}} \ 79 "no-plt-1a" \ 80 ] \ 81 [list \ 82 "No PLT (dynamic 1b)" \ 83 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 84 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \ 85 "" \ 86 {dummy.s} \ 87 {{readelf -Wr no-plt-1b.rd} {objdump -dwrj.text no-plt-1b.dd}} \ 88 "no-plt-1b" \ 89 ] \ 90 [list \ 91 "No PLT (dynamic 1c)" \ 92 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 93 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \ 94 "" \ 95 {dummy.s} \ 96 {{readelf -Wr no-plt-1c.rd} {objdump -dwrj.text no-plt-1c.dd}} \ 97 "no-plt-1c" \ 98 ] \ 99 [list \ 100 "No PLT (static 1d)" \ 101 "-static tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 102 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \ 103 "" \ 104 {dummy.s} \ 105 {{readelf -Wr no-plt-1d.rd} {objdump -dwrj.text no-plt-1d.dd}} \ 106 "no-plt-1d" \ 107 ] \ 108 [list \ 109 "No PLT (PIE 1e)" \ 110 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 111 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \ 112 "" \ 113 {dummy.s} \ 114 {{readelf -Wr no-plt-1e.rd} {objdump -dwrj.text no-plt-1e.dd}} \ 115 "no-plt-1e" \ 116 ] \ 117 [list \ 118 "No PLT (PIE 1f)" \ 119 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 120 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \ 121 "" \ 122 { dummy.s } \ 123 {{readelf -Wr no-plt-1f.rd} {objdump -dwrj.text no-plt-1f.dd}} \ 124 "no-plt-1f" \ 125 ] \ 126 [list \ 127 "No PLT (PIE 1g)" \ 128 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 129 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \ 130 "" \ 131 { dummy.s } \ 132 {{readelf -Wr no-plt-1g.rd} {objdump -dwrj.text no-plt-1g.dd}} \ 133 "no-plt-1g" \ 134 ] \ 135] 136 137run_ld_link_exec_tests [] [list \ 138 [list \ 139 "No PLT (dynamic 1a)" \ 140 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 141 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \ 142 "" \ 143 { dummy.s } \ 144 "no-plt-1a" \ 145 "pass.out" \ 146 ] \ 147 [list \ 148 "No PLT (dynamic 1b)" \ 149 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 150 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \ 151 "" \ 152 { dummy.s } \ 153 "no-plt-1b" \ 154 "pass.out" \ 155 ] \ 156 [list \ 157 "No PLT (dynamic 1c)" \ 158 "tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 159 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \ 160 "" \ 161 { dummy.s } \ 162 "no-plt-1c" \ 163 "pass.out" \ 164 ] \ 165 [list \ 166 "No PLT (static 1d)" \ 167 "-static tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 168 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \ 169 "" \ 170 { dummy.s } \ 171 "no-plt-1d" \ 172 "pass.out" \ 173 ] \ 174 [list \ 175 "No PLT (PIE 1e)" \ 176 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 177 tmpdir/no-plt-func1.o tmpdir/no-plt-extern1.o" \ 178 "" \ 179 { dummy.s } \ 180 "no-plt-1e" \ 181 "pass.out" \ 182 ] \ 183 [list \ 184 "No PLT (PIE 1f)" \ 185 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 186 tmpdir/libno-plt-1a.so tmpdir/libno-plt-1b.so" \ 187 "" \ 188 { dummy.s } \ 189 "no-plt-1f" \ 190 "pass.out" \ 191 ] \ 192 [list \ 193 "No PLT (PIE 1g)" \ 194 "-pie tmpdir/no-plt-check1.o tmpdir/no-plt-main1.o \ 195 tmpdir/no-plt-func1.o tmpdir/libno-plt-1b.so" \ 196 "" \ 197 { dummy.s } \ 198 "no-plt-1g" \ 199 "pass.out" \ 200 ] \ 201] 202 203# Run-time tests which require working IFUNC support. 204if { [check_ifunc_available] } { 205 run_cc_link_tests [list \ 206 [list \ 207 "Build pr20253-2a.o pr20253-2b.o pr20253-2c.o pr20253-2d.o" \ 208 "" \ 209 "-fPIE -O2 -g" \ 210 { pr20253-2a.c pr20253-2b.S pr20253-2c.S pr20253-2d.S } \ 211 ] \ 212 [list \ 213 "Build libpr20253-2a.so" \ 214 "-shared tmpdir/pr20253-2b.o \ 215 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \ 216 "" \ 217 { dummy.s } \ 218 {} \ 219 "libpr20253-2a.so" \ 220 ] \ 221 ] 222 223 run_ld_link_exec_tests [] [list \ 224 [list \ 225 "Run pr20253-2a" \ 226 "tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \ 227 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \ 228 "" \ 229 { dummy.s } \ 230 "pr20253-2a" \ 231 "pass.out" \ 232 ] \ 233 [list \ 234 "Run pr20253-2b" \ 235 "--static tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \ 236 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \ 237 "" \ 238 { dummy.s } \ 239 "pr20253-2b" \ 240 "pass.out" \ 241 ] \ 242 [list \ 243 "Run pr20253-2c" \ 244 "-pie tmpdir/pr20253-2a.o tmpdir/pr20253-2b.o \ 245 tmpdir/pr20253-2c.o tmpdir/pr20253-2d.o" \ 246 "" \ 247 { dummy.s } \ 248 "pr20253-2c" \ 249 "pass.out" \ 250 ] \ 251 [list \ 252 "Run pr20253-2d" \ 253 "tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \ 254 "" \ 255 { dummy.s } \ 256 "pr20253-2d" \ 257 "pass.out" \ 258 ] \ 259 [list \ 260 "Run pr20253-2e" \ 261 "-pie tmpdir/pr20253-2a.o tmpdir/libpr20253-2a.so" \ 262 "" \ 263 { dummy.s } \ 264 "pr20253-2e" \ 265 "pass.out" \ 266 ] \ 267 [list \ 268 "Run pr20253-2f" \ 269 "tmpdir/pr20253-2a.o" \ 270 "" \ 271 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \ 272 "pr20253-2f" \ 273 "pass.out" \ 274 "-DCHECK_PLT" \ 275 ] \ 276 [list \ 277 "Run pr20253-2g" \ 278 "--static tmpdir/pr20253-2a.o" \ 279 "" \ 280 { pr20253-2b.S pr20253-2c.S pr20253-2d.S } \ 281 "pr20253-2g" \ 282 "pass.out" \ 283 "-DCHECK_PLT" \ 284 ] \ 285 ] 286} 287