]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - ld/testsuite/ld-i386/i386.exp
Fix: ld testsuite: pr22001-1 test segfaults on musl/x86
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-i386 / i386.exp
1 # Expect script for ld-i386 tests
2 # Copyright (C) 2002-2023 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 set saved_ASFLAGS "$ASFLAGS"
23 if { [is_elf_format] \
24 && ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
25 set ASFLAGS "$ASFLAGS -mx86-used-note=no"
26 }
27
28 # Test i386 linking; all types of relocs. This tests the assembler and
29 # tools like objdump as well as the linker.
30
31 if {[istarget "i?86-*-vxworks"]} {
32 set i386tests {
33 {"VxWorks shared library test 1"
34 "-shared -Tvxworks1.ld --hash-style=sysv" ""
35 "" {vxworks1-lib.s}
36 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
37 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
38 "libvxworks1.so"}
39 {"VxWorks executable test 1 (dynamic)" \
40 "tmpdir/libvxworks1.so -Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
41 "" {vxworks1.s}
42 {{readelf {--relocs --wide} vxworks1.rd} {objdump -dr vxworks1.dd}}
43 "vxworks1"}
44 {"VxWorks executable test 2 (dynamic)" \
45 "-Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
46 "" {vxworks2.s}
47 {{readelf --segments vxworks2.sd}}
48 "vxworks2"}
49 {"VxWorks executable test 2 (static)"
50 "-Tvxworks1.ld --hash-style=sysv" ""
51 "" {vxworks2.s}
52 {{readelf --segments vxworks2-static.sd}}
53 "vxworks2"}
54 }
55 run_ld_link_tests $i386tests
56 run_dump_test "vxworks1-static"
57 }
58
59 if [istarget "*-*-go32*"] {
60 run_ld_link_tests {{"go32 stub" "" "" "" {zero.s} {} "go32stub"}}
61
62 set src "tmpdir/go32stub"
63 set dest "tmpdir/go32stub-copy"
64
65 set test "go32 stub patch the source"
66 set fi [open $src r+]
67 fconfigure $fi -translation binary
68 if {[read $fi 2] != "MZ"} {
69 fail $test
70 } else {
71 pass $test
72 seek $fi 0x40
73 puts -nonewline $fi "objcopy-test-go32stub"
74 }
75 close $fi
76
77 set test "go32 stub objcopy"
78 set status [remote_exec build $OBJCOPY "$OBJCOPYFLAGS $src $dest"]
79 set exec_output [lindex $status 1]
80 set exec_output [prune_warnings $exec_output]
81 if [string match "" $exec_output] then {
82 pass $test
83 } else {
84 send_log "$exec_output\n"
85 verbose "$exec_output" 1
86 fail $test
87 }
88
89 # cmp would compare the whole files and some data after the initial exe
90 # stub could differ.
91 set test "go32 stub comparison after objcopy"
92 set fi [open $src]
93 fconfigure $fi -translation binary
94 set src_stub [read $fi 2048]
95 close $fi
96 set fi [open $dest]
97 fconfigure $fi -translation binary
98 set dest_stub [read $fi 2048]
99 close $fi
100 if {$src_stub == $dest_stub} {
101 pass $test
102 } else {
103 fail $test
104 }
105 }
106
107 if { !([istarget "i?86-*-elf*"]
108 || [istarget "i?86-*-linux*"]
109 || [istarget "i?86-*-gnu*"]
110 || [istarget "x86_64-*-elf*"]
111 || [istarget "x86_64-*-linux*"]
112 || [istarget "amd64-*-linux*"]) } {
113 return
114 }
115
116 # List contains test-items with 3 items followed by 2 lists:
117 # 0:name 1:ld early options 2:ld late options 3:assembler options
118 # 4:filenames of assembler files 5: action and options. 6: name of output file
119
120 # Actions:
121 # objdump: Apply objdump options on result. Compare with regex (last arg).
122 # nm: Apply nm options on result. Compare with regex (last arg).
123 # readelf: Apply readelf options on result. Compare with regex (last arg).
124
125 set i386tests {
126 {"Helper shared library (basic PLT test)"
127 "-shared -melf_i386" "" "--32" {pltlib.s} {} "libpltlib.so"}
128 {"basic PLT generation (non-PIC)"
129 "-melf_i386 tmpdir/libpltlib.so" "" "--32" {plt.s}
130 {{objdump -drj.plt plt.pd}} "plt"}
131 {"basic PLT generation (PIC)"
132 "-shared -melf_i386 tmpdir/libpltlib.so" "" "--32" {plt-pic.s}
133 {{objdump -drj.plt plt-pic.pd}} "libplt-pic.so"}
134 {"TLS -fpic -shared transitions"
135 "-shared -melf_i386 --no-ld-generated-unwind-info \
136 -z noseparate-code --hash-style=sysv" ""
137 "--32" {tlspic1.s tlspic2.s}
138 {{readelf -Ssrl tlspic.rd} {objdump -drj.text tlspic.dd}
139 {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
140 "libtlspic.so"}
141 {"TLS -fpic -shared transitions without PLT"
142 "-shared -melf_i386 --no-ld-generated-unwind-info \
143 -z noseparate-code --hash-style=sysv" ""
144 "-mrelax-relocations=yes --32"
145 {tlspic3.s tlspic2.s}
146 {{readelf -Ssrl tlspic2.rd} {objdump -drj.text tlspic2.dd}
147 {objdump -sj.got tlspic2.sd} {objdump -sj.tdata tlspic2.td}}
148 "libtlspic2.so"}
149 {"TLS descriptor -fpic -shared transitions"
150 "-shared -melf_i386 --no-ld-generated-unwind-info \
151 -z noseparate-code --hash-style=sysv" ""
152 "--32" {tlsdesc.s tlspic2.s}
153 {{readelf -Ssrl tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
154 {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}}
155 "libtlsdesc.so"}
156 {"Helper shared library" "-shared -melf_i386" ""
157 "--32" {tlslib.s} {} "libtlslib.so"}
158 {"TLS -fpic and -fno-pic exec transitions"
159 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
160 -z noseparate-code --hash-style=sysv" ""
161 "--32" {tlsbinpic.s tlsbin.s}
162 {{readelf -Ssrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
163 {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
164 "tlsbin"}
165 {"TLS -fpic and -fno-pic exec transitions without PLT"
166 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
167 -z noseparate-code --hash-style=sysv" ""
168 "-mrelax-relocations=yes --32"
169 {tlsbinpic2.s tlsbin.s}
170 {{readelf -Ssrl tlsbin2.rd} {objdump -drj.text tlsbin2.dd}
171 {objdump -sj.got tlsbin2.sd} {objdump -sj.tdata tlsbin2.td}}
172 "tlsbin2"}
173 {"TLS descriptor -fpic and -fno-pic exec transitions"
174 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
175 -z noseparate-code --hash-style=sysv" ""
176 "--32" {tlsbindesc.s tlsbin.s}
177 {{readelf -Ssrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
178 {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
179 "tlsbindesc"}
180 {"TLS with global dynamic and descriptors"
181 "-shared -melf_i386 --no-ld-generated-unwind-info \
182 -z noseparate-code --hash-style=sysv" ""
183 "--32" {tlsgdesc.s}
184 {{readelf -Ssrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
185 "libtlsgdesc.so"}
186 {"TLS in debug sections" "-melf_i386" ""
187 "--32" {tlsg.s}
188 {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
189 {"TLS @indntpoff with %eax" "-melf_i386" "" "--32" {tlsindntpoff.s}
190 {{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"}
191 {"Reloc section order"
192 "-shared -melf_i386 -z nocombreloc -z notext" "" "--32"
193 {reloc.s} {{objdump -hw reloc.d}} "reloc.so"}
194 {"Basic --emit-relocs support" "-shared -melf_i386 --emit-relocs" "" "--32"
195 {emit-relocs.s} {{readelf --relocs emit-relocs.rd}} "emit-relocs.so"}
196 {"-z combreloc relocation sections" "-shared -melf_i386 -z combreloc" ""
197 "--32" {combreloc.s} {{readelf -r combreloc.d}} "combreloc.so"}
198 {"TLS GD->LE transition" "-melf_i386" ""
199 "--32" {tlsgd1.s}
200 {{objdump -dwr tlsgd1.dd}} "tlsgd1"}
201 {"TLS GD->LE transition without PLT" "-melf_i386" ""
202 "-mrelax-relocations=yes --32"
203 {tlsgd3.s}
204 {{objdump -dwr tlsgd3.dd}} "tlsgd3"}
205 {"TLS LD->LE transition" "-melf_i386" ""
206 "--32" {tlsld1.s}
207 {{objdump -dwr tlsld1.dd}} "tlsld1"}
208 {"TLS LD->LE transition without PLT" "-melf_i386" ""
209 "-mrelax-relocations=yes --32"
210 {tlsld2.s}
211 {{objdump -dwr tlsld2.dd}} "tlsld2"}
212 {"TLS IE->LE transition" "-melf_i386" ""
213 "--32" {tlsie1.s}
214 {{objdump -dwr tlsie1.dd}} "tlsie1"}
215 {"PR ld/17313 (1)" "-melf_i386" ""
216 "--32 -mx86-used-note=yes" {zero.s} {} ""}
217 {"PR ld/17313 (2)" "-melf_i386 -shared --just-symbols=tmpdir/zero.o" ""
218 "--32 -mx86-used-note=yes" {lea1.s} {} "libpr17313.so"}
219 {"PR ld/17306 (1)" "-melf_i386" ""
220 "--32 -mx86-used-note=yes" {pr17306b.s} {} ""}
221 {"PR ld/17306 (2)" "-melf_i386 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
222 "--32 -mx86-used-note=yes" {pr17306a.s} {} "libpr17306.so"}
223 {"PR ld/17709 (1)" "-melf_i386 -shared" ""
224 "--32 -mx86-used-note=yes" {pr17709a.s} {} "libpr17709.so"}
225 {"PR ld/17709 (2)" "-melf_i386 tmpdir/libpr17709.so" ""
226 "--32 -mx86-used-note=yes"
227 {pr17709b.s} {{ld "pr17709.err"}} "pr17709"}
228 {"Build pr19827a.o" "" ""
229 "--32 -mx86-used-note=yes" { pr19827a.S }}
230 {"Build pr19827b.so" "-melf_i386 -shared" ""
231 "--32 -mx86-used-note=yes"
232 { pr19827b.S } {} "pr19827b.so"}
233 {"Build pr19827"
234 "-melf_i386 -pie -z notext tmpdir/pr19827a.o tmpdir/pr19827b.so"
235 ""
236 "--32 -mx86-used-note=yes"
237 { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
238 {"Build pr19827.so"
239 "-melf_i386 -shared -Bsymbolic -z notext" ""
240 "--32 -mx86-used-note=yes"
241 { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
242 {"Build pr27193a.so"
243 "-melf_i386 -shared -z noexecstack" ""
244 "--32"
245 { pr27193a.o.bz2 pr27193b.s }
246 {{objdump {-dw} pr27193.dd}} "pr27193a.so"}
247 {"Build pr27193b.so"
248 "-melf_i386 -shared --reduce-memory-overheads -z noexecstack" ""
249 "--32"
250 { pr27193a.o.bz2 pr27193b.s }
251 {{objdump {-dw} pr27193.dd}} "pr27193b.so"}
252 }
253
254 proc iamcu_tests {} {
255 global as
256 global srcdir
257 global subdir
258
259 if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/start.s" tmpdir/startiamcu.o] {
260 fail "Build Intel MCU start.o"
261 return
262 }
263
264 if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
265 fail "Build ia32 start.o"
266 return
267 }
268
269 if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/foo.s" tmpdir/fooiamcu.o] {
270 fail "Build Intel MCU foo.o"
271 return
272 }
273
274 if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
275 fail "Build ia32 foo.o"
276 return
277 }
278
279 run_dump_test "abs-iamcu"
280 run_dump_test "iamcu-1"
281 run_dump_test "iamcu-2"
282 run_dump_test "iamcu-3"
283 run_dump_test "iamcu-4"
284 }
285
286 iamcu_tests
287
288 run_ld_link_tests $i386tests
289
290 run_ld_link_tests [list \
291 [list \
292 "TLS -fno-pic -shared" \
293 "-shared -melf_i386 --no-ld-generated-unwind-info -z notext \
294 -z noseparate-code --hash-style=sysv $NO_DT_RELR_LDFLAGS" \
295 "" "--32" \
296 {tlsnopic1.s tlsnopic2.s} \
297 {{readelf -Ssrl tlsnopic.rd} \
298 {objdump -drj.text tlsnopic.dd} \
299 {objdump -sj.got tlsnopic.sd}} \
300 "libtlsnopic.so" \
301 ] \
302 ]
303
304 run_dump_test "abs"
305 run_dump_test "pcrel8"
306 run_dump_test "pcrel16"
307 run_dump_test "pcrel16abs"
308 run_dump_test "pcrel16-2"
309 run_dump_test "alloc"
310 run_dump_test "warn1"
311 run_dump_test "tlsgd2"
312 run_dump_test "tlsgd4"
313 run_dump_test "tlsie2"
314 run_dump_test "tlsie3"
315 run_dump_test "tlsie4"
316 run_dump_test "tlsie5"
317 run_dump_test "hidden1"
318 run_dump_test "hidden2"
319 run_dump_test "hidden3"
320 run_dump_test "protected1"
321 run_dump_test "protected2"
322 run_dump_test "protected3"
323 run_dump_test "protected4"
324 run_dump_test "protected5"
325 run_dump_test "protected6a"
326 run_dump_test "protected6b"
327 run_dump_test "protected7"
328 run_dump_test "tlspie1"
329 run_dump_test "tlspie2"
330 run_dump_test "tlspie3a"
331 run_dump_test "tlspie3b"
332 run_dump_test "tlspie3c"
333 run_dump_test "nogot1"
334 run_dump_test "nogot2"
335 run_dump_test "discarded1"
336 run_dump_test "pr12718"
337 run_dump_test "pr12921"
338 run_dump_test "pr12570a"
339 run_dump_test "pr12570b"
340 run_dump_test "lea1a"
341 run_dump_test "lea1b"
342 run_dump_test "lea1c"
343 run_dump_test "lea1d"
344 run_dump_test "lea1e"
345 run_dump_test "lea1f"
346 run_dump_test "mov1a"
347 run_dump_test "mov1b"
348 run_dump_test "mov2a"
349 run_dump_test "mov2b"
350 run_dump_test "mov3"
351 run_dump_test "branch1"
352 run_dump_test "call1"
353 run_dump_test "call2"
354 run_dump_test "call3a"
355 run_dump_test "call3b"
356 run_dump_test "call3c"
357 run_dump_test "call3d"
358 run_dump_test "call3e"
359 run_dump_test "call3f"
360 run_dump_test "call3g"
361 run_dump_test "call3h"
362 run_dump_test "jmp1"
363 run_dump_test "jmp2"
364 run_dump_test "ljmp1"
365 run_dump_test "ljmp2"
366 run_dump_test "load1"
367 run_dump_test "load2"
368 run_dump_test "load3"
369 run_dump_test "load4a"
370 run_dump_test "load4b"
371 run_dump_test "load5a"
372 run_dump_test "load5b"
373 run_dump_test "load6"
374 run_dump_test "load7"
375 run_dump_test "pr19175"
376 run_dump_test "pr19615"
377 run_dump_test "pr19636-1a"
378 run_dump_test "pr19636-1b"
379 run_dump_test "pr19636-1c"
380 run_dump_test "pr19636-1d"
381 run_dump_test "pr19636-1e"
382 run_dump_test "pr19636-1f"
383 run_dump_test "pr19636-1g"
384 run_dump_test "pr19636-1h"
385 run_dump_test "pr19636-1i"
386 run_dump_test "pr19636-1j"
387 run_dump_test "pr19636-1k"
388 run_dump_test "pr19636-1l"
389 run_dump_test "pr19636-2a"
390 run_dump_test "pr19636-2b"
391 run_dump_test "pr19636-2c"
392 run_dump_test "pr19636-2d"
393 run_dump_test "pr19636-2e"
394 run_dump_test "pr19636-3a"
395 run_dump_test "pr19636-3b"
396 run_dump_test "pr19636-3c"
397 run_dump_test "pr19636-3d"
398 run_dump_test "pr19636-3e"
399 run_dump_test "pr19636-3f"
400 run_dump_test "pr19636-3g"
401 run_dump_test "pr19636-3h"
402 run_dump_test "pr19636-3i"
403 run_dump_test "pr19636-4a"
404 run_dump_test "pr19636-4b"
405 run_dump_test "pr19636-4c"
406 run_dump_test "pr19636-4d"
407 run_dump_test "pr19645"
408 run_dump_test "pr19609-1a"
409 run_dump_test "pr19609-1b"
410 run_dump_test "pr19609-1c"
411 run_dump_test "pr19609-1d"
412 run_dump_test "pr19609-1e"
413 run_dump_test "pr19609-1f"
414 run_dump_test "pr19609-1g"
415 run_dump_test "pr19609-1h"
416 run_dump_test "pr19609-1i"
417 run_dump_test "pr19609-2a"
418 run_dump_test "pr19609-2b"
419 run_dump_test "pr19609-2c"
420 run_dump_test "undefweaka"
421 run_dump_test "undefweakb"
422 run_dump_test "pr19539"
423 run_dump_test "pr20117"
424 run_dump_test "pr20244-1a"
425 run_dump_test "pr20244-1b"
426 run_dump_test "pr20244-1c"
427 run_dump_test "pr20244-2a"
428 run_dump_test "pr20244-2b"
429 run_dump_test "pr20244-2c"
430 run_dump_test "pr20244-2d"
431 run_dump_test "pr20244-4a"
432 run_dump_test "pr20244-4b"
433 run_dump_test "pr20244-4c"
434 run_dump_test "pr20253-3"
435 run_dump_test "pr20253-4a"
436 run_dump_test "pr20253-4b"
437 run_dump_test "pr20253-4c"
438 run_dump_test "pr20253-5"
439 run_dump_test "pr20515"
440 run_dump_test "property-x86-3"
441 run_dump_test "property-x86-4a"
442 run_dump_test "property-x86-4b"
443 run_dump_test "property-x86-5"
444 run_dump_test "property-x86-6"
445 run_dump_test "property-x86-ibt1a"
446 run_dump_test "property-x86-ibt1b"
447 run_dump_test "property-x86-ibt2"
448 run_dump_test "property-x86-ibt3a"
449 run_dump_test "property-x86-ibt3b"
450 run_dump_test "property-x86-ibt4"
451 run_dump_test "property-x86-ibt5"
452 run_dump_test "property-x86-shstk1a"
453 run_dump_test "property-x86-shstk1b"
454 run_dump_test "property-x86-shstk2"
455 run_dump_test "property-x86-shstk3a"
456 run_dump_test "property-x86-shstk3b"
457 run_dump_test "property-x86-shstk4"
458 run_dump_test "property-x86-shstk5"
459 run_dump_test "property-x86-cet1"
460 run_dump_test "property-x86-cet2a"
461 run_dump_test "property-x86-cet2b"
462 run_dump_test "property-x86-cet3a"
463 run_dump_test "property-x86-cet3b"
464 run_dump_test "property-x86-cet4a"
465 run_dump_test "property-x86-cet4b"
466 run_dump_test "property-x86-cet5a"
467 run_dump_test "property-x86-cet5b"
468 run_dump_test "property-x86-cet6"
469 run_dump_test "pie1"
470 run_dump_test "pr21884"
471 run_dump_test "pr22115-1a"
472 run_dump_test "pr22115-1b"
473 run_dump_test "pr22115-1c"
474 run_dump_test "pr22115-1d"
475 run_dump_test "pr22135"
476 run_dump_test "pr22782"
477 run_dump_test "pr22929"
478 run_dump_test "pr23189"
479 run_dump_test "pr23194"
480 run_dump_test "pr23372a"
481 run_dump_test "pr23372b"
482 run_dump_test "pr23372c"
483 run_dump_test "pr23372d"
484 run_dump_test "pr23486a"
485 run_dump_test "pr23486b"
486 run_dump_test "pr23486c"
487 run_dump_test "pr23486d"
488 run_dump_test "pr23854"
489 run_dump_test "pr23930"
490 run_dump_test "pr24322a"
491 run_dump_test "pr24322b"
492 run_dump_test "align-branch-1"
493 run_dump_test "pr26018"
494 run_dump_test "pr26263"
495 run_dump_test "pr26711-1"
496 run_dump_test "pr26711-2"
497 run_dump_test "pr26711-3"
498 run_dump_test "property-x86-isa1"
499 run_dump_test "property-x86-isa2"
500 run_dump_test "property-x86-isa3"
501 run_dump_test "property-x86-isa4"
502 run_dump_test "pr26869"
503 run_dump_test "code16"
504 run_dump_test "pr27491-1a"
505 run_dump_test "pr27491-1b"
506 run_dump_test "pr27491-1c"
507 run_dump_test "pr27491-2"
508 run_dump_test "pr27491-3"
509 run_dump_test "pr27491-4"
510 run_dump_test "dt-relr-1a"
511 run_dump_test "dt-relr-1b"
512 run_dump_test "pr28870"
513 run_dump_test "pr28894"
514 run_dump_test "pr30787"
515
516 if { !([istarget "i?86-*-linux*"]
517 || [istarget "i?86-*-gnu*"]
518 || [istarget "x86_64-*-linux*"]) } {
519 set ASFLAGS "$saved_ASFLAGS"
520 return
521 }
522
523 run_dump_test "compressed1"
524 run_dump_test "pr12627"
525 run_dump_test "pr13302"
526 run_dump_test "pr14215"
527 run_dump_test "pr17057"
528 run_dump_test "pr17935-1"
529 run_dump_test "pr17935-2"
530 run_dump_test "pr18801a"
531 run_dump_test "pr18801b"
532 run_dump_test "ifunc-textrel-1a"
533 run_dump_test "ifunc-textrel-1b"
534 run_dump_test "ifunc-textrel-2a"
535 run_dump_test "ifunc-textrel-2b"
536 run_dump_test "pr18815"
537 run_dump_test "pr19939a"
538 run_dump_test "pr19939b"
539 run_dump_test "tlsdesc2"
540 run_dump_test "report-reloc-1"
541 run_dump_test "pr27998a"
542 run_dump_test "pr27998b"
543
544 proc undefined_weak {cflags ldflags} {
545 set testname "Undefined weak symbol"
546 if { ![ string match "" $cflags$ldflags] } {
547 set testname "$testname ($cflags $ldflags)"
548 }
549
550 if { [string match "*-fPIE*" $cflags]
551 && ![string match "*-z nodynamic-undefined-weak*" $ldflags] } {
552 set weak_symbol "Weak defined"
553 } else {
554 set weak_symbol "Weak undefined"
555 }
556
557 run_cc_link_tests [list \
558 [list \
559 "Build libpr19704a.so" \
560 "-shared -Wl,-soname,libpr19704.so" \
561 "-Wa,-mrelax-relocations=yes" \
562 { dummy.s } \
563 {} \
564 "libpr19704a.so" \
565 ] \
566 [list \
567 "Build libpr19704b.so" \
568 "-shared -Wl,-soname,libpr19704.so" \
569 "-fPIC -Wa,-mrelax-relocations=yes" \
570 { pr19704b.c } \
571 {} \
572 "libpr19704b.so" \
573 ] \
574 ]
575
576 exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
577
578 run_ld_link_exec_tests [list \
579 [list \
580 "Run pr19704" \
581 "$ldflags -Wl,--no-as-needed tmpdir/libpr19704.so \
582 -Wl,-R,tmpdir" \
583 "-Wa,-mrelax-relocations=yes" \
584 { pr19704a.c } \
585 "pr19704" \
586 "pr19704.out" \
587 "$cflags" \
588 ] \
589 ]
590
591 exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
592
593 set exec_output [run_host_cmd tmpdir/pr19704 ""]
594 if {![string match $weak_symbol $exec_output]} {
595 fail $testname
596 } else {
597 pass $testname
598 }
599 }
600
601 # Must be Linux native with the C compiler
602 if { [isnative]
603 && [istarget "i?86-*-linux*"]
604 && [check_compiler_available] } {
605 run_cc_link_tests [list \
606 [list \
607 "Build plt-lib.so" \
608 "-shared" \
609 "-fPIC -Wa,-mrelax-relocations=yes" \
610 { plt-lib.c } \
611 {} \
612 "libplt-lib.so" \
613 ] \
614 [list \
615 "Build libplt-main1.a" \
616 "" \
617 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
618 { plt-main1.c } \
619 {{readelf {-Wr} plt-main1.rd}} \
620 "libplt-main1.a" \
621 ] \
622 [list \
623 "Build libplt-main2.a" \
624 "" \
625 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
626 { plt-main2.c } \
627 {{readelf {-Wr} plt-main2.rd}} \
628 "libplt-main2.a" \
629 ] \
630 [list \
631 "Build libplt-main3.a" \
632 "" \
633 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
634 { plt-main3.c } \
635 {{readelf {-Wr} plt-main3.rd}} \
636 "libplt-main3.a" \
637 ] \
638 [list \
639 "Build libplt-main4.a" \
640 "" \
641 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
642 { plt-main4.c } \
643 {{readelf {-Wr} plt-main4.rd}} \
644 "libplt-main4.a" \
645 ] \
646 [list \
647 "Build plt-main" \
648 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
649 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
650 "-Wa,-mrelax-relocations=yes" \
651 { plt-main5.c } \
652 {{readelf {-Wr} plt-main.rd}} \
653 "plt-main" \
654 ] \
655 [list \
656 "Build plt-main with PIE" \
657 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
658 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
659 "-fPIC -Wa,-mrelax-relocations=yes" \
660 { plt-main5.c } \
661 {{readelf {-Wr} plt-main.rd}} \
662 "plt-main" \
663 ] \
664 [list \
665 "Build copyreloc-lib.so" \
666 "-shared" \
667 "-fPIC -Wa,-mrelax-relocations=yes" \
668 { copyreloc-lib.c } \
669 {} \
670 "copyreloc-lib.so" \
671 ] \
672 [list \
673 "Build libcopyreloc-main.a" \
674 "" \
675 "-Wa,-mrelax-relocations=yes" \
676 { copyreloc-main.S } \
677 {} \
678 "libcopyreloc-main.a" \
679 ] \
680 [list \
681 "Build copyreloc-main with PIE and GOTOFF (1)" \
682 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
683 "-Wa,-mrelax-relocations=yes" \
684 { dummy.s } \
685 {{readelf {-Wr} copyreloc-main1.rd}} \
686 "copyreloc-main" \
687 ] \
688 [list \
689 "Build copyreloc-main with PIE and GOTOFF (2)" \
690 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
691 "-Wa,-mrelax-relocations=yes" \
692 { dummy.s } \
693 {{readelf {-Wr} copyreloc-main2.rd}} \
694 "copyreloc-main" \
695 ] \
696 [list \
697 "Build pr17689.so" \
698 "-shared" \
699 "-fPIC -Wa,-mrelax-relocations=yes" \
700 { pr17689a.c } \
701 {} \
702 "pr17689.so" \
703 ] \
704 [list \
705 "Build pr17689.so with -z now" \
706 "-shared -Wl,-z,now" \
707 "-fPIC -Wa,-mrelax-relocations=yes" \
708 { pr17689a.c } \
709 {{readelf {-Wr} pr17689now.rd}} \
710 "pr17689now.so" \
711 ] \
712 [list \
713 "Build pr17689ver.so" \
714 "-shared -Wl,--version-script,pr17689a.t" \
715 "-fPIC -Wa,-mrelax-relocations=yes" \
716 { pr17689a.c } \
717 {} \
718 "pr17689ver.so" \
719 ] \
720 [list \
721 "Build pr17689.a" \
722 "" \
723 "-Wa,-mrelax-relocations=yes" \
724 { pr17689b.S } \
725 {} \
726 "pr17689.a" \
727 ] \
728 [list \
729 "Build pr17689 with PIE and GOTOFF" \
730 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
731 "-Wa,-mrelax-relocations=yes" \
732 { dummy.c } \
733 {{readelf {-Wr} pr17689.rd}} \
734 "pr17689" \
735 ] \
736 [list \
737 "Build pr17689 with PIE, -z now and GOTOFF" \
738 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
739 "-Wa,-mrelax-relocations=yes" \
740 { dummy.c } \
741 {{readelf {-Wr} pr17689now.rd}} \
742 "pr17689now" \
743 ] \
744 [list \
745 "Build pr17689ver with PIE and GOTOFF" \
746 "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
747 "-Wa,-mrelax-relocations=yes" \
748 { dummy.c } \
749 {{readelf {-Wr} pr17689ver.rd}} \
750 "pr17689ver" \
751 ] \
752 [list \
753 "Build pr17827 with PIE and GOTOFF" \
754 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
755 "-Wa,-mrelax-relocations=yes" \
756 { dummy.c } \
757 {{readelf {-Wr} pr17827.rd}} \
758 "pr17827" \
759 ] \
760 [list \
761 "Build pr18900.so" \
762 "-shared" \
763 "-fPIC -Wa,-mrelax-relocations=yes" \
764 { pr18900a.c } \
765 "" \
766 "pr18900.so" \
767 ] \
768 [list \
769 "Build pr18900.o" \
770 "-r -nostdlib" \
771 "-Wa,-mrelax-relocations=yes" \
772 { pr18900b.c pr18900c.c } \
773 "" \
774 "pr18900.o" \
775 ] \
776 [list \
777 "Build pr18900a" \
778 "tmpdir/pr18900.o tmpdir/pr18900.so" \
779 "-Wa,-mrelax-relocations=yes" \
780 { dummy.s } \
781 {{readelf {-Wrd} pr18900a.rd}} \
782 "pr18900a" \
783 ] \
784 [list \
785 "Build pr18900b" \
786 "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
787 "-Wa,-mrelax-relocations=yes" \
788 { dummy.s } \
789 {{readelf {-Wrd} pr18900b.rd}} \
790 "pr18900b" \
791 ] \
792 [list \
793 "Build pr19031.so" \
794 "-shared" \
795 "-fPIC -Wa,-mrelax-relocations=yes" \
796 { pr19031a.c } \
797 "" \
798 "pr19031.so" \
799 ] \
800 [list \
801 "Build got1d.so" \
802 "-shared" \
803 "-Wa,-mrelax-relocations=yes" \
804 { got1d.S } \
805 "" \
806 "got1d.so" \
807 ] \
808 [list \
809 "Build gotpc1.o" \
810 "-r -nostdlib" \
811 "-Wa,-mrelax-relocations=yes" \
812 { got1a.S got1b.c got1c.c } \
813 "" \
814 "gotpc1.o" \
815 ] \
816 [list \
817 "Build gotpc1" \
818 "$NOPIE_LDFLAGS -Wl,--as-needed,-z,noexecstack \
819 tmpdir/gotpc1.o tmpdir/got1d.so" \
820 "-Wa,-mx86-used-note=no" \
821 { dummy.s } \
822 {{objdump {-dw} got1.dd}} \
823 "got1" \
824 ] \
825 [list \
826 "Build pr19319.so" \
827 "-shared" \
828 "-Wa,-mx86-used-note=no" \
829 { pr19319a.S } \
830 "" \
831 "pr19319.so" \
832 ] \
833 [list \
834 "Build pr19319" \
835 "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
836 "-Wa,-mrelax-relocations=yes" \
837 { pr19319b.S } \
838 {{objdump {-dw} pr19319.dd}} \
839 "pr19319" \
840 ] \
841 [list \
842 "Build pr24276.so" \
843 "-shared -nostdlib -nostartfiles \
844 -Ltmpdir $srcdir/$subdir/pr24276.dso" \
845 "-Wa,-mx86-used-note=yes" \
846 { pr19319b.S } \
847 {{warning_output pr24276.warn}} \
848 "pr24276.so" \
849 ] \
850 [list \
851 "Build property 1" \
852 "" \
853 "-Wa,-mx86-used-note=no" \
854 {pass.c property-no-copy.S} \
855 {{readelf {-n} property-1.r}} \
856 "property-1" \
857 ] \
858 [list \
859 "Build property 1 (.o)" \
860 "-r -nostdlib" \
861 "-Wa,-mx86-used-note=yes" \
862 {pass.c property-no-copy.S} \
863 {{readelf {-n} property-1a.r}} \
864 "property-1.o" \
865 ] \
866 [list \
867 "Build property 1 (.so)" \
868 "-shared" \
869 "-fPIC -Wa,-mx86-used-note=no" \
870 {pass.c property-no-copy.S} \
871 {{readelf {-n} property-1.r}} \
872 "property-1.so" \
873 ] \
874 [list \
875 "Build property 2" \
876 "" \
877 "-Wa,-mx86-used-note=no" \
878 {pass.c property-stack.S} \
879 {{readelf {-n} property-2.r}} \
880 "property-2" \
881 ] \
882 [list \
883 "Build property 2 (.o)" \
884 "-r -nostdlib" \
885 "-Wa,-mx86-used-note=yes" \
886 {pass.c property-stack.S} \
887 {{readelf {-n} property-2a.r}} \
888 "property-2.o" \
889 ] \
890 [list \
891 "Build property 2 (.so)" \
892 "-shared" \
893 "-fPIC -Wa,-mx86-used-note=no" \
894 {pass.c property-stack.S} \
895 {{readelf {-n} property-2.r}} \
896 "property-2.so" \
897 ] \
898 [list \
899 "Build property 3" \
900 "" \
901 "-Wa,-mx86-used-note=no" \
902 {pass.c property-stack.S property-x86-1.S} \
903 {{readelf {-n} property-3.r}} \
904 "property-3" \
905 ] \
906 [list \
907 "Build property 3 (.o)" \
908 "-r -nostdlib" \
909 "-Wa,-mx86-used-note=yes" \
910 {pass.c property-x86-1.S property-stack.S} \
911 {{readelf {-n} property-3a.r}} \
912 "property-3.o" \
913 ] \
914 [list \
915 "Build property 3 (.so)" \
916 "-shared" \
917 "-fPIC -Wa,-mx86-used-note=no" \
918 {property-x86-1.S pass.c property-stack.S} \
919 {{readelf {-n} property-3.r}} \
920 "property-3.so" \
921 ] \
922 [list \
923 "Build property 4" \
924 "" \
925 "-Wa,-mx86-used-note=no" \
926 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
927 {{readelf {-n} property-4.r}} \
928 "property-4" \
929 ] \
930 [list \
931 "Build property 4 (.o)" \
932 "-r -nostdlib" \
933 "-Wa,-mx86-used-note=yes" \
934 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
935 {{readelf {-n} property-4a.r}} \
936 "property-4.o" \
937 ] \
938 [list \
939 "Build property 4 (.so)" \
940 "-shared" \
941 "-fPIC -Wa,-mx86-used-note=no" \
942 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
943 {{readelf {-n} property-4.r}} \
944 "property-4.so" \
945 ] \
946 [list \
947 "Build property 4 (-Wl,-z,stack-size=0)" \
948 "-Wl,-z,stack-size=0" \
949 "-Wa,-mx86-used-note=no" \
950 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
951 {{readelf {-n} property-4.r}} \
952 "property-4" \
953 ] \
954 [list \
955 "Build property 5" \
956 "-Wl,-z,stack-size=0x900000" \
957 "-Wa,-mx86-used-note=no" \
958 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
959 {{readelf {-n} property-5.r}} \
960 "property-5" \
961 ] \
962 [list \
963 "Build property 5 (.o)" \
964 "-r -nostdlib -Wl,-z,stack-size=0x900000" \
965 "-Wa,-mx86-used-note=yes" \
966 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
967 {{readelf {-n} property-5a.r}} \
968 "property-5.o" \
969 ] \
970 [list \
971 "Build property 5 (.so)" \
972 "-shared -Wl,-z,stack-size=0x900000" \
973 "-fPIC -Wa,-mx86-used-note=no" \
974 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
975 {{readelf {-n} property-5.r}} \
976 "property-5.so" \
977 ] \
978 [list \
979 "Build property-6.so" \
980 "-shared" \
981 "-fPIC -Wa,-mx86-used-note=no" \
982 {property-6a.c property-6c.S} \
983 {{readelf {-n} property-6.r}} \
984 "property-6.so" \
985 ] \
986 [list \
987 "Build property-6.o" \
988 "-r -nostdlib" \
989 "-Wa,-mx86-used-note=yes" \
990 {property-6b.c property-stack.S} \
991 {{readelf {-n} property-2a.r}} \
992 "property-6.o" \
993 ] \
994 [list \
995 "Build property-6" \
996 "-Wl,--as-needed,-z,noexecstack \
997 tmpdir/property-6.o tmpdir/property-6.so" \
998 "-Wa,-mx86-used-note=no" \
999 { dummy.s } \
1000 {{readelf {-n} property-2.r}} \
1001 "property-6" \
1002 ] \
1003 [list \
1004 "Build property 7a (.o)" \
1005 "-r -nostdlib" \
1006 "-Wa,-mx86-used-note=yes" \
1007 {property-unsorted-1.S} \
1008 {{readelf {-n} property-7a.r}} \
1009 "property-7a.o" \
1010 ] \
1011 [list \
1012 "Build property 7b (.o)" \
1013 "-r -nostdlib" \
1014 "-Wa,-mx86-used-note=yes" \
1015 {property-unsorted-2.S} \
1016 {{readelf {-n} property-7a.r}} \
1017 "property-7b.o" \
1018 ] \
1019 ]
1020
1021 run_ld_link_exec_tests [list \
1022 [list \
1023 "Run plt-main" \
1024 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1025 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
1026 "-Wa,-mx86-used-note=yes" \
1027 { plt-main5.c } \
1028 "plt-main" \
1029 "plt-main.out" \
1030 ] \
1031 [list \
1032 "Run plt-main with PIE" \
1033 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
1034 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
1035 "-Wa,-mx86-used-note=yes" \
1036 { plt-main5.c } \
1037 "plt-main-pie" \
1038 "plt-main.out" \
1039 "-fPIC" \
1040 ] \
1041 [list \
1042 "Run copyreloc-main with PIE and GOTOFF" \
1043 "-Wl,--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
1044 "-Wa,-mx86-used-note=yes" \
1045 { dummy.s } \
1046 "copyreloc-main" \
1047 "copyreloc-main.out" \
1048 ] \
1049 [list \
1050 "Run pr17689 with PIE and GOTOFF" \
1051 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
1052 "-Wa,-mx86-used-note=yes" \
1053 { dummy.c } \
1054 "pr17689" \
1055 "pr17689.out" \
1056 ] \
1057 [list \
1058 "Run pr17689 with PIE, -z now and GOTOFF" \
1059 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -z now" \
1060 "-Wa,-mx86-used-note=yes" \
1061 { dummy.c } \
1062 "pr17689now" \
1063 "pr17689.out" \
1064 ] \
1065 [list \
1066 "Run pr17689ver with PIE and GOTOFF" \
1067 "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
1068 "-Wa,-mx86-used-note=yes" \
1069 { dummy.c } \
1070 "pr17689ver" \
1071 "pr17689.out" \
1072 ] \
1073 [list \
1074 "Run pr18900" \
1075 "tmpdir/pr18900.o tmpdir/pr18900.so" \
1076 "-Wa,-mx86-used-note=yes" \
1077 { dummy.s } \
1078 "pr18900" \
1079 "pr18900.out" \
1080 ] \
1081 [list \
1082 "Run pr19031" \
1083 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr19031.so" \
1084 "-Wa,-mx86-used-note=yes" \
1085 { pr19031b.S pr19031c.c } \
1086 "pr19031" \
1087 "pr19031.out" \
1088 "$NOPIE_CFLAGS" \
1089 ] \
1090 [list \
1091 "Run got1" \
1092 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/got1d.so" \
1093 "-Wa,-mx86-used-note=yes" \
1094 { got1a.S got1b.c got1c.c } \
1095 "got1" \
1096 "got1.out" \
1097 ] \
1098 [list \
1099 "Run property 1" \
1100 "" \
1101 "-Wa,-mx86-used-note=yes" \
1102 {pass.c property-no-copy.S} \
1103 "property-1" "pass.out" \
1104 ] \
1105 [list \
1106 "Run property 1 (PIE)" \
1107 "-pie" \
1108 "-Wa,-mx86-used-note=yes" \
1109 {pass.c property-no-copy.S} \
1110 "property-1-pie" "pass.out" "-fPIE" \
1111 ] \
1112 [list \
1113 "Run property 1 (static)" \
1114 "-static" \
1115 "-Wa,-mx86-used-note=yes" \
1116 {pass.c property-no-copy.S} \
1117 "property-1-static" "pass.out" \
1118 ] \
1119 [list \
1120 "Run property 2" \
1121 "" \
1122 "-Wa,-mx86-used-note=yes" \
1123 {pass.c property-stack.S} \
1124 "property-2" "pass.out" \
1125 ] \
1126 [list \
1127 "Run property 2 (PIE)" \
1128 "-pie" \
1129 "-Wa,-mx86-used-note=yes" \
1130 {pass.c property-stack.S} \
1131 "property-2-pie" "pass.out" "-fPIE" \
1132 ] \
1133 [list \
1134 "Run property 2 (static)" \
1135 "-static" \
1136 "-Wa,-mx86-used-note=yes" \
1137 {pass.c property-stack.S} \
1138 "property-3-static" "pass.out" \
1139 ] \
1140 ]
1141
1142 undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
1143 undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
1144 undefined_weak "-fPIE" "-pie"
1145 undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS"
1146 undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
1147 }
1148
1149 # Must be native with the C compiler and working IFUNC support,
1150 if { [isnative]
1151 && [check_ifunc_available]
1152 && [istarget "i?86-*-*"]
1153 && [check_compiler_available] } {
1154 run_cc_link_tests [list \
1155 [list \
1156 "Build ifunc-1a.o ifunc-1b.o ifunc-1c.o ifunc-1d.o" \
1157 "" \
1158 "-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
1159 { ifunc-1a.c ifunc-1b.S ifunc-1c.S ifunc-1d.S } \
1160 ] \
1161 [list \
1162 "Build pr21168a.o" \
1163 "" \
1164 "-Wa,-mx86-used-note=yes" \
1165 { pr21168a.c } \
1166 ] \
1167 [list \
1168 "Build pr21168.so" \
1169 "-shared" \
1170 "-Wa,-mx86-used-note=yes" \
1171 { pr21168b.S } \
1172 "" \
1173 "pr21168.so" \
1174 ] \
1175 ]
1176
1177 run_ld_link_exec_tests [list \
1178 [list \
1179 "Run ifunc-1a" \
1180 "tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
1181 tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1182 "-Wa,-mx86-used-note=yes" \
1183 { dummy.c } \
1184 "ifunc-1a" \
1185 "pass.out" \
1186 ] \
1187 [list \
1188 "Run ifunc-1b" \
1189 "--static tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
1190 tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1191 "-Wa,-mx86-used-note=yes" \
1192 { dummy.c } \
1193 "ifunc-1b" \
1194 "pass.out" \
1195 ] \
1196 [list \
1197 "Run pr21168" \
1198 "tmpdir/pr21168a.o tmpdir/pr21168.so" \
1199 "-Wa,-mx86-used-note=yes" \
1200 { dummy.c } \
1201 "pr21168" \
1202 "pass.out" \
1203 ] \
1204 ]
1205
1206 if { [istarget "i?86-*-linux*"] } {
1207 run_cc_link_tests [list \
1208 [list \
1209 "Build pr21168.so with -z ibtplt" \
1210 "-shared -Wl,-z,ibtplt" \
1211 "-Wa,-mx86-used-note=yes" \
1212 { pr21168b.S } \
1213 "" \
1214 "pr21168-ibt.so" \
1215 ] \
1216 [list \
1217 "Build ifunc-1a with -z ibtplt" \
1218 "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
1219 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1220 "-Wa,-mx86-used-note=yes" \
1221 { dummy.c } \
1222 {{objdump {-dw} plt-main-ibt.dd}} \
1223 "ifunc-1a-ibt" \
1224 ] \
1225 [list \
1226 "Build ifunc-1a with PIE -z ibtplt" \
1227 "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
1228 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1229 "-Wa,-mx86-used-note=yes" \
1230 { dummy.c } \
1231 {{objdump {-dw} plt-pie-ibt.dd}} \
1232 "ifunc-1a-pie-ibt" \
1233 ] \
1234 ]
1235
1236 run_ld_link_exec_tests [list \
1237 [list \
1238 "Run ifunc-1a with -z ibtplt" \
1239 "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
1240 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1241 "-Wa,-mx86-used-note=yes" \
1242 { dummy.c } \
1243 "ifunc-1a-ibt" \
1244 "pass.out" \
1245 ] \
1246 [list \
1247 "Run ifunc-1a with PIE -z ibtplt" \
1248 "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
1249 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1250 "-Wa,-mx86-used-note=yes" \
1251 { dummy.c } \
1252 "ifunc-1a-pie-ibt" \
1253 "pass.out" \
1254 ] \
1255 [list \
1256 "Run pr21168 with -z ibtplt" \
1257 "tmpdir/pr21168a.o tmpdir/pr21168-ibt.so" \
1258 "-Wa,-mx86-used-note=yes" \
1259 { dummy.c } \
1260 "pr21168-ibt" \
1261 "pass.out" \
1262 ] \
1263 ]
1264 }
1265 }
1266
1267 # Must be native with the C compiler.
1268 if { [isnative]
1269 && [istarget "i?86-*-*"]
1270 && [check_compiler_available] } {
1271 run_cc_link_tests [list \
1272 [list \
1273 "Build pr22001-1.so" \
1274 "-shared -Wl,-z,notext" \
1275 "-Wa,-mx86-used-note=yes" \
1276 { pr22001-1a.c } \
1277 {} \
1278 "pr22001-1.so" \
1279 ] \
1280 [list \
1281 "Build pr21997-1.so" \
1282 "-shared" \
1283 "-Wa,-mx86-used-note=yes" \
1284 { property-stack.S property-no-copy.S pr21997-1a.S } \
1285 {} \
1286 "pr21997-1.so" \
1287 ] \
1288 [list \
1289 "Build pr22842.so" \
1290 "-shared" \
1291 "-fPIC -Wa,-mx86-used-note=yes" \
1292 { pr22842a.c } \
1293 {} \
1294 "pr22842.so" \
1295 ] \
1296 [list \
1297 "Build pr28875.so" \
1298 "-shared -Wl,-z,indirect-extern-access" \
1299 "-fPIC" \
1300 { pr28875a.c } \
1301 {} \
1302 "pr28875.so" \
1303 ] \
1304 [list \
1305 "Build pr28875" \
1306 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr28875.so" \
1307 "$NOPIE_CFLAGS" \
1308 { pr28875b.c } \
1309 {{error_output "pr28875.err"}} \
1310 "pr28875" \
1311 ] \
1312 [list \
1313 "Build pr21997-1" \
1314 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-z,notext tmpdir/pr21997-1.so" \
1315 "$NOPIE_CFLAGS -Wa,-mx86-used-note=yes" \
1316 { pr21997-1b.c } \
1317 {{error_output "pr21997-1.err"}} \
1318 "pr21997-1" \
1319 ] \
1320 ]
1321
1322 # The musl C library does not support TEXTRELs.
1323 if { ![istarget i?86-*-musl] } {
1324 run_ld_link_exec_tests [list \
1325 [list \
1326 "Run pr22001-1" \
1327 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed,-z,notext tmpdir/pr22001-1.so" \
1328 "-Wa,-mx86-used-note=yes" \
1329 { pr22001-1b.c } \
1330 "pr22001-1" \
1331 "pass.out" \
1332 "$NOPIE_CFLAGS" \
1333 ] \
1334 ]
1335 }
1336
1337 run_ld_link_exec_tests [list \
1338 [list \
1339 "Run weakundef1 without PIE" \
1340 "$NOPIE_LDFLAGS" \
1341 "-Wa,-mx86-used-note=yes" \
1342 { weakundef1.c } \
1343 "weakundef1pie" \
1344 "pass.out" \
1345 "$NOPIE_CFLAGS" \
1346 ] \
1347 [list \
1348 "Run pr22001-1 (PIE 1)" \
1349 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1350 "-Wa,-mx86-used-note=yes" \
1351 { pr22001-1c.S } \
1352 "pr22001-1-pie-1" \
1353 "pass.out" \
1354 ] \
1355 [list \
1356 "Run pr22001-1 (PIE 2)" \
1357 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1358 "-Wa,-mx86-used-note=yes" \
1359 { pr22001-1c.S } \
1360 "pr22001-1-pie-2" \
1361 "pass.out" \
1362 ] \
1363 [list \
1364 "Run pr22001-1 (PIC 1)" \
1365 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1366 "-Wa,-mx86-used-note=yes" \
1367 { pr22001-1b.c } \
1368 "pr22001-1-pic-1" \
1369 "pass.out" \
1370 "-fPIC" \
1371 ] \
1372 [list \
1373 "Run pr22001-1 (PIC 2)" \
1374 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1375 "-Wa,-mx86-used-note=yes" \
1376 { pr22001-1b.c } \
1377 "pr22001-1-pic-2" \
1378 "pass.out" \
1379 "-fPIC" \
1380 ] \
1381 [list \
1382 "Run pr21997-1 (PIC 1)" \
1383 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1384 "-Wa,-mx86-used-note=yes" \
1385 { pr21997-1b.c } \
1386 "pr21997-1-pic-1" \
1387 "pass.out" \
1388 "-fPIC" \
1389 ] \
1390 [list \
1391 "Run pr21997-1 (PIC 2)" \
1392 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1393 "-Wa,-mx86-used-note=yes" \
1394 { pr21997-1b.c } \
1395 "pr21997-1-pic-2" \
1396 "pass.out" \
1397 "-fPIC" \
1398 ] \
1399 [list \
1400 "Run pr21997-1 (PIE 1)" \
1401 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1402 "-Wa,-mx86-used-note=yes" \
1403 { pr21997-1c.S } \
1404 "pr21997-1-pie-1" \
1405 "pass.out" \
1406 ] \
1407 [list \
1408 "Run pr21997-1 (PIE 2)" \
1409 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1410 "-Wa,-mx86-used-note=yes" \
1411 { pr21997-1c.S } \
1412 "pr21997-1-pie-2" \
1413 "pass.out" \
1414 ] \
1415 [list \
1416 "Build pr22842" \
1417 "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
1418 "-Wa,-mx86-used-note=yes" \
1419 { pr22842b.S } \
1420 "pr22842" \
1421 "pass.out" \
1422 ] \
1423 [list \
1424 "Run pr23997" \
1425 "" \
1426 "" \
1427 { ../ld-x86-64/pr23997a.s ../ld-x86-64/pr23997b.c \
1428 ../ld-x86-64/pr23997c.c } \
1429 "pr23997" \
1430 "pass.out" \
1431 ] \
1432 ]
1433
1434 if { [at_least_gcc_version 5 0] } {
1435 run_ld_link_exec_tests [list \
1436 [list \
1437 "Run weakundef1 with PIE" \
1438 "-pie" \
1439 "-Wa,-mx86-used-note=yes" \
1440 { weakundef1.c } \
1441 "weakundef1pie" \
1442 "pass.out" \
1443 "-fPIE" \
1444 ] \
1445 ]
1446 }
1447 }
1448
1449 if { !([istarget "i?86-*-linux*"]
1450 || [istarget "x86_64-*-linux*"]) } {
1451 set ASFLAGS "$saved_ASFLAGS"
1452 return
1453 }
1454
1455 run_ld_link_tests [list \
1456 [list \
1457 "basic PLT generation (non-PIC, -z now)" \
1458 "-z now -melf_i386 --hash-style=sysv \
1459 -z noseparate-code tmpdir/libpltlib.so" \
1460 "" \
1461 "--32" \
1462 {plt2.s} \
1463 {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
1464 "plt2" \
1465 ] \
1466 [list \
1467 "basic PLT generation (PIC, -z now)" \
1468 "-z now -shared -melf_i386 tmpdir/libpltlib.so" \
1469 "" \
1470 "--32 -mx86-used-note=yes" \
1471 {plt-pic.s} \
1472 {{objdump -dwr plt-pic2.dd}} \
1473 "plt-pic2.so" \
1474 ] \
1475 [list \
1476 "Build pr21626.so" \
1477 "-shared -melf_i386" \
1478 "" \
1479 "--32 -mx86-used-note=yes" \
1480 {property-x86-3.s} \
1481 "" \
1482 "pr21626.so" \
1483 ] \
1484 [list \
1485 "Build pr21626" \
1486 "-melf_i386 tmpdir/pr21626.so" \
1487 "" \
1488 "--32 -mx86-used-note=yes" \
1489 {start.s foo.s} \
1490 "" \
1491 "pr21626" \
1492 ] \
1493 ]
1494
1495 # Linux only tests
1496 run_dump_test "pltgot-1"
1497 run_dump_test "pltgot-2"
1498 run_dump_test "pr20830"
1499 run_dump_test "ibt-plt-1"
1500 run_dump_test "ibt-plt-2a"
1501 run_dump_test "ibt-plt-2b"
1502 run_dump_test "ibt-plt-2c"
1503 run_dump_test "ibt-plt-2d"
1504 run_dump_test "ibt-plt-3a"
1505 run_dump_test "ibt-plt-3b"
1506 run_dump_test "ibt-plt-3c"
1507 run_dump_test "ibt-plt-3d"
1508
1509 set ASFLAGS "$saved_ASFLAGS"