1 # Expect script for ld-i386 tests
2 # Copyright (C) 2002-2018 Free Software Foundation, Inc.
4 # This file is part of the GNU Binutils.
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.
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.
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,
23 set saved_ASFLAGS "$ASFLAGS"
24 if { [is_elf_format] \
25 && ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
26 set ASFLAGS "$ASFLAGS -mx86-used-note=no"
29 # Test i386 linking; all types of relocs. This tests the assembler and
30 # tools like objdump as well as the linker.
32 if {[istarget "i?86-*-vxworks"]} {
34 {"VxWorks shared library test 1"
35 "-shared -Tvxworks1.ld --hash-style=sysv" ""
37 {{readelf --relocs vxworks1-lib.rd} {objdump -dr vxworks1-lib.dd}
38 {readelf --symbols vxworks1-lib.nd} {readelf -d vxworks1-lib.td}}
40 {"VxWorks executable test 1 (dynamic)" \
41 "tmpdir/libvxworks1.so -Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
43 {{readelf --relocs vxworks1.rd} {objdump -dr vxworks1.dd}}
45 {"VxWorks executable test 2 (dynamic)" \
46 "-Tvxworks1.ld --hash-style=sysv -q --force-dynamic" ""
48 {{readelf --segments vxworks2.sd}}
50 {"VxWorks executable test 2 (static)"
51 "-Tvxworks1.ld --hash-style=sysv" ""
53 {{readelf --segments vxworks2-static.sd}}
56 run_ld_link_tests $i386tests
57 run_dump_test "vxworks1-static"
60 if [istarget "*-*-go32*"] {
61 run_ld_link_tests {{"go32 stub" "" "" "" {zero.s} {} "go32stub"}}
63 set src "tmpdir/go32stub"
64 set dest "tmpdir/go32stub-copy"
66 set test "go32 stub patch the source"
68 fconfigure $fi -translation binary
69 if {[read $fi 2] != "MZ"} {
74 puts -nonewline $fi "objcopy-test-go32stub"
78 set test "go32 stub objcopy"
79 set status [remote_exec build $OBJCOPY "$OBJCOPYFLAGS $src $dest"]
80 set exec_output [lindex $status 1]
81 set exec_output [prune_warnings $exec_output]
82 if [string match "" $exec_output] then {
85 send_log "$exec_output\n"
86 verbose "$exec_output" 1
90 # cmp would compare the whole files and some data after the initial exe
92 set test "go32 stub comparison after objcopy"
94 fconfigure $fi -translation binary
95 set src_stub [read $fi 2048]
98 fconfigure $fi -translation binary
99 set dest_stub [read $fi 2048]
101 if {$src_stub == $dest_stub} {
108 if { !([istarget "i?86-*-elf*"]
109 || [istarget "i?86-*-linux*"]
110 || [istarget "i?86-*-gnu*"]
111 || [istarget "i?86-*-nacl*"]
112 || [istarget "x86_64-*-nacl*"]
113 || [istarget "x86_64-*-linux*"]
114 || [istarget "amd64-*-linux*"]) } {
118 # List contains test-items with 3 items followed by 2 lists:
119 # 0:name 1:ld early options 2:ld late options 3:assembler options
120 # 4:filenames of assembler files 5: action and options. 6: name of output file
123 # objdump: Apply objdump options on result. Compare with regex (last arg).
124 # nm: Apply nm options on result. Compare with regex (last arg).
125 # readelf: Apply readelf options on result. Compare with regex (last arg).
128 {"Helper shared library (basic PLT test)"
129 "-shared -melf_i386" "" "--32" {pltlib.s} {} "libpltlib.so"}
130 {"basic PLT generation (non-PIC)"
131 "-melf_i386 tmpdir/libpltlib.so" "" "--32" {plt.s}
132 {{objdump -drj.plt plt.pd}} "plt"}
133 {"basic PLT generation (PIC)"
134 "-shared -melf_i386 tmpdir/libpltlib.so" "" "--32" {plt-pic.s}
135 {{objdump -drj.plt plt-pic.pd}} "libplt-pic.so"}
136 {"TLS -fpic -shared transitions"
137 "-shared -melf_i386 --no-ld-generated-unwind-info \
138 -z noseparate-code --hash-style=sysv" ""
139 "--32" {tlspic1.s tlspic2.s}
140 {{readelf -Ssrl tlspic.rd} {objdump -drj.text tlspic.dd}
141 {objdump -sj.got tlspic.sd} {objdump -sj.tdata tlspic.td}}
143 {"TLS -fpic -shared transitions without PLT"
144 "-shared -melf_i386 --no-ld-generated-unwind-info \
145 -z noseparate-code --hash-style=sysv" ""
146 "-mrelax-relocations=yes --32"
147 {tlspic3.s tlspic2.s}
148 {{readelf -Ssrl tlspic2.rd} {objdump -drj.text tlspic2.dd}
149 {objdump -sj.got tlspic2.sd} {objdump -sj.tdata tlspic2.td}}
151 {"TLS descriptor -fpic -shared transitions"
152 "-shared -melf_i386 --no-ld-generated-unwind-info \
153 -z noseparate-code --hash-style=sysv" ""
154 "--32" {tlsdesc.s tlspic2.s}
155 {{readelf -Ssrl tlsdesc.rd} {objdump -drj.text tlsdesc.dd}
156 {objdump "-s -j.got -j.got.plt" tlsdesc.sd} {objdump -sj.tdata tlsdesc.td}}
158 {"Helper shared library" "-shared -melf_i386" ""
159 "--32" {tlslib.s} {} "libtlslib.so"}
160 {"TLS -fpic and -fno-pic exec transitions"
161 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
162 -z noseparate-code --hash-style=sysv" ""
163 "--32" {tlsbinpic.s tlsbin.s}
164 {{readelf -Ssrl tlsbin.rd} {objdump -drj.text tlsbin.dd}
165 {objdump -sj.got tlsbin.sd} {objdump -sj.tdata tlsbin.td}}
167 {"TLS -fpic and -fno-pic exec transitions without PLT"
168 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
169 -z noseparate-code --hash-style=sysv" ""
170 "-mrelax-relocations=yes --32"
171 {tlsbinpic2.s tlsbin.s}
172 {{readelf -Ssrl tlsbin2.rd} {objdump -drj.text tlsbin2.dd}
173 {objdump -sj.got tlsbin2.sd} {objdump -sj.tdata tlsbin2.td}}
175 {"TLS descriptor -fpic and -fno-pic exec transitions"
176 "-melf_i386 tmpdir/libtlslib.so --no-ld-generated-unwind-info \
177 -z noseparate-code --hash-style=sysv" ""
178 "--32" {tlsbindesc.s tlsbin.s}
179 {{readelf -Ssrl tlsbindesc.rd} {objdump -drj.text tlsbindesc.dd}
180 {objdump -sj.got tlsbindesc.sd} {objdump -sj.tdata tlsbindesc.td}}
182 {"TLS -fno-pic -shared"
183 "-shared -melf_i386 --no-ld-generated-unwind-info \
184 -z noseparate-code --hash-style=sysv" ""
185 "--32" {tlsnopic1.s tlsnopic2.s}
186 {{readelf -Ssrl tlsnopic.rd} {objdump -drj.text tlsnopic.dd}
187 {objdump -sj.got tlsnopic.sd}} "libtlsnopic.so"}
188 {"TLS with global dynamic and descriptors"
189 "-shared -melf_i386 --no-ld-generated-unwind-info \
190 -z noseparate-code --hash-style=sysv" ""
192 {{readelf -Ssrl tlsgdesc.rd} {objdump -drj.text tlsgdesc.dd}}
194 {"TLS in debug sections" "-melf_i386" ""
196 {{objdump -sj.debug_foobar tlsg.sd}} "tlsg"}
197 {"TLS @indntpoff with %eax" "-melf_i386" "" "--32" {tlsindntpoff.s}
198 {{objdump -drj.text tlsindntpoff.dd}} "tlsindntpoff"}
199 {"Reloc section order" "-shared -melf_i386 -z nocombreloc" "" "--32"
200 {reloc.s} {{objdump -hw reloc.d}} "reloc.so"}
201 {"Basic --emit-relocs support" "-shared -melf_i386 --emit-relocs" "" "--32"
202 {emit-relocs.s} {{readelf --relocs emit-relocs.rd}} "emit-relocs.so"}
203 {"-z combreloc relocation sections" "-shared -melf_i386 -z combreloc" ""
204 "--32" {combreloc.s} {{readelf -r combreloc.d}} "combreloc.so"}
205 {"TLS GD->LE transition" "-melf_i386" ""
207 {{objdump -dwr tlsgd1.dd}} "tlsgd1"}
208 {"TLS GD->LE transition without PLT" "-melf_i386" ""
209 "-mrelax-relocations=yes --32"
211 {{objdump -dwr tlsgd3.dd}} "tlsgd3"}
212 {"TLS LD->LE transition" "-melf_i386" ""
214 {{objdump -dwr tlsld1.dd}} "tlsld1"}
215 {"TLS LD->LE transition without PLT" "-melf_i386" ""
216 "-mrelax-relocations=yes --32"
218 {{objdump -dwr tlsld2.dd}} "tlsld2"}
219 {"TLS IE->LE transition" "-melf_i386" ""
221 {{objdump -dwr tlsie1.dd}} "tlsie1"}
222 {"PR ld/17313 (1)" "-melf_i386" ""
223 "--32 -mx86-used-note=yes" {zero.s} {} ""}
224 {"PR ld/17313 (2)" "-melf_i386 -shared --just-symbols=tmpdir/zero.o" ""
225 "--32 -mx86-used-note=yes" {lea1.s} {} "libpr17313.so"}
226 {"PR ld/17306 (1)" "-melf_i386" ""
227 "--32 -mx86-used-note=yes" {pr17306b.s} {} ""}
228 {"PR ld/17306 (2)" "-melf_i386 -shared -Bsymbolic --just-symbols=tmpdir/pr17306b.o" ""
229 "--32 -mx86-used-note=yes" {pr17306a.s} {} "libpr17306.so"}
230 {"PR ld/17709 (1)" "-melf_i386 -shared" ""
231 "--32 -mx86-used-note=yes" {pr17709a.s} {} "libpr17709.so"}
232 {"PR ld/17709 (2)" "-melf_i386 tmpdir/libpr17709.so" ""
233 "--32 -mx86-used-note=yes"
234 {pr17709b.s} {{readelf -r pr17709.rd}} "pr17709"}
235 {"Build pr19827a.o" "" ""
236 "--32 -mx86-used-note=yes" { pr19827a.S }}
237 {"Build pr19827b.so" "-melf_i386 -shared" ""
238 "--32 -mx86-used-note=yes"
239 { pr19827b.S } {} "pr19827b.so"}
240 {"Build pr19827" "-melf_i386 -pie tmpdir/pr19827a.o tmpdir/pr19827b.so" ""
241 "--32 -mx86-used-note=yes"
242 { dummy.s } {{readelf {-rW} pr19827.rd}} "pr19827"}
243 {"Build pr19827.so" "-melf_i386 -shared -Bsymbolic" ""
244 "--32 -mx86-used-note=yes"
245 { pr19827a.S } {{readelf {-rW} pr19827.rd}} "pr19827.so"}
248 # So as to avoid rewriting every last test case here in a nacl variant,
249 # we use black magic to massage the generic cases into nacl-variant cases.
250 if [istarget "*-*-nacl*"] {
251 # Change all the -melf_i386 to -melf_i386_nacl so linking can succeed.
252 regsub -all elf_i386 $i386tests elf_i386_nacl i386tests
254 # Same, applied to all the run_dump_test cases.
255 set options_regsub(ld) {elf_i386 elf_i386_nacl}
257 # The section/segment layout differs too much for the vanilla
258 # readelf output files to match. So massage the cases so that
259 # they refer to a foo-nacl.rd file instead of a foo.rd file.
260 regsub -all {([a-z0-9]+)\.rd} $i386tests {\1-nacl.rd} i386tests
263 regsub -all -- {([a-z0-9]+)\.pd} $i386tests {\1-nacl.pd} i386tests
266 proc iamcu_tests {} {
267 if {[istarget "*-*-nacl*"]} then {
275 if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/start.s" tmpdir/startiamcu.o] {
276 unresolved "Build Intel MCU start.o"
280 if ![ld_assemble $as "--32 $srcdir/$subdir/start.s" tmpdir/start32.o] {
281 unresolved "Build ia32 start.o"
285 if ![ld_assemble $as "--32 -march=iamcu $srcdir/$subdir/foo.s" tmpdir/fooiamcu.o] {
286 unresolved "Build Intel MCU foo.o"
290 if ![ld_assemble $as "--32 $srcdir/$subdir/foo.s" tmpdir/foo32.o] {
291 unresolved "Build ia32 foo.o"
295 run_dump_test "abs-iamcu"
296 run_dump_test "iamcu-1"
297 run_dump_test "iamcu-2"
298 run_dump_test "iamcu-3"
299 run_dump_test "iamcu-4"
304 run_ld_link_tests $i386tests
307 run_dump_test "pcrel8"
308 run_dump_test "pcrel16"
309 run_dump_test "pcrel16abs"
310 run_dump_test "alloc"
311 run_dump_test "warn1"
312 run_dump_test "tlsgd2"
313 run_dump_test "tlsgd4"
314 run_dump_test "tlsie2"
315 run_dump_test "tlsie3"
316 run_dump_test "tlsie4"
317 run_dump_test "tlsie5"
318 run_dump_test "hidden1"
319 run_dump_test "hidden2"
320 run_dump_test "hidden3"
321 run_dump_test "protected1"
322 run_dump_test "protected2"
323 run_dump_test "protected3"
324 run_dump_test "protected4"
325 run_dump_test "protected5"
326 run_dump_test "protected6a"
327 run_dump_test "protected6b"
328 run_dump_test "protected7"
329 run_dump_test "tlspie1"
330 run_dump_test "tlspie2"
331 run_dump_test "tlspie3a"
332 run_dump_test "tlspie3b"
333 run_dump_test "tlspie3c"
334 run_dump_test "nogot1"
335 run_dump_test "nogot2"
336 run_dump_test "discarded1"
337 run_dump_test "pr12718"
338 run_dump_test "pr12921"
339 run_dump_test "pr12570a"
340 run_dump_test "pr12570b"
341 run_dump_test "lea1a"
342 run_dump_test "lea1b"
343 run_dump_test "lea1c"
344 run_dump_test "lea1d"
345 run_dump_test "lea1e"
346 run_dump_test "lea1f"
347 run_dump_test "mov1a"
348 run_dump_test "mov1b"
349 run_dump_test "mov2a"
350 run_dump_test "mov2b"
352 run_dump_test "branch1"
353 run_dump_test "call1"
354 run_dump_test "call2"
355 run_dump_test "call3a"
356 run_dump_test "call3b"
357 run_dump_test "call3c"
358 run_dump_test "call3d"
359 run_dump_test "call3e"
360 run_dump_test "call3f"
361 run_dump_test "call3g"
362 run_dump_test "call3h"
365 run_dump_test "load1"
366 run_dump_test "load1-nacl"
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-1d-nacl"
382 run_dump_test "pr19636-1e"
383 run_dump_test "pr19636-1f"
384 run_dump_test "pr19636-1g"
385 run_dump_test "pr19636-1h"
386 run_dump_test "pr19636-1i"
387 run_dump_test "pr19636-1j"
388 run_dump_test "pr19636-1k"
389 run_dump_test "pr19636-1l"
390 run_dump_test "pr19636-2a"
391 run_dump_test "pr19636-2b"
392 run_dump_test "pr19636-2c"
393 run_dump_test "pr19636-2c-nacl"
394 run_dump_test "pr19636-2d"
395 run_dump_test "pr19636-2d-nacl"
396 run_dump_test "pr19636-2e"
397 run_dump_test "pr19636-2e-nacl"
398 run_dump_test "pr19636-3a"
399 run_dump_test "pr19636-3b"
400 run_dump_test "pr19636-3c"
401 run_dump_test "pr19636-3d"
402 run_dump_test "pr19636-3e"
403 run_dump_test "pr19636-3f"
404 run_dump_test "pr19636-3g"
405 run_dump_test "pr19636-3h"
406 run_dump_test "pr19636-3i"
407 run_dump_test "pr19636-4a"
408 run_dump_test "pr19636-4b"
409 run_dump_test "pr19636-4c"
410 run_dump_test "pr19636-4d"
411 run_dump_test "pr19645"
412 run_dump_test "pr19609-1a"
413 run_dump_test "pr19609-1b"
414 run_dump_test "pr19609-1c"
415 run_dump_test "pr19609-1d"
416 run_dump_test "pr19609-1e"
417 run_dump_test "pr19609-1f"
418 run_dump_test "pr19609-1g"
419 run_dump_test "pr19609-1h"
420 run_dump_test "pr19609-1i"
421 run_dump_test "pr19609-2a"
422 run_dump_test "pr19609-2b"
423 run_dump_test "pr19609-2c"
424 run_dump_test "undefweaka"
425 run_dump_test "undefweakb"
426 run_dump_test "pr19539"
427 run_dump_test "pr20117"
428 run_dump_test "pr20244-1a"
429 run_dump_test "pr20244-1b"
430 run_dump_test "pr20244-1c"
431 run_dump_test "pr20244-2a"
432 run_dump_test "pr20244-2b"
433 run_dump_test "pr20244-2c"
434 run_dump_test "pr20244-2d"
435 run_dump_test "pr20244-4a"
436 run_dump_test "pr20244-4b"
437 run_dump_test "pr20244-4c"
438 run_dump_test "pr20253-3"
439 run_dump_test "pr20253-4a"
440 run_dump_test "pr20253-4b"
441 run_dump_test "pr20253-4c"
442 run_dump_test "pr20253-5"
443 run_dump_test "pr20515"
444 run_dump_test "property-x86-3"
445 run_dump_test "property-x86-4a"
446 run_dump_test "property-x86-4b"
447 run_dump_test "property-x86-5"
448 run_dump_test "property-x86-ibt1a"
449 run_dump_test "property-x86-ibt1b"
450 run_dump_test "property-x86-ibt2"
451 run_dump_test "property-x86-ibt3a"
452 run_dump_test "property-x86-ibt3b"
453 run_dump_test "property-x86-ibt4"
454 run_dump_test "property-x86-ibt5"
455 run_dump_test "property-x86-shstk1a"
456 run_dump_test "property-x86-shstk1b"
457 run_dump_test "property-x86-shstk2"
458 run_dump_test "property-x86-shstk3a"
459 run_dump_test "property-x86-shstk3b"
460 run_dump_test "property-x86-shstk4"
461 run_dump_test "property-x86-shstk5"
463 run_dump_test "pie1-nacl"
464 run_dump_test "pr21884"
465 run_dump_test "pr21884-nacl"
466 run_dump_test "pr22115-1a"
467 run_dump_test "pr22115-1b"
468 run_dump_test "pr22115-1c"
469 run_dump_test "pr22115-1d"
470 run_dump_test "pr22135"
471 run_dump_test "pr22782"
472 run_dump_test "pr22929"
473 run_dump_test "pr23189"
474 run_dump_test "pr23194"
475 run_dump_test "pr23372a"
476 run_dump_test "pr23372b"
477 run_dump_test "pr23372c"
478 run_dump_test "pr23372d"
479 run_dump_test "pr23486a"
480 run_dump_test "pr23486b"
481 run_dump_test "pr23486c"
482 run_dump_test "pr23486d"
484 if { !([istarget "i?86-*-linux*"]
485 || [istarget "i?86-*-gnu*"]
486 || [istarget "i?86-*-nacl*"]
487 || [istarget "x86_64-*-nacl*"]
488 || [istarget "x86_64-*-linux*"]) } {
489 set ASFLAGS "$saved_ASFLAGS"
493 run_dump_test "compressed1"
494 run_dump_test "pr12627"
495 run_dump_test "pr13302"
496 run_dump_test "pr14215"
497 run_dump_test "pr17057"
498 run_dump_test "pr17935-1"
499 run_dump_test "pr17935-2"
500 run_dump_test "pr18801"
501 run_dump_test "pr18815"
502 run_dump_test "pr19939a"
503 run_dump_test "pr19939b"
504 run_dump_test "tlsdesc2"
506 proc undefined_weak {cflags ldflags} {
507 set testname "Undefined weak symbol"
508 if { ![ string match "" $cflags$ldflags] } {
509 set testname "$testname ($cflags $ldflags)"
512 if { [string match "*-fPIE*" $cflags]
513 && ![string match "*-z nodynamic-undefined-weak*" $ldflags] } {
514 set weak_symbol "Weak defined"
516 set weak_symbol "Weak undefined"
519 run_cc_link_tests [list \
521 "Build libpr19704a.so" \
522 "-shared -Wl,-soname,libpr19704.so" \
523 "-Wa,-mrelax-relocations=yes" \
529 "Build libpr19704b.so" \
530 "-shared -Wl,-soname,libpr19704.so" \
531 "-fPIC -Wa,-mrelax-relocations=yes" \
538 exec cp tmpdir/libpr19704a.so tmpdir/libpr19704.so
540 run_ld_link_exec_tests [list \
543 "$ldflags tmpdir/libpr19704.so -Wl,-R,tmpdir" \
544 "-Wa,-mrelax-relocations=yes" \
552 exec cp tmpdir/libpr19704b.so tmpdir/libpr19704.so
554 set exec_output [run_host_cmd tmpdir/pr19704 ""]
555 if {![string match $weak_symbol $exec_output]} {
562 # Add $PLT_CFLAGS if PLT is expected.
565 # Must be Linux native with the C compiler
567 && [istarget "i?86-*-linux*"]
568 && [which $CC] != 0 } {
569 run_cc_link_tests [list \
573 "-fPIC -Wa,-mrelax-relocations=yes" \
579 "Build libplt-main1.a" \
581 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
583 {{readelf {-Wr} plt-main1.rd}} \
587 "Build libplt-main2.a" \
589 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes" \
591 {{readelf {-Wr} plt-main2.rd}} \
595 "Build libplt-main3.a" \
597 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
599 {{readelf {-Wr} plt-main3.rd}} \
603 "Build libplt-main4.a" \
605 "-fPIC -Wa,-mrelax-relocations=yes,-mrelax-relocations=yes $PLT_CFLAGS" \
607 {{readelf {-Wr} plt-main4.rd}} \
612 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
613 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
614 "-Wa,-mrelax-relocations=yes" \
616 {{readelf {-Wr} plt-main.rd}} \
620 "Build plt-main with PIE" \
621 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
622 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
623 "-fPIC -Wa,-mrelax-relocations=yes" \
625 {{readelf {-Wr} plt-main.rd}} \
629 "Build copyreloc-lib.so" \
631 "-fPIC -Wa,-mrelax-relocations=yes" \
632 { copyreloc-lib.c } \
637 "Build libcopyreloc-main.a" \
639 "-Wa,-mrelax-relocations=yes" \
640 { copyreloc-main.S } \
642 "libcopyreloc-main.a" \
645 "Build copyreloc-main with PIE and GOTOFF (1)" \
646 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
647 "-Wa,-mrelax-relocations=yes" \
649 {{readelf {-Wr} copyreloc-main1.rd}} \
653 "Build copyreloc-main with PIE and GOTOFF (2)" \
654 "tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
655 "-Wa,-mrelax-relocations=yes" \
657 {{readelf {-Wr} copyreloc-main2.rd}} \
663 "-fPIC -Wa,-mrelax-relocations=yes" \
669 "Build pr17689.so with -z now" \
670 "-shared -Wl,-z,now" \
671 "-fPIC -Wa,-mrelax-relocations=yes" \
673 {{readelf {-Wr} pr17689now.rd}} \
677 "Build pr17689ver.so" \
678 "-shared -Wl,--version-script,pr17689a.t" \
679 "-fPIC -Wa,-mrelax-relocations=yes" \
687 "-Wa,-mrelax-relocations=yes" \
693 "Build pr17689 with PIE and GOTOFF" \
694 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
695 "-Wa,-mrelax-relocations=yes" \
697 {{readelf {-Wr} pr17689.rd}} \
701 "Build pr17689 with PIE, -z now and GOTOFF" \
702 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -Wl,-z,now" \
703 "-Wa,-mrelax-relocations=yes" \
705 {{readelf {-Wr} pr17689now.rd}} \
709 "Build pr17689ver with PIE and GOTOFF" \
710 "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
711 "-Wa,-mrelax-relocations=yes" \
713 {{readelf {-Wr} pr17689ver.rd}} \
717 "Build pr17827 with PIE and GOTOFF" \
718 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
719 "-Wa,-mrelax-relocations=yes" \
721 {{readelf {-Wr} pr17827.rd}} \
727 "-fPIC -Wa,-mrelax-relocations=yes" \
735 "-Wa,-mrelax-relocations=yes" \
736 { pr18900b.c pr18900c.c } \
742 "tmpdir/pr18900.o tmpdir/pr18900.so" \
743 "-Wa,-mrelax-relocations=yes" \
745 {{readelf {-Wrd} pr18900a.rd}} \
750 "-Wl,--as-needed tmpdir/pr18900.o tmpdir/pr18900.so" \
751 "-Wa,-mrelax-relocations=yes" \
753 {{readelf {-Wrd} pr18900b.rd}} \
759 "-fPIC -Wa,-mrelax-relocations=yes" \
767 "-Wa,-mrelax-relocations=yes" \
775 "-Wa,-mrelax-relocations=yes" \
776 { got1a.S got1b.c got1c.c } \
782 "$NOPIE_LDFLAGS -Wl,--as-needed tmpdir/gotpc1.o tmpdir/got1d.so" \
783 "-Wa,-mx86-used-note=no" \
785 {{objdump {-dw} got1.dd}} \
791 "-Wa,-mx86-used-note=no" \
798 "-pie -nostdlib -nostartfiles tmpdir/pr19319.so" \
799 "-Wa,-mrelax-relocations=yes" \
801 {{objdump {-dw} pr19319.dd}} \
807 "-Wa,-mx86-used-note=no" \
808 {pass.c property-no-copy.S} \
809 {{readelf {-n} property-1.r}} \
813 "Build property 1 (.o)" \
815 "-Wa,-mx86-used-note=yes" \
816 {pass.c property-no-copy.S} \
817 {{readelf {-n} property-1a.r}} \
821 "Build property 1 (.so)" \
823 "-fPIC -Wa,-mx86-used-note=no" \
824 {pass.c property-no-copy.S} \
825 {{readelf {-n} property-1.r}} \
831 "-Wa,-mx86-used-note=no" \
832 {pass.c property-stack.S} \
833 {{readelf {-n} property-2.r}} \
837 "Build property 2 (.o)" \
839 "-Wa,-mx86-used-note=yes" \
840 {pass.c property-stack.S} \
841 {{readelf {-n} property-2a.r}} \
845 "Build property 2 (.so)" \
847 "-fPIC -Wa,-mx86-used-note=no" \
848 {pass.c property-stack.S} \
849 {{readelf {-n} property-2.r}} \
855 "-Wa,-mx86-used-note=no" \
856 {pass.c property-stack.S property-x86-1.S} \
857 {{readelf {-n} property-3.r}} \
861 "Build property 3 (.o)" \
863 "-Wa,-mx86-used-note=yes" \
864 {pass.c property-x86-1.S property-stack.S} \
865 {{readelf {-n} property-3a.r}} \
869 "Build property 3 (.so)" \
871 "-fPIC -Wa,-mx86-used-note=no" \
872 {property-x86-1.S pass.c property-stack.S} \
873 {{readelf {-n} property-3.r}} \
879 "-Wa,-mx86-used-note=no" \
880 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
881 {{readelf {-n} property-4.r}} \
885 "Build property 4 (.o)" \
887 "-Wa,-mx86-used-note=yes" \
888 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
889 {{readelf {-n} property-4a.r}} \
893 "Build property 4 (.so)" \
895 "-fPIC -Wa,-mx86-used-note=no" \
896 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
897 {{readelf {-n} property-4.r}} \
901 "Build property 4 (-Wl,-z,stack-size=0)" \
902 "-Wl,-z,stack-size=0" \
903 "-Wa,-mx86-used-note=no" \
904 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
905 {{readelf {-n} property-4.r}} \
910 "-Wl,-z,stack-size=0x900000" \
911 "-Wa,-mx86-used-note=no" \
912 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
913 {{readelf {-n} property-5.r}} \
917 "Build property 5 (.o)" \
918 "-r -nostdlib -Wl,-z,stack-size=0x900000" \
919 "-Wa,-mx86-used-note=yes" \
920 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
921 {{readelf {-n} property-5a.r}} \
925 "Build property 5 (.so)" \
926 "-shared -Wl,-z,stack-size=0x900000" \
927 "-fPIC -Wa,-mx86-used-note=no" \
928 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
929 {{readelf {-n} property-5.r}} \
933 "Build property-6.so" \
935 "-fPIC -Wa,-mx86-used-note=no" \
936 {property-6a.c property-6c.S} \
937 {{readelf {-n} property-6.r}} \
941 "Build property-6.o" \
943 "-Wa,-mx86-used-note=yes" \
944 {property-6b.c property-stack.S} \
945 {{readelf {-n} property-2a.r}} \
950 "-Wl,--as-needed tmpdir/property-6.o tmpdir/property-6.so" \
951 "-Wa,-mx86-used-note=no" \
953 {{readelf {-n} property-2.r}} \
957 "Build property 7a (.o)" \
959 "-Wa,-mx86-used-note=yes" \
960 {property-unsorted-1.S} \
961 {{readelf {-n} property-7a.r}} \
965 "Build property 7b (.o)" \
967 "-Wa,-mx86-used-note=yes" \
968 {property-unsorted-2.S} \
969 {{readelf {-n} property-7a.r}} \
974 run_ld_link_exec_tests [list \
977 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
978 tmpdir/plt-main4.o tmpdir/libplt-lib.so" \
979 "-Wa,-mx86-used-note=yes" \
985 "Run plt-main with PIE" \
986 "tmpdir/plt-main1.o tmpdir/plt-main2.o tmpdir/plt-main3.o \
987 tmpdir/plt-main4.o tmpdir/libplt-lib.so -pie" \
988 "-Wa,-mx86-used-note=yes" \
995 "Run copyreloc-main with PIE and GOTOFF" \
996 "-Wl,--as-needed tmpdir/copyreloc-main.o tmpdir/copyreloc-lib.so -pie" \
997 "-Wa,-mx86-used-note=yes" \
1000 "copyreloc-main.out" \
1003 "Run pr17689 with PIE and GOTOFF" \
1004 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie" \
1005 "-Wa,-mx86-used-note=yes" \
1011 "Run pr17689 with PIE, -z now and GOTOFF" \
1012 "tmpdir/pr17689b.o tmpdir/pr17689.so -pie -z now" \
1013 "-Wa,-mx86-used-note=yes" \
1019 "Run pr17689ver with PIE and GOTOFF" \
1020 "tmpdir/pr17689b.o tmpdir/pr17689ver.so -pie" \
1021 "-Wa,-mx86-used-note=yes" \
1028 "tmpdir/pr18900.o tmpdir/pr18900.so" \
1029 "-Wa,-mx86-used-note=yes" \
1036 "$NOPIE_LDFLAGS tmpdir/pr19031.so" \
1037 "-Wa,-mx86-used-note=yes" \
1038 { pr19031b.S pr19031c.c } \
1045 "$NOPIE_LDFLAGS tmpdir/got1d.so" \
1046 "-Wa,-mx86-used-note=yes" \
1047 { got1a.S got1b.c got1c.c } \
1054 "-Wa,-mx86-used-note=yes" \
1055 {pass.c property-no-copy.S} \
1056 "property-1" "pass.out" \
1059 "Run property 1 (PIE)" \
1061 "-Wa,-mx86-used-note=yes" \
1062 {pass.c property-no-copy.S} \
1063 "property-1-pie" "pass.out" "-fPIE" \
1066 "Run property 1 (static)" \
1068 "-Wa,-mx86-used-note=yes" \
1069 {pass.c property-no-copy.S} \
1070 "property-1-static" "pass.out" \
1075 "-Wa,-mx86-used-note=yes" \
1076 {pass.c property-stack.S} \
1077 "property-2" "pass.out" \
1080 "Run property 2 (PIE)" \
1082 "-Wa,-mx86-used-note=yes" \
1083 {pass.c property-stack.S} \
1084 "property-2-pie" "pass.out" "-fPIE" \
1087 "Run property 2 (static)" \
1089 "-Wa,-mx86-used-note=yes" \
1090 {pass.c property-stack.S} \
1091 "property-3-static" "pass.out" \
1096 "-Wa,-mx86-used-note=yes" \
1097 {pass.c property-stack.S property-x86-1.S} \
1098 "property-3" "pass.out" \
1101 "Run property 3 (PIE)" \
1103 "-Wa,-mx86-used-note=yes" \
1104 {pass.c property-x86-1.S property-stack.S} \
1105 "property-3-pie" "pass.out" "-fPIE" \
1108 "Run property 3 (static)" \
1110 "-Wa,-mx86-used-note=yes" \
1111 {property-x86-1.S pass.c property-stack.S} \
1112 "property-3-static" "pass.out" \
1117 "-Wa,-mx86-used-note=yes" \
1118 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1119 "property-4" "pass.out" \
1122 "Run property 4 (PIE)" \
1124 "-Wa,-mx86-used-note=yes" \
1125 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1126 "property-4-pie" "pass.out" "-fPIE" \
1129 "Run property 4 (static)" \
1131 "-Wa,-mx86-used-note=yes" \
1132 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1133 "property-4-static" "pass.out" \
1137 "-Wl,-z,stack-size=0x900000" \
1138 "-Wa,-mx86-used-note=yes" \
1139 {pass.c property-stack.S property-x86-1.S property-x86-2.S} \
1140 "property-5" "pass.out" \
1143 "Run property 5 (PIE)" \
1144 "-pie -Wl,-z,stack-size=0x900000" \
1145 "-Wa,-mx86-used-note=yes" \
1146 {pass.c property-x86-2.S property-x86-1.S property-stack.S} \
1147 "property-5-pie" "pass.out" "-fPIE" \
1150 "Run property 5 (static)" \
1151 "-static -Wl,-z,stack-size=0x900000" \
1152 "-Wa,-mx86-used-note=yes" \
1153 {property-x86-2.S property-x86-1.S pass.c property-stack.S} \
1154 "property-5-static" "pass.out" \
1158 undefined_weak "$NOPIE_CFLAGS" "$NOPIE_LDFLAGS"
1159 undefined_weak "-fPIE" "$NOPIE_LDFLAGS"
1160 undefined_weak "-fPIE" "-pie"
1161 undefined_weak "-fPIE" "-z nodynamic-undefined-weak $NOPIE_LDFLAGS"
1162 undefined_weak "-fPIE" "-pie -z nodynamic-undefined-weak"
1165 global NOPIE_CFLAGS NOPIE_LDFLAGS
1167 # Must be native with the C compiler and working IFUNC support,
1169 && [check_ifunc_available]
1170 && [istarget "i?86-*-*"]
1171 && [which $CC] != 0 } {
1172 run_cc_link_tests [list \
1174 "Build ifunc-1a.o ifunc-1b.o ifunc-1c.o ifunc-1d.o" \
1176 "-fPIC -O2 -g -Wa,-mx86-used-note=yes" \
1177 { ifunc-1a.c ifunc-1b.S ifunc-1c.S ifunc-1d.S } \
1180 "Build pr21168a.o" \
1182 "-Wa,-mx86-used-note=yes" \
1186 "Build pr21168.so" \
1188 "-Wa,-mx86-used-note=yes" \
1195 run_ld_link_exec_tests [list \
1198 "tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
1199 tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1200 "-Wa,-mx86-used-note=yes" \
1207 "--static tmpdir/ifunc-1a.o tmpdir/ifunc-1b.o \
1208 tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1209 "-Wa,-mx86-used-note=yes" \
1216 "tmpdir/pr21168a.o tmpdir/pr21168.so" \
1217 "-Wa,-mx86-used-note=yes" \
1224 if { [istarget "i?86-*-linux*"] } {
1225 run_cc_link_tests [list \
1227 "Build pr21168.so with -z ibtplt" \
1228 "-shared -Wl,-z,ibtplt" \
1229 "-Wa,-mx86-used-note=yes" \
1235 "Build ifunc-1a with -z ibtplt" \
1236 "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
1237 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1238 "-Wa,-mx86-used-note=yes" \
1240 {{objdump {-dw} plt-main-ibt.dd}} \
1244 "Build ifunc-1a with PIE -z ibtplt" \
1245 "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
1246 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1247 "-Wa,-mx86-used-note=yes" \
1249 {{objdump {-dw} plt-pie-ibt.dd}} \
1250 "ifunc-1a-pie-ibt" \
1254 run_ld_link_exec_tests [list \
1256 "Run ifunc-1a with -z ibtplt" \
1257 "-Wl,-z,ibtplt $NOPIE_LDFLAGS tmpdir/ifunc-1a.o \
1258 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1259 "-Wa,-mx86-used-note=yes" \
1265 "Run ifunc-1a with PIE -z ibtplt" \
1266 "-Wl,-z,ibtplt -pie tmpdir/ifunc-1a.o \
1267 tmpdir/ifunc-1b.o tmpdir/ifunc-1c.o tmpdir/ifunc-1d.o" \
1268 "-Wa,-mx86-used-note=yes" \
1270 "ifunc-1a-pie-ibt" \
1274 "Run pr21168 with -z ibtplt" \
1275 "tmpdir/pr21168a.o tmpdir/pr21168-ibt.so" \
1276 "-Wa,-mx86-used-note=yes" \
1285 # Must be native with the C compiler.
1287 && [istarget "i?86-*-*"]
1288 && [which $CC] != 0 } {
1289 run_cc_link_tests [list \
1291 "Build pr22001-1.so" \
1293 "-Wa,-mx86-used-note=yes" \
1299 "Build pr21997-1.so" \
1301 "-Wa,-mx86-used-note=yes" \
1302 { property-stack.S property-no-copy.S pr21997-1a.S } \
1307 "Build pr22842.so" \
1309 "-fPIC -Wa,-mx86-used-note=yes" \
1316 run_ld_link_exec_tests [list \
1318 "Run weakundef1 without PIE" \
1320 "-Wa,-mx86-used-note=yes" \
1328 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1329 "-Wa,-mx86-used-note=yes" \
1336 "Run pr22001-1 (PIE 1)" \
1337 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1338 "-Wa,-mx86-used-note=yes" \
1344 "Run pr22001-1 (PIE 2)" \
1345 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1346 "-Wa,-mx86-used-note=yes" \
1352 "Run pr22001-1 (PIC 1)" \
1353 "$NOPIE_LDFLAGS -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1354 "-Wa,-mx86-used-note=yes" \
1361 "Run pr22001-1 (PIC 2)" \
1362 "-pie -Wl,-z,nocopyreloc,--no-as-needed tmpdir/pr22001-1.so" \
1363 "-Wa,-mx86-used-note=yes" \
1371 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1372 "-Wa,-mx86-used-note=yes" \
1379 "Run pr21997-1 (PIC 1)" \
1380 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1381 "-Wa,-mx86-used-note=yes" \
1388 "Run pr21997-1 (PIC 2)" \
1389 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1390 "-Wa,-mx86-used-note=yes" \
1397 "Run pr21997-1 (PIE 1)" \
1398 "$NOPIE_LDFLAGS -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1399 "-Wa,-mx86-used-note=yes" \
1405 "Run pr21997-1 (PIE 2)" \
1406 "-pie -Wl,--no-as-needed tmpdir/pr21997-1.so" \
1407 "-Wa,-mx86-used-note=yes" \
1414 "-pie -Wl,--no-as-needed tmpdir/pr22842.so" \
1415 "-Wa,-mx86-used-note=yes" \
1422 if { [at_least_gcc_version 5 0] } {
1423 run_ld_link_exec_tests [list \
1425 "Run weakundef1 with PIE" \
1427 "-Wa,-mx86-used-note=yes" \
1437 if { !([istarget "i?86-*-linux*"]
1438 || [istarget "x86_64-*-linux*"]) } {
1439 set ASFLAGS "$saved_ASFLAGS"
1443 run_ld_link_tests [list \
1445 "basic PLT generation (non-PIC, -z now)" \
1446 "-z now -melf_i386 --hash-style=sysv \
1447 -z noseparate-code tmpdir/libpltlib.so" \
1451 {{readelf -SW plt2.rd} {objdump -dwr plt2.dd}} \
1455 "basic PLT generation (PIC, -z now)" \
1456 "-z now -shared -melf_i386 tmpdir/libpltlib.so" \
1458 "--32 -mx86-used-note=yes" \
1460 {{objdump -dwr plt-pic2.dd}} \
1464 "Build pr21626.so" \
1465 "-shared -melf_i386" \
1467 "--32 -mx86-used-note=yes" \
1468 {property-x86-3.s} \
1474 "-melf_i386 tmpdir/pr21626.so" \
1476 "--32 -mx86-used-note=yes" \
1484 run_dump_test "pltgot-1"
1485 run_dump_test "pltgot-2"
1486 run_dump_test "pr20830"
1487 run_dump_test "ibt-plt-1"
1488 run_dump_test "ibt-plt-2a"
1489 run_dump_test "ibt-plt-2b"
1490 run_dump_test "ibt-plt-2c"
1491 run_dump_test "ibt-plt-2d"
1492 run_dump_test "ibt-plt-3a"
1493 run_dump_test "ibt-plt-3b"
1494 run_dump_test "ibt-plt-3c"
1495 run_dump_test "ibt-plt-3d"
1497 set ASFLAGS "$saved_ASFLAGS"