1 # Expect script for various ELF tests.
2 # Copyright (C) 2006-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,
22 # Exclude non-ELF targets.
28 # Skip targets where -shared is not supported
30 if ![check_shared_lib_support] {
34 # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
35 global NOPIE_CFLAGS NOPIE_LDFLAGS
37 set old_ASFLAGS $ASFLAGS
39 # This target requires extra GAS options when building code for shared
42 if [istarget "nds32*-*"] {
43 append AFLAGS_PIC " -mpic"
45 if [istarget "tic6x-*-*"] {
46 append AFLAGS_PIC " -mpic -mpid=near"
48 if [istarget "sparc*-*-*"] {
49 append AFLAGS_PIC " -K PIC"
52 # This target requires a non-default emulation for successful shared
53 # library/executable builds.
55 if [istarget "tic6x-*-*"] {
56 append LFLAGS " -melf32_tic6x_le"
58 # HPUX targets use a different .comm syntax.
60 if [istarget "*-*-hpux*"] {
61 set hpux "--defsym HPUX=1"
63 # These targets do not default to linking with shared libraries.
64 if { [istarget "mips*vr4100*-*-elf*"] \
65 || [istarget "mips*vr4300*-*-elf*"] \
66 || [istarget "mips*vr5000*-*-elf*"] } {
67 append LFLAGS " -call_shared"
70 if [is_underscore_target] {
71 set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
74 run_ld_link_tests [list \
86 "$LFLAGS -shared --version-script pr22471.t" \
87 "tmpdir/pr22471a.so" \
95 "$LFLAGS -rpath-link ." \
96 "tmpdir/pr22471b.so" \
103 "Build pr22649-1.so" \
113 if { [check_gc_sections_available] } {
114 if [istarget mips*-*-*] {
115 set actions {{ld pr22649-2ab-mips.msg}}
117 set actions {{ld pr22649.msg}}
119 run_ld_link_tests [list \
121 "Build pr22649-2a.so" \
122 "$LFLAGS -shared -gc-sections -print-gc-sections" \
130 "Build pr22649-2b.so" \
131 "$LFLAGS -shared -gc-sections -print-gc-sections" \
132 "tmpdir/pr22649-1.so" \
139 if { [istarget mips*-*-*] && ![istarget *-*-elf*] } {
140 set actions {{ld pr22649-2cd-mips.msg}}
144 run_ld_link_tests [list \
146 "Build pr22649-2c.so" \
147 "$LFLAGS -shared -gc-sections -print-gc-sections" \
155 "Build pr22649-2d.so" \
156 "$LFLAGS -shared -gc-sections -print-gc-sections" \
157 "tmpdir/pr22649-1.so" \
166 run_ld_link_tests [list \
168 "DT_TEXTREL in shared lib" \
169 "$LFLAGS -shared --warn-shared-textrel" \
174 {readelf {-d --wide} textrel.rd}} \
179 run_ld_link_tests [list \
181 "DT_TEXTREL map file warning" \
182 "$LFLAGS -shared -M" \
191 # PR ld/20828 check for correct dynamic symbol table entries where:
192 # - symbols have been defined with a linker script,
193 # - the same symbols have been seen in shared library used in the link,
194 # - the shared library symbols have been swept in section garbage collection.
195 # Verify that the symbols are global rather than local and that a version
196 # script adjusts them accordingly.
197 # Also verify that a version definition supplied by an object rather than
198 # a version script and forcibly exported is unaffected by section GC.
199 if { [check_gc_sections_available] } {
200 run_ld_link_tests [list \
202 "PR ld/20828 dynamic symbols with section GC\
203 (auxiliary shared library)" \
204 "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \
206 {{readelf --dyn-syms pr20828-a.sd} \
207 {readelf --dyn-syms pr20828-b.sd}} \
210 "PR ld/20828 dynamic symbols with section GC (plain)" \
211 "$LFLAGS -shared --gc-sections -T pr20828.ld" \
212 "tmpdir/libpr20828.so" "$AFLAGS_PIC" \
214 {{readelf --dyn-syms pr20828-a.sd} \
215 {readelf --dyn-syms pr20828-b.sd}} \
218 "PR ld/20828 dynamic symbols with section GC (version script)" \
219 "$LFLAGS -shared --gc-sections -T pr20828.ld\
220 --version-script=pr20828.ver" \
221 "tmpdir/libpr20828.so" \
224 {{readelf --dyn-syms pr20828-b.sd} \
225 {readelf --dyn-syms pr20828-c.sd}} \
228 "PR ld/20828 dynamic symbols with section GC\
229 (versioned shared library)" \
230 "$LFLAGS -shared --gc-sections -T pr20828.ld\
231 --version-script=pr20828-v.ver" \
234 {{readelf --dyn-syms pr20828-c.sd} \
235 {readelf --dyn-syms pr20828-d.sd} \
236 {readelf --dyn-syms pr20828-e.sd}} \
239 "PR ld/20828 dynamic symbols with section GC (versioned)" \
240 "$LFLAGS -shared --gc-sections -T pr20828.ld\
241 --version-script=pr20828-v.ver" \
242 "tmpdir/libpr20828-v.so" \
245 {{readelf --dyn-syms pr20828-c.sd} \
246 {readelf --dyn-syms pr20828-d.sd} \
247 {readelf --dyn-syms pr20828-e.sd}} \
250 "PR ld/20828 forcibly exported symbol version without section GC" \
251 "$LFLAGS --no-dynamic-linker -e foo -E -T pr20828-v.ld" "" "" \
253 {{objdump -p pr20828-v.od}} \
256 "PR ld/20828 forcibly exported symbol version with section GC" \
257 "$LFLAGS --no-dynamic-linker -e foo --gc-sections -E -T pr20828-v.ld" "" "" \
259 {{objdump -p pr20828-v.od}} \
262 # PR ld/21233 check for correct dynamic symbol table entries where:
263 # - a symbol has been defined in a shared library used in the link,
264 # - the symbol has been referenced from a section swept in garbage collection,
265 # - the symbol has also been forced to be entered in the output file as an
266 # undefined symbol, either with a command-line option or a linker script
268 # Verify that the undefined symbol is global rather than local.
269 if { [check_gc_sections_available] } {
270 run_ld_link_tests [list \
272 "PR ld/21233 dynamic symbols with section GC\
273 (auxiliary shared library)" \
274 "$LFLAGS -shared -T pr21233.ld" "" "$AFLAGS_PIC" \
276 {{readelf --dyn-syms pr21233-l.sd}} \
279 run_ld_link_tests [list \
281 "PR ld/21233 dynamic symbols with section GC (--undefined)" \
282 "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld" \
283 "tmpdir/libpr21233.so" "" \
285 {{readelf --dyn-syms pr21233.sd}} \
288 run_ld_link_tests [list \
290 "PR ld/21233 dynamic symbols with section GC (--require-defined)" \
291 "$LFLAGS --gc-sections -e foo --require-defined=bar\
293 "tmpdir/libpr21233.so" "" \
295 {{readelf --dyn-syms pr21233.sd}} \
298 run_ld_link_tests [list \
300 "PR ld/21233 dynamic symbols with section GC (EXTERN)" \
301 "$LFLAGS --gc-sections -e foo -T pr21233-e.ld" \
302 "tmpdir/libpr21233.so" "" \
304 {{readelf --dyn-syms pr21233.sd}} \
308 if { [check_gc_sections_available] } {
309 run_ld_link_tests [list \
312 "$LFLAGS -shared --version-script pr22150.ver" \
321 "$LFLAGS -e _start --gc-sections" \
322 "tmpdir/pr22150.so" \
325 {{readelf -V pr22150.vd}} \
331 set ASFLAGS $old_ASFLAGS
334 {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" }
336 run_ld_link_tests [list \
337 [list "Build shared library for pr14170" \
338 "-shared" "" "$AFLAGS_PIC" "pr14170b.s" {} "pr14170.so" ] \
341 # bfin does not currently support copy relocs.
342 run_ld_link_tests [list \
343 [list "PR ld/14170" \
344 "$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \
346 {pr14170c.s} { } "pr14170" ] \
349 # Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests
350 # Not will hppa64 with dot-symbols.
351 run_ld_link_tests [list \
352 [list "PR ld/21703 shared" \
353 "-shared --allow-multiple-definition --version-script pr21703.ver\
354 tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "$AFLAGS_PIC" \
355 {pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} \
357 ] "d30v-*-*" "dlx-*-*" "pj-*-*" "hppa64-*-*"
359 # This target requires extra GAS options when building non-PIC code
360 # for linking with shared libraries.
362 if [istarget "mips*-*-*"] {
363 append AFLAGS_NONPIC " -call_nonpic"
366 # Run a test to check linking a shared library with a broken linker
367 # script that accidentally marks dynamic sections as notes. The
368 # resulting executable is not expected to work, but the linker
369 # should not seg-fault whilst creating the binary.
370 run_ld_link_tests [list \
371 [list "Build shared library for broken linker script test" \
372 "-shared --hash-style=sysv" "" "$AFLAGS_PIC" "note-3.s" \
375 [list "Link using broken linker script" \
376 "$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" "" \
377 { { ld "note-3.l" } } \
381 run_ld_link_tests [list \
382 [list "Build pr17068.so" \
383 "-shared" "" "$AFLAGS_PIC" \
384 {pr17068d.s} {} "pr17068.so"] \
385 [list "Build pr17068a.a" \
387 {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"] \
388 [list "Build pr17068b.a" \
390 {pr17068b.s pr17068e.s} {} "pr17068b.a"] \
393 # bfin does not currently support copy relocs.
395 {"pr17068 link --as-needed lib in group"
396 "$LFLAGS --as-needed --no-dynamic-linker"
397 "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\
399 {start.s pr17068.s} {} "pr17068"}
402 # Fails on MIPS because ABI trickery means that a NULL reloc is emitted.
403 # Fails on bfin because relocations are not created.
404 run_ld_link_tests [list \
405 [list "-Bsymbolic-functions" \
406 "-shared -Bsymbolic-functions" "" "$AFLAGS_PIC" \
407 {symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}} \
408 "symbolic-func.so"] \
409 ] "mips*-*-*" "bfin-*-*"
411 run_ld_link_tests [list \
412 [list "Build pr20995.so" \
413 "-shared" "" "$AFLAGS_PIC" \
414 {pr20995b.s} {} "pr20995.so"] \
417 # xfail on arm*-*-eabi*. The list can be enlarged to those targets that
418 # don't support GNU_RELRO. For more details, please see discussions at:
419 # https://sourceware.org/ml/binutils/2017-01/msg00441.html
420 run_ld_link_tests [list \
421 [list "Build pr20995-2.so" \
422 "-shared -z relro" "" "$AFLAGS_PIC" \
423 {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \
424 ] "tic6x-*-*" "arm*-*-eabi*" "hppa*64*-*-hpux*" "aarch64*-*-elf*"
426 # These targets don't copy dynamic variables into .bss.
427 setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
428 # or don't have .data.rel.ro
429 setup_xfail "hppa*64*-*-hpux*"
430 run_ld_link_tests [list \
433 "$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
434 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]]
436 # xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO.
437 # Please see the link above for details.
438 setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*"
439 setup_xfail "hppa*64*-*-hpux*" "aarch64*-*-elf*"
440 run_ld_link_tests [list \
443 "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
444 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]]
446 run_ld_link_tests [list \
447 [list "Build pr22374 shared library" \
448 "-shared" "" "$AFLAGS_PIC" "pr22374b.s" {} "pr22374.so" ] \
450 if { ![istarget "alpha-*-*"]
451 && ![istarget "frv-*-*"]
452 && ![istarget "hppa*-*-*"]
453 && ![istarget "i?86-*-*"]
454 && ![istarget "ia64-*-*"]
455 && ![istarget "microblaze-*-*"]
456 && ![istarget "powerpc*-*-*"]
457 && ![istarget "x86_64-*-*"]
458 && ![istarget "xtensa-*-*"] } {
459 # The next test checks that copy relocs are not used unnecessarily,
460 # but that is just an optimization so don't complain loudly.
464 {"pr22374 function pointer initialization"
465 "" "tmpdir/pr22374.so" "" "pr22374a.s"
466 { {readelf {--wide -r --dyn-syms} "pr22374-1.r"}
467 {readelf {--wide -r} "pr22374-2.r"} }
471 if { [istarget *-*-linux*]
472 || [istarget *-*-nacl*]
473 || [istarget *-*-gnu*] } {
475 {"Weak symbols in dynamic objects 1 (support)"
476 "-shared" "" "" {weak-dyn-1a.s}
479 {"Weak symbols in dynamic objects 1 (main test)"
480 "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s}
481 {{readelf {--relocs --wide} weak-dyn-1.rd}}
486 # Check to see if the C compiler works
487 if { [which $CC] == 0 } {
491 # Add -ldl to extralibs if needed
493 if { ![istarget *-*-freebsd*]} {
500 {foo.c} {} "libfoo.so"}
501 {"Build versioned libfoo.so"
502 "-shared -Wl,--version-script=foo.map" "-fPIC"
503 {foo.c} {} "libfoov.so"}
506 {begin.c end.c} {} "libbar.so"}
507 {"Build warn libbar.so"
510 {{readelf {-S --wide} libbarw.rd}
511 {warning "^.*beginwarn.c:7: warning: function foo is deprecated$"}}
513 {"Build hidden libbar.so"
515 {begin.c endhidden.c} {} "libbarh.so"}
516 {"Build protected libbar.so"
518 {begin.c endprotected.c} {} "libbarp.so"}
519 {"Build libbar.so with libfoo.so"
520 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
521 {end.c} {} "libbarfoo.so"}
522 {"Build libar.so with versioned libfoo.so"
523 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
524 {end.c} {} "libbarfoov.so"}
525 {"Build hidden libbar.so with libfoo.so"
526 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
527 {endhidden.c} {} "libbarhfoo.so"}
528 {"Build hidden libar.so with versioned libfoo.so"
529 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
530 {endhidden.c} {} "libbarhfoov.so"}
531 {"Build protected libbar.so with libfoo.so"
532 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
533 {endprotected.c} {} "libbarpfoo.so"}
534 {"Build protected libbar.so with versioned libfoo.so"
535 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
536 {endprotected.c} {} "libbarpfoov.so"}
539 {dl1.c} {} "libdl1.so"}
540 {"Build libdl2a.so with --dynamic-list=dl2.list"
541 "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
542 {dl2.c dl2xxx.c} {} "libdl2a.so"}
543 {"Build libdl2a.so with --dynamic-list=dl2a.list"
544 "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC"
545 {dl2.c dl2xxx.c} {} "libdl2a.so"}
546 {"Build libdl2a.so with --dynamic-list-data"
547 "-shared -Wl,--dynamic-list-data" "-fPIC"
548 {dl2.c dl2xxx.c} {} "libdl2a.so"}
549 {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
550 "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
551 {dl2.c dl2xxx.c} {} "libdl2b.so"}
552 {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
553 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
554 {dl2.c dl2xxx.c} {} "libdl2c.so"}
555 {"Build libdl4a.so with --dynamic-list=dl4.list"
556 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
557 {dl4.c dl4xxx.c} {} "libdl4a.so"}
558 {"Build libdl4b.so with --dynamic-list-data"
559 "-shared -Wl,--dynamic-list-data" "-fPIC"
560 {dl4.c dl4xxx.c} {} "libdl4b.so"}
561 {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list"
562 "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
563 {dl4.c dl4xxx.c} {} "libdl4c.so"}
564 {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list"
565 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
566 {dl4.c dl4xxx.c} {} "libdl4d.so"}
567 {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new"
568 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
569 {dl4.c dl4xxx.c} {} "libdl4e.so"}
570 {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions"
571 "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC"
572 {dl4.c dl4xxx.c} {} "libdl4f.so"}
575 {dl6.c} {} "libdl6a.so"}
576 {"Build libdl6b.so with -Bsymbolic --dynamic-list-data"
577 "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
578 {dl6.c} {} "libdl6b.so"}
579 {"Build libdl6c.so with -Bsymbolic"
580 "-shared -Wl,-Bsymbolic" "-fPIC"
581 {dl6.c} {} "libdl6c.so"}
582 {"Build libdl6d.so with --dynamic-list-data -Bsymbolic"
583 "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC"
584 {dl6.c} {} "libdl6d.so"}
587 {data1.c} {} "libdata1.so"}
590 {data2.c} {} "libdata2.so"}
593 {comm1.c} {} "libcomm1.o"}
596 {func1.c} {} "libfunc1.so"}
597 {"Build libpr9676-1.a"
599 {pr9676-1.c} {} "libpr9676-1.a"}
600 {"Build libpr9676-2.a"
602 {pr9676-2.c} {} "libpr9676-2.a"}
603 {"Build libpr9676-3.so"
605 {pr9676-3.c} {} "libpr9676-3.so"}
606 {"Build libpr9676-4.so"
608 {pr9676-4.c} {} "libpr9676-4.so"}
609 {"Build libpr9676-4a.so"
610 "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group"
612 {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"}
613 {"Build libpr9679.so"
614 "-shared" "-fPIC -O0"
615 {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"}
616 {"Build libpr11138-1.so"
617 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
618 {pr11138-1.c} {} "libpr11138-1.so"}
619 {"Build libpr11138-2.o"
621 {pr11138-2.c} {} "libpr11138-2.o"}
622 {"Build pr13250-1.so"
624 {pr13250-1.c} {} "libpr13250-1.so"}
625 {"Build pr13250-2.so with libpr13250-1.so"
626 "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC"
627 {pr13250-2.c} {} "libpr13250-2.so"}
628 {"Build libpr13250-3.o"
630 {pr13250-3.c} {} "libpr13250-3.o"}
631 {"Build libpr14323-2.so"
633 {pr14323-2.c} {} "libpr14323-2.so"}
636 {pr14862-1.c} {} "libpr14862-1.o"}
637 {"Build libpr14862.so"
638 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
639 {pr14862-2.c} {} "libpr14862.so"}
640 {"Build libneeded1b.so"
642 {needed1b.c} {} "libneeded1b.so"}
643 {"Build libneeded1a.so"
644 "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC"
645 {needed1a.c} {} "libneeded1a.so"}
646 {"Build libneeded1c.o"
648 {needed1c.c} {} "libneeded1c.o"}
649 {"Build libneeded1pic.o"
650 "-r -nostdlib" "-fPIC"
651 {needed1c.c} {} "libneeded1pic.o"}
652 {"Build needed1a.so with --add-needed"
653 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
654 {dummy.c} {} "needed1a.so"}
655 {"Build needed1b.so with --copy-dt-needed-entries"
656 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
657 {dummy.c} {} "needed1b.so"}
658 {"Build needed1a.so with --no-add-needed"
659 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" ""
660 {dummy.c} {} "needed1c.so"}
661 {"Build needed1b.so with --no-copy-dt-needed-entries"
662 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
663 {dummy.c} {} "needed1d.so"}
666 {rel.c} {} "librel.so"}
667 {"Build libneeded2a.so"
669 {needed2a.c} {} "libneeded2a.so"}
670 {"Build libneeded2b.so"
671 "-shared -Wl,--version-script,needed2.ver" "-fPIC"
672 {needed2b.c} {} "libneeded2b.so"}
673 {"Build libneeded2c.o"
675 {needed2c.c} {} "libneeded2c.o"}
677 "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" ""
678 {dummy.c} {} "needed2"}
679 {"Build libneeded3a.so"
680 "-shared -Wl,--no-add-needed" "-fPIC"
681 {needed1a.c} {} "libneeded3a.so"}
682 {"Build libneeded3b.so"
683 "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC"
684 {dummy.c} {} "libneeded3b.so"}
687 {needed3.c} {} "libneeded3.so"}
689 "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
690 {dummy.c} {} "needed3"}
691 {"Build libpr2404a.so"
693 {pr2404a.c} {} "libpr2404a.so"}
694 {"Build libpr2404n.so"
695 "-shared -Wl,-z,now" "-fPIC"
696 {pr2404a.c} {} "libpr2404n.so"}
697 {"Build libpr2404b.a"
699 {pr2404b.c} {} "libpr2404b.a"}
701 "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
702 {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
704 "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
705 {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"}
706 {"Build libpr16496a.so"
707 "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
708 {pr16496a.c} {} "libpr16496a.so"}
709 {"Build libpr16496b.a"
711 {pr16496b.c} {} "libpr16496b.a"}
712 {"Build libpr16496b.so"
713 "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
714 {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
715 {"Build libpr16452a.so"
716 "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC"
717 {pr16452a.c} {} "libpr16452a.so"}
718 {"Build libpr16452b.so"
719 "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC"
720 {dummy.c} {} "libpr16452b.so"}
722 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
723 {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"}
725 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
726 {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"}
727 {"Build libpr18458a.so"
728 "-shared -Wl,-z,now" "-fPIC"
729 {pr18458a.c} {} "libpr18458a.so"}
730 {"Build libpr18458b.so"
731 "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC"
732 {pr18458b.c} {} "libpr18458b.so"}
735 {pr19073.s} {} "pr19073a.o"}
736 {"Build libpr19073.so"
737 "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC"
738 {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"}
739 {"Build pr21964-1a.so"
741 {pr21964-1a.c} {} "pr21964-1a.so"}
742 {"Build pr21964-1b.so"
744 {pr21964-1b.c} {} "pr21964-1b.so"}
745 {"Build pr21964-2a.so"
747 {pr21964-2a.c} {} "pr21964-2a.so"}
748 {"Build pr21964-2b.so"
750 {pr21964-2b.c} {} "pr21964-2b.so"}
751 {"Build pr21964-3a.so"
753 {pr21964-3a.c} {} "pr21964-3a.so"}
755 "-shared" "-fPIC -g -O2"
756 {pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"}
759 run_cc_link_tests $build_tests
761 run_ld_link_tests [list \
764 "-pie -e _start --no-dynamic-linker -z text" \
768 {{readelf -rW pr22269-1.rd}} \
774 set run_tests [list \
775 [list "Run normal with libfoo.so" \
776 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
777 {main.c} "normal" "normal.out" ] \
778 [list "Run protected with libfoo.so" \
779 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \
780 {main.c} "protected" "normal.out" ] \
781 [list "Run hidden with libfoo.so" \
782 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \
783 {main.c} "hidden" "hidden.out" ] \
784 [list "Run normal with versioned libfoo.so" \
785 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \
786 {main.c} "normalv" "normal.out" ] \
787 [list "Run warn with versioned libfoo.so" \
788 "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
789 {main.c} "warn" "warn.out" \
790 "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated$} ] \
791 [list "Run protected with versioned libfoo.so" \
792 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
793 {main.c} "protected" "normal.out" ] \
794 [list "Run hidden with versioned libfoo.so" \
795 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \
796 {main.c} "hiddenv" "hidden.out" ] \
797 [list "Run normal libbar.so with libfoo.so" \
798 "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \
799 {main.c} "normal" "normal.out" ] \
800 [list "Run protected libbar.so with libfoo.so" \
801 "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \
802 {main.c} "protected" "normal.out" ] \
803 [list "Run hidden libbar.so with libfoo.so" \
804 "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \
805 {main.c} "hidden" "hidden.out" ] \
806 [list "Run normal libbar.so with versioned libfoo.so" \
807 "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \
808 {main.c} "normal" "normal.out" ] \
809 [list "Run protected libbar.so with versioned libfoo.so" \
810 "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \
811 {main.c} "protected" "normal.out" ] \
812 [list "Run hidden libbar.so with versioned libfoo.so" \
813 "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
814 {main.c} "hidden" "hidden.out" ] \
815 [list "Run with libdl2a.so" \
816 "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
817 {dl2main.c} "dl2a" "dl2a.out" ] \
818 [list "Run with libdl2b.so" \
819 "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \
820 {dl2main.c} "dl2b" "dl2b.out" ] \
821 [list "Run with libdl2c.so" \
822 "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
823 {dl2main.c} "dl2c" "dl2b.out" ] \
824 [list "Run with libdl4a.so" \
825 "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
826 {dl4main.c} "dl4a" "dl4a.out" ] \
827 [list "Run with libdl4b.so" \
828 "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \
829 {dl4main.c} "dl4b" "dl4a.out" ] \
830 [list "Run with libdl4c.so" \
831 "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \
832 {dl4main.c} "dl4c" "dl4b.out" ] \
833 [list "Run with libdl4d.so" \
834 "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \
835 {dl4main.c} "dl4d" "dl4b.out" ] \
836 [list "Run with libdl4e.so" \
837 "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
838 {dl4main.c} "dl4e" "dl4a.out" ] \
839 [list "Run with libdl4f.so" \
840 "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
841 {dl4main.c} "dl4f" "dl4a.out" ] \
842 [list "Run with libdata1.so" \
843 "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
844 {dynbss1.c} "dynbss1" "pass.out" ] \
845 [list "Run with libdata2.so" \
846 "-Wl,--no-as-needed tmpdir/libdata2.so" "" \
847 {weakdef1.c} "weakdef1" "pass.out" ] \
848 [list "Run with libfunc1.so comm1.o" \
849 "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \
850 {dummy.c} "comm1" "pass.out" ] \
851 [list "Run with comm1.o libfunc1.so" \
852 "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \
853 {dummy.c} "comm1" "pass.out" ] \
854 [list "Run with pr11138-2.c libpr11138-1.so" \
855 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \
856 {dummy.c} "pr11138a" "pr11138.out" ] \
857 [list "Run with libpr11138-1.so pr11138-2.c" \
858 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \
859 {dummy.c} "pr11138b" "pr11138.out" ] \
860 [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \
861 "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" \
862 {dummy.c} "pr13250" "pass.out" ] \
863 [list "Run with pr14323-1.c pr14323-2.so" \
864 "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \
865 {pr14323-1.c} "pr14323" "pass.out" ] \
866 [list "Run with pr14862-1.c libpr14862.so" \
867 "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
868 {dummy.c} "pr14862" "pr14862.out" ] \
869 [list "Link with --add-needed" \
870 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
871 {dummy.c} "needed1a" "needed1.out" ] \
872 [list "Link with --copy-dt-needed-entries" \
873 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
874 {dummy.c} "needed1b" "needed1.out" ] \
875 [list "Run relmain" \
876 "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
877 {relmain.c} "relmain" "relmain.out" ] \
879 "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
880 {dummy.c} "pr2404" "pr2404.out" ] \
881 [list "Run pr2404n" \
882 "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
883 {dummy.c} "pr2404n" "pr2404.out" ] \
884 [list "Run pr18458" \
885 "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
886 {pr18458c.c} "pr18458" "pass.out" ] \
887 [list "Run pr21964-1" \
888 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \
889 {pr21964-1c.c} "pr21964-1" "pass.out" ] \
890 [list "Run pr21964-3" \
891 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \
892 {pr21964-3c.c} "pr21964-3" "pass.out" ] \
895 # NetBSD ELF systems do not currently support the .*_array sections.
896 run_ld_link_exec_tests $run_tests "*-*-netbsdelf*"
898 # These tests require dlopen support.
899 set dlopen_run_tests [list \
900 [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
901 "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
902 {dl1main.c} "dl1a" "dl1.out" ] \
903 [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
904 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
905 {dl1main.c} "dl1b" "dl1.out" ] \
906 [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
907 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
908 {dl6amain.c} "dl6a1" "dl6a.out" ] \
909 [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
910 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
911 {dl6amain.c} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \
912 [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
913 "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
914 {dl6amain.c} "dl6a3" "dl6b.out" ] \
915 [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
916 "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
917 {dl6amain.c} "dl6a4" "dl6a.out" ] \
918 [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
919 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
920 {dl6amain.c} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \
921 [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
922 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
923 {dl6amain.c} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \
924 [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
925 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
926 {dl6amain.c} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \
927 [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
928 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
929 {dl6bmain.c} "dl6b1" "dl6a.out" ] \
930 [list "Run dl6b2 with dlopen on libdl6b.so" \
931 "-Wl,--no-as-needed $extralibs" "" \
932 {dl6bmain.c} "dl6b2" "dl6b.out" ] \
933 [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
934 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
935 {dl6cmain.c} "dl6c1" "dl6b.out" ] \
936 [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
937 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
938 {dl6dmain.c} "dl6d1" "dl6b.out" ] \
939 [list "Run pr21964-2" \
940 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \
941 {pr21964-2c.c} "pr21964-2" "pass.out" ] \
942 [list "Run pr21964-5" \
943 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \
944 {pr21964-5.c} "pr21964-5" "pass.out" ] \
947 # Only run them when libdl is available.
948 if [check_libdl_available] {
949 # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
951 run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*"
954 # Check --no-add-needed and --no-copy-dt-needed-entries
955 set testname "--no-add-needed"
956 set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
957 if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
962 set testname "--no-copy-dt-needed-entries"
963 set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
964 if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
969 set testname "--no-add-needed -shared"
970 set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"]
971 if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
976 set testname "--no-copy-dt-needed-entries -shared"
977 set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"]
978 if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
984 # Check to see if the C++ compiler works
985 if { [which $CXX] == 0 } {
989 set build_cxx_tests {
990 {"Build libdl3a.so with --dynamic-list=dl3.list"
991 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
992 {dl3.cc} {} "libdl3a.so" "c++"}
993 {"Build libdl3b.so with -Bsymbolic"
994 "-shared -Wl,-Bsymbolic" "-fPIC"
995 {dl3.cc} {} "libdl3b.so" "c++"}
996 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
997 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
998 {dl3.cc} {} "libdl3c.so" "c++"}
999 {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
1000 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi"
1001 {del.cc new.cc} {} "libnew1a.so" "c++"}
1002 {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
1003 "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi"
1004 {del.cc new.cc} {} "libnew1b.so" "c++"}
1007 # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
1008 # {"Run with libdl3b.so"
1009 # "tmpdir/libdl3b.so" ""
1010 # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
1012 {"Run with libdl3a.so"
1013 "-Wl,--no-as-needed tmpdir/libdl3a.so" ""
1014 {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
1015 {"Run with libdl3c.so"
1016 "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
1017 {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
1018 {"Run with libnew1a.so"
1019 "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
1020 {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"}
1021 {"Run with libnew1b.so"
1022 "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
1023 {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"}
1026 run_cc_link_tests $build_cxx_tests
1027 run_ld_link_exec_tests $run_cxx_tests
1029 if { [istarget *-*-linux*]
1030 || [istarget *-*-nacl*]
1031 || [istarget *-*-gnu*] } {
1032 run_cc_link_tests [list \
1034 "Build libpr2404b.a with PIE" \
1042 "Build pr19579a.o" \
1049 "Build libpr19579.so" \
1057 "Build libpr19579now.so" \
1058 "-shared -Wl,-z,now" \
1065 "Build pr22393-2a.so" \
1066 "-shared -Wl,-z,separate-code" \
1069 {{readelf -lW pr22393-2a.rd} \
1070 {readelf -lW pr22393-2b.rd}} \
1074 "Build pr22393-2a-now.so" \
1075 "-shared -Wl,-z,separate-code,-z,now" \
1078 {{readelf -lW pr22393-2a.rd} \
1079 {readelf -lW pr22393-2b.rd}} \
1080 "pr22393-2a-now.so" \
1084 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
1087 {{readelf -lW pr22393-2a.rd} \
1088 {readelf -lW pr22393-2b.rd}} \
1092 "Build pr22393-2 (PIE)" \
1093 "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
1096 {{readelf -lW pr22393-2a.rd} \
1097 {readelf -lW pr22393-2b.rd}} \
1101 "Build pr22393-2 (static)" \
1102 "-static -Wl,-z,separate-code" \
1104 {pr22393-2a.c pr22393-2b.c} \
1105 {{readelf -lW pr22393-2a.rd} \
1106 {readelf -lW pr22393-2b.rd}} \
1107 "pr22393-2-static" \
1110 run_ld_link_exec_tests [list \
1112 "Run pr18458 with PIE" \
1113 "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \
1121 "Run pr2404 with PIE" \
1122 "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
1130 "Run pr2404 with PIE (-z now)" \
1131 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
1142 { pr18718.c check-ptr-eq.c } \
1148 "Run pr18718 (-z now)" \
1151 { pr18718.c check-ptr-eq.c } \
1157 "Run pr18718 with PIE (1)" \
1160 { pr18718.c check-ptr-eq.c } \
1163 "-O2 -fPIE -I../bfd" \
1166 "Run pr18718 with PIE (2)" \
1169 { pr18718.c check-ptr-eq.c } \
1172 "-O2 -fPIE -I../bfd" \
1175 "Run pr18718 with PIE (3)" \
1178 { pr18718.c check-ptr-eq.c } \
1181 "-O2 -fPIE -I../bfd" \
1184 "Run pr18718 with PIE (4)" \
1187 { pr18718.c check-ptr-eq.c } \
1190 "-O2 -fPIE -I../bfd" \
1193 "Run pr18718 with PIC (1)" \
1196 { pr18718.c check-ptr-eq.c } \
1199 "-O2 -fPIC -I../bfd" \
1202 "Run pr18718 with PIC (2)" \
1205 { pr18718.c check-ptr-eq.c } \
1208 "-O2 -fPIC -I../bfd" \
1211 "Run pr18718 with PIC (3)" \
1214 { pr18718.c check-ptr-eq.c } \
1217 "-O2 -fPIC -I../bfd" \
1220 "Run pr18718 with PIC (4)" \
1223 { pr18718.c check-ptr-eq.c } \
1226 "-O2 -fPIC -I../bfd" \
1230 "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
1238 "Run pr19579 (-z now)" \
1239 "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
1248 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
1256 "Run pr22393-2 (PIE)" \
1257 "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
1265 "Run pr22393-2 (static)" \
1266 "-static -Wl,-z,separate-code" \
1268 {pr22393-2a.c pr22393-2b.c} \
1269 "pr22393-2-static" \
1287 proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
1288 run_cc_link_tests [list \
1290 "Build libpr19719a.so" \
1291 "-shared -Wl,-soname,libpr19719.so" \
1298 "Build libpr19719b.so" \
1299 "-shared -Wl,-soname,libpr19719.so" \
1306 "Build libpr19719b.o" \
1315 send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n"
1316 exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so
1318 run_ld_link_exec_tests [list \
1320 "Run $exe fun defined" \
1321 "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
1323 { pr19719a.c pr19719c.c } \
1330 send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n"
1331 exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so
1333 foreach targ $xfails {
1338 unsupported "Run $exe fun undefined"
1342 set exec_output [run_host_cmd "tmpdir/$exe" ""]
1343 if {![string match "PASS" $exec_output]} {
1344 fail "Run $exe fun undefined"
1346 pass "Run $exe fun undefined"
1350 mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719"
1351 mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie"
1353 if { ([istarget "i?86-*-*"]
1354 || [istarget "x86_64-*-*"]) } {
1355 run_ld_link_tests [list \
1357 "Build libpr23162a.so" \
1368 "-pie --no-as-needed tmpdir/libpr23162a.so" \
1370 "-mrelax-relocations=yes" \
1372 {{readelf {--dyn-syms -rW} pr23162.rd}} \
1377 "Build libpr23162b.so" \
1378 "-shared --version-script=pr23162.map" \
1388 "-pie --no-as-needed tmpdir/libpr23162b.so" \
1390 "-mrelax-relocations=yes" \
1392 {{readelf {--dyn-syms -rW} pr23162.rd}} \
1397 "Build libpr23161a.so" \
1402 {{readelf {--dyn-syms -rW} pr23161a.rd}} \
1408 "-pie --no-as-needed tmpdir/libpr23161a.so" \
1410 "-mrelax-relocations=yes" \
1412 {{readelf {--dyn-syms -rW} pr23161b.rd}} \
1417 "Build libpr23161b.so" \
1418 "-shared --version-script=pr23161.map" \
1422 {{readelf {--dyn-syms -rW} pr23161a.rd}} \
1428 "-pie --no-as-needed tmpdir/libpr23161b.so" \
1430 "-mrelax-relocations=yes" \
1432 {{readelf {--dyn-syms -rW} pr23161b.rd}} \
1437 "Build libpr23161c.so" \
1442 {{readelf {--dyn-syms -rW} pr23161c.rd}} \
1448 "-pie --no-as-needed tmpdir/libpr23161c.so" \
1450 "-mrelax-relocations=yes" \
1452 {{readelf {--dyn-syms -rW} pr23161d.rd}} \