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 "tic6x-*-*"] {
43 append AFLAGS_PIC " -mpic -mpid=near"
45 if [istarget "sparc*-*-*"] {
46 append AFLAGS_PIC " -K PIC"
49 # This target requires a non-default emulation for successful shared
50 # library/executable builds.
52 if [istarget "tic6x-*-*"] {
53 append LFLAGS " -melf32_tic6x_le"
55 # HPUX targets use a different .comm syntax.
57 if [istarget "*-*-hpux*"] {
58 set hpux "--defsym HPUX=1"
60 # These targets do not default to linking with shared libraries.
61 if { [istarget "mips*vr4100*-*-elf*"] \
62 || [istarget "mips*vr4300*-*-elf*"] \
63 || [istarget "mips*vr5000*-*-elf*"] } {
64 append LFLAGS " -call_shared"
67 if [is_underscore_target] {
68 set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
71 run_ld_link_tests [list \
83 "$LFLAGS -shared --version-script pr22471.t" \
84 "tmpdir/pr22471a.so" \
92 "$LFLAGS -rpath-link ." \
93 "tmpdir/pr22471b.so" \
100 "Build pr22649-1.so" \
110 if { [check_gc_sections_available] } {
111 if [istarget mips*-*-*] {
112 set actions {{ld pr22649-2ab-mips.msg}}
114 set actions {{ld pr22649.msg}}
116 run_ld_link_tests [list \
118 "Build pr22649-2a.so" \
119 "$LFLAGS -shared -gc-sections -print-gc-sections" \
127 "Build pr22649-2b.so" \
128 "$LFLAGS -shared -gc-sections -print-gc-sections" \
129 "tmpdir/pr22649-1.so" \
136 if { [istarget mips*-*-*] && ![istarget *-*-elf*] } {
137 set actions {{ld pr22649-2cd-mips.msg}}
141 run_ld_link_tests [list \
143 "Build pr22649-2c.so" \
144 "$LFLAGS -shared -gc-sections -print-gc-sections" \
152 "Build pr22649-2d.so" \
153 "$LFLAGS -shared -gc-sections -print-gc-sections" \
154 "tmpdir/pr22649-1.so" \
163 run_ld_link_tests [list \
165 "DT_TEXTREL in shared lib" \
166 "$LFLAGS -shared --warn-shared-textrel" \
171 {readelf {-d --wide} textrel.rd}} \
176 run_ld_link_tests [list \
178 "DT_TEXTREL map file warning" \
179 "$LFLAGS -shared -M" \
188 # PR ld/20828 check for correct dynamic symbol table entries where:
189 # - symbols have been defined with a linker script,
190 # - the same symbols have been seen in shared library used in the link,
191 # - the shared library symbols have been swept in section garbage collection.
192 # Verify that the symbols are global rather than local and that a version
193 # script adjusts them accordingly.
194 # Also verify that a version definition supplied by an object rather than
195 # a version script and forcibly exported is unaffected by section GC.
196 if { [check_gc_sections_available] } {
197 run_ld_link_tests [list \
199 "PR ld/20828 dynamic symbols with section GC\
200 (auxiliary shared library)" \
201 "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \
203 {{readelf --dyn-syms pr20828-a.sd} \
204 {readelf --dyn-syms pr20828-b.sd}} \
207 "PR ld/20828 dynamic symbols with section GC (plain)" \
208 "$LFLAGS -shared --gc-sections -T pr20828.ld" \
209 "tmpdir/libpr20828.so" "$AFLAGS_PIC" \
211 {{readelf --dyn-syms pr20828-a.sd} \
212 {readelf --dyn-syms pr20828-b.sd}} \
215 "PR ld/20828 dynamic symbols with section GC (version script)" \
216 "$LFLAGS -shared --gc-sections -T pr20828.ld\
217 --version-script=pr20828.ver" \
218 "tmpdir/libpr20828.so" \
221 {{readelf --dyn-syms pr20828-b.sd} \
222 {readelf --dyn-syms pr20828-c.sd}} \
225 "PR ld/20828 dynamic symbols with section GC\
226 (versioned shared library)" \
227 "$LFLAGS -shared --gc-sections -T pr20828.ld\
228 --version-script=pr20828-v.ver" \
231 {{readelf --dyn-syms pr20828-c.sd} \
232 {readelf --dyn-syms pr20828-d.sd} \
233 {readelf --dyn-syms pr20828-e.sd}} \
236 "PR ld/20828 dynamic symbols with section GC (versioned)" \
237 "$LFLAGS -shared --gc-sections -T pr20828.ld\
238 --version-script=pr20828-v.ver" \
239 "tmpdir/libpr20828-v.so" \
242 {{readelf --dyn-syms pr20828-c.sd} \
243 {readelf --dyn-syms pr20828-d.sd} \
244 {readelf --dyn-syms pr20828-e.sd}} \
247 "PR ld/20828 forcibly exported symbol version without section GC" \
248 "$LFLAGS --no-dynamic-linker -e foo -E -T pr20828-v.ld" "" "" \
250 {{objdump -p pr20828-v.od}} \
253 "PR ld/20828 forcibly exported symbol version with section GC" \
254 "$LFLAGS --no-dynamic-linker -e foo --gc-sections -E -T pr20828-v.ld" "" "" \
256 {{objdump -p pr20828-v.od}} \
259 # PR ld/21233 check for correct dynamic symbol table entries where:
260 # - a symbol has been defined in a shared library used in the link,
261 # - the symbol has been referenced from a section swept in garbage collection,
262 # - the symbol has also been forced to be entered in the output file as an
263 # undefined symbol, either with a command-line option or a linker script
265 # Verify that the undefined symbol is global rather than local.
266 if { [check_gc_sections_available] } {
267 run_ld_link_tests [list \
269 "PR ld/21233 dynamic symbols with section GC\
270 (auxiliary shared library)" \
271 "$LFLAGS -shared -T pr21233.ld" "" "$AFLAGS_PIC" \
273 {{readelf --dyn-syms pr21233-l.sd}} \
276 run_ld_link_tests [list \
278 "PR ld/21233 dynamic symbols with section GC (--undefined)" \
279 "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld" \
280 "tmpdir/libpr21233.so" "" \
282 {{readelf --dyn-syms pr21233.sd}} \
285 run_ld_link_tests [list \
287 "PR ld/21233 dynamic symbols with section GC (--require-defined)" \
288 "$LFLAGS --gc-sections -e foo --require-defined=bar\
290 "tmpdir/libpr21233.so" "" \
292 {{readelf --dyn-syms pr21233.sd}} \
295 run_ld_link_tests [list \
297 "PR ld/21233 dynamic symbols with section GC (EXTERN)" \
298 "$LFLAGS --gc-sections -e foo -T pr21233-e.ld" \
299 "tmpdir/libpr21233.so" "" \
301 {{readelf --dyn-syms pr21233.sd}} \
305 if { [check_gc_sections_available] } {
306 run_ld_link_tests [list \
309 "$LFLAGS -shared --version-script pr22150.ver" \
318 "$LFLAGS -e _start --gc-sections" \
319 "tmpdir/pr22150.so" \
322 {{readelf -V pr22150.vd}} \
328 set ASFLAGS $old_ASFLAGS
331 {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" }
334 {"Build shared library for pr14170"
335 "-shared" "" "" "pr14170b.s" {} "pr14170.so" }
338 # bfin does not currently support copy relocs.
339 run_ld_link_tests [list \
340 [list "PR ld/14170" \
341 "$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \
343 {pr14170c.s} { } "pr14170" ] \
346 # Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests
347 # Not will tic6x with PIC/PID warning, or hppa64 with dot-symbols
349 {"PR ld/21703 shared"
350 "-shared --allow-multiple-definition --version-script pr21703.ver tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "" \
351 {pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} "pr21703.so" }
352 } "d30v-*-*" "dlx-*-*" "pj-*-*" "tic6x-*-*" "hppa64-*-*"
354 # This target requires extra GAS options when building non-PIC code
355 # for linking with shared libraries.
357 if [istarget "mips*-*-*"] {
358 append AFLAGS_NONPIC " -call_nonpic"
361 # Run a test to check linking a shared library with a broken linker
362 # script that accidentally marks dynamic sections as notes. The
363 # resulting executable is not expected to work, but the linker
364 # should not seg-fault whilst creating the binary.
365 # Note: setup_xfail before run_ld_link_tests xfails only the first test.
366 setup_xfail "tic6x-*-*"
368 {"Build shared library for broken linker scrip test"
369 "-shared --hash-style=sysv" "" "" "note-3.s" {} "note-3.so" }
370 {"Link using broken linker script"
371 "$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" ""
372 { { ld "note-3.l" } }
376 setup_xfail "tic6x-*-*"
380 {pr17068d.s} {} "pr17068.so"}
383 {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"}
386 {pr17068b.s pr17068e.s} {} "pr17068b.a"}
389 # bfin does not currently support copy relocs.
391 {"pr17068 link --as-needed lib in group"
392 "$LFLAGS --as-needed --no-dynamic-linker"
393 "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\
395 {start.s pr17068.s} {} "pr17068"}
398 # xfail on tic6x due to non-PIC/non-PID warnings
399 # Fails on MIPS because ABI trickery means that a NULL reloc is emitted.
400 # Fails on bfin because relocations are not created.
402 {"-Bsymbolic-functions"
403 "-shared -Bsymbolic-functions" "" ""
404 {symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}}
406 } "tic6x-*-*" "mips*-*-*" "bfin-*-*"
408 # xfail on tic6x due to non-PIC/non-PID warnings
412 {pr20995b.s} {} "pr20995.so"}
415 # xfail on arm*-*-eabi*. The list can be enlarged to those targets that
416 # don't support GNU_RELRO. For more details, please see discussions at:
417 # https://sourceware.org/ml/binutils/2017-01/msg00441.html
419 {"Build pr20995-2.so"
420 "-shared -z relro" "" ""
421 {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"}
422 } "tic6x-*-*" "arm*-*-eabi*" "hppa*64*-*-hpux*"
424 # These targets don't copy dynamic variables into .bss.
425 setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
426 # or don't have .data.rel.ro
427 setup_xfail "hppa*64*-*-hpux*"
428 run_ld_link_tests [list \
431 "$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
432 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]]
434 # xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO.
435 # Please see the link above for details.
436 setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*"
437 setup_xfail "hppa*64*-*-hpux*"
438 run_ld_link_tests [list \
441 "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
442 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]]
444 setup_xfail "tic6x-*-*"
446 {"Build pr22374 shared library"
447 "-shared" "" "" "pr22374b.s" {} "pr22374.so" }
449 if { ![istarget "alpha-*-*"]
450 && ![istarget "frv-*-*"]
451 && ![istarget "hppa*-*-*"]
452 && ![istarget "i?86-*-*"]
453 && ![istarget "ia64-*-*"]
454 && ![istarget "microblaze-*-*"]
455 && ![istarget "powerpc*-*-*"]
456 && ![istarget "x86_64-*-*"]
457 && ![istarget "xtensa-*-*"] } {
458 # The next test checks that copy relocs are not used unnecessarily,
459 # but that is just an optimization so don't complain loudly.
463 {"pr22374 function pointer initialization"
464 "" "tmpdir/pr22374.so" "" "pr22374a.s"
465 { {readelf {--wide -r --dyn-syms} "pr22374-1.r"}
466 {readelf {--wide -r} "pr22374-2.r"} }
470 if { [istarget *-*-linux*]
471 || [istarget *-*-nacl*]
472 || [istarget *-*-gnu*] } {
474 {"Weak symbols in dynamic objects 1 (support)"
475 "-shared" "" "" {weak-dyn-1a.s}
478 {"Weak symbols in dynamic objects 1 (main test)"
479 "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s}
480 {{readelf {--relocs --wide} weak-dyn-1.rd}}
485 # Check to see if the C compiler works
486 if { [which $CC] == 0 } {
490 # Add -ldl to extralibs if needed
492 if { ![istarget *-*-freebsd*]} {
499 {foo.c} {} "libfoo.so"}
500 {"Build versioned libfoo.so"
501 "-shared -Wl,--version-script=foo.map" "-fPIC"
502 {foo.c} {} "libfoov.so"}
505 {begin.c end.c} {} "libbar.so"}
506 {"Build warn libbar.so"
509 {{readelf {-S --wide} libbarw.rd}
510 {warning "^.*beginwarn.c:7: warning: function foo is deprecated$"}}
512 {"Build hidden libbar.so"
514 {begin.c endhidden.c} {} "libbarh.so"}
515 {"Build protected libbar.so"
517 {begin.c endprotected.c} {} "libbarp.so"}
518 {"Build libbar.so with libfoo.so"
519 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
520 {end.c} {} "libbarfoo.so"}
521 {"Build libar.so with versioned libfoo.so"
522 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
523 {end.c} {} "libbarfoov.so"}
524 {"Build hidden libbar.so with libfoo.so"
525 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
526 {endhidden.c} {} "libbarhfoo.so"}
527 {"Build hidden libar.so with versioned libfoo.so"
528 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
529 {endhidden.c} {} "libbarhfoov.so"}
530 {"Build protected libbar.so with libfoo.so"
531 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
532 {endprotected.c} {} "libbarpfoo.so"}
533 {"Build protected libbar.so with versioned libfoo.so"
534 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
535 {endprotected.c} {} "libbarpfoov.so"}
538 {dl1.c} {} "libdl1.so"}
539 {"Build libdl2a.so with --dynamic-list=dl2.list"
540 "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
541 {dl2.c dl2xxx.c} {} "libdl2a.so"}
542 {"Build libdl2a.so with --dynamic-list=dl2a.list"
543 "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC"
544 {dl2.c dl2xxx.c} {} "libdl2a.so"}
545 {"Build libdl2a.so with --dynamic-list-data"
546 "-shared -Wl,--dynamic-list-data" "-fPIC"
547 {dl2.c dl2xxx.c} {} "libdl2a.so"}
548 {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
549 "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
550 {dl2.c dl2xxx.c} {} "libdl2b.so"}
551 {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
552 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
553 {dl2.c dl2xxx.c} {} "libdl2c.so"}
554 {"Build libdl4a.so with --dynamic-list=dl4.list"
555 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
556 {dl4.c dl4xxx.c} {} "libdl4a.so"}
557 {"Build libdl4b.so with --dynamic-list-data"
558 "-shared -Wl,--dynamic-list-data" "-fPIC"
559 {dl4.c dl4xxx.c} {} "libdl4b.so"}
560 {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list"
561 "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
562 {dl4.c dl4xxx.c} {} "libdl4c.so"}
563 {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list"
564 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
565 {dl4.c dl4xxx.c} {} "libdl4d.so"}
566 {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new"
567 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
568 {dl4.c dl4xxx.c} {} "libdl4e.so"}
569 {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions"
570 "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC"
571 {dl4.c dl4xxx.c} {} "libdl4f.so"}
574 {dl6.c} {} "libdl6a.so"}
575 {"Build libdl6b.so with -Bsymbolic --dynamic-list-data"
576 "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
577 {dl6.c} {} "libdl6b.so"}
578 {"Build libdl6c.so with -Bsymbolic"
579 "-shared -Wl,-Bsymbolic" "-fPIC"
580 {dl6.c} {} "libdl6c.so"}
581 {"Build libdl6d.so with --dynamic-list-data -Bsymbolic"
582 "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC"
583 {dl6.c} {} "libdl6d.so"}
586 {data1.c} {} "libdata1.so"}
589 {data2.c} {} "libdata2.so"}
592 {comm1.c} {} "libcomm1.o"}
595 {func1.c} {} "libfunc1.so"}
596 {"Build libpr9676-1.a"
598 {pr9676-1.c} {} "libpr9676-1.a"}
599 {"Build libpr9676-2.a"
601 {pr9676-2.c} {} "libpr9676-2.a"}
602 {"Build libpr9676-3.so"
604 {pr9676-3.c} {} "libpr9676-3.so"}
605 {"Build libpr9676-4.so"
607 {pr9676-4.c} {} "libpr9676-4.so"}
608 {"Build libpr9676-4a.so"
609 "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group"
611 {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"}
612 {"Build libpr9679.so"
613 "-shared" "-fPIC -O0"
614 {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"}
615 {"Build libpr11138-1.so"
616 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
617 {pr11138-1.c} {} "libpr11138-1.so"}
618 {"Build libpr11138-2.o"
620 {pr11138-2.c} {} "libpr11138-2.o"}
621 {"Build pr13250-1.so"
623 {pr13250-1.c} {} "libpr13250-1.so"}
624 {"Build pr13250-2.so with libpr13250-1.so"
625 "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC"
626 {pr13250-2.c} {} "libpr13250-2.so"}
627 {"Build libpr13250-3.o"
629 {pr13250-3.c} {} "libpr13250-3.o"}
630 {"Build libpr14323-2.so"
632 {pr14323-2.c} {} "libpr14323-2.so"}
635 {pr14862-1.c} {} "libpr14862-1.o"}
636 {"Build libpr14862.so"
637 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
638 {pr14862-2.c} {} "libpr14862.so"}
639 {"Build libneeded1b.so"
641 {needed1b.c} {} "libneeded1b.so"}
642 {"Build libneeded1a.so"
643 "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC"
644 {needed1a.c} {} "libneeded1a.so"}
645 {"Build libneeded1c.o"
647 {needed1c.c} {} "libneeded1c.o"}
648 {"Build libneeded1pic.o"
649 "-r -nostdlib" "-fPIC"
650 {needed1c.c} {} "libneeded1pic.o"}
651 {"Build needed1a.so with --add-needed"
652 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
653 {dummy.c} {} "needed1a.so"}
654 {"Build needed1b.so with --copy-dt-needed-entries"
655 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
656 {dummy.c} {} "needed1b.so"}
657 {"Build needed1a.so with --no-add-needed"
658 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" ""
659 {dummy.c} {} "needed1c.so"}
660 {"Build needed1b.so with --no-copy-dt-needed-entries"
661 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
662 {dummy.c} {} "needed1d.so"}
665 {rel.c} {} "librel.so"}
666 {"Build libneeded2a.so"
668 {needed2a.c} {} "libneeded2a.so"}
669 {"Build libneeded2b.so"
670 "-shared -Wl,--version-script,needed2.ver" "-fPIC"
671 {needed2b.c} {} "libneeded2b.so"}
672 {"Build libneeded2c.o"
674 {needed2c.c} {} "libneeded2c.o"}
676 "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" ""
677 {dummy.c} {} "needed2"}
678 {"Build libneeded3a.so"
679 "-shared -Wl,--no-add-needed" "-fPIC"
680 {needed1a.c} {} "libneeded3a.so"}
681 {"Build libneeded3b.so"
682 "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC"
683 {dummy.c} {} "libneeded3b.so"}
686 {needed3.c} {} "libneeded3.so"}
688 "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
689 {dummy.c} {} "needed3"}
690 {"Build libpr2404a.so"
692 {pr2404a.c} {} "libpr2404a.so"}
693 {"Build libpr2404n.so"
694 "-shared -Wl,-z,now" "-fPIC"
695 {pr2404a.c} {} "libpr2404n.so"}
696 {"Build libpr2404b.a"
698 {pr2404b.c} {} "libpr2404b.a"}
700 "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
701 {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
703 "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
704 {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"}
705 {"Build libpr16496a.so"
706 "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
707 {pr16496a.c} {} "libpr16496a.so"}
708 {"Build libpr16496b.a"
710 {pr16496b.c} {} "libpr16496b.a"}
711 {"Build libpr16496b.so"
712 "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
713 {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
714 {"Build libpr16452a.so"
715 "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC"
716 {pr16452a.c} {} "libpr16452a.so"}
717 {"Build libpr16452b.so"
718 "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC"
719 {dummy.c} {} "libpr16452b.so"}
721 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
722 {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"}
724 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
725 {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"}
726 {"Build libpr18458a.so"
727 "-shared -Wl,-z,now" "-fPIC"
728 {pr18458a.c} {} "libpr18458a.so"}
729 {"Build libpr18458b.so"
730 "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC"
731 {pr18458b.c} {} "libpr18458b.so"}
734 {pr19073.s} {} "pr19073a.o"}
735 {"Build libpr19073.so"
736 "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC"
737 {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"}
738 {"Build pr21964-1a.so"
740 {pr21964-1a.c} {} "pr21964-1a.so"}
741 {"Build pr21964-1b.so"
743 {pr21964-1b.c} {} "pr21964-1b.so"}
744 {"Build pr21964-2a.so"
746 {pr21964-2a.c} {} "pr21964-2a.so"}
747 {"Build pr21964-2b.so"
749 {pr21964-2b.c} {} "pr21964-2b.so"}
750 {"Build pr21964-3a.so"
752 {pr21964-3a.c} {} "pr21964-3a.so"}
754 "-shared" "-fPIC -g -O2"
755 {pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"}
758 run_cc_link_tests $build_tests
760 run_ld_link_tests [list \
763 "-pie -e _start --no-dynamic-linker -z text" \
767 {{readelf -rW pr22269-1.rd}} \
773 set run_tests [list \
774 [list "Run normal with libfoo.so" \
775 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
776 {main.c} "normal" "normal.out" ] \
777 [list "Run protected with libfoo.so" \
778 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \
779 {main.c} "protected" "normal.out" ] \
780 [list "Run hidden with libfoo.so" \
781 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \
782 {main.c} "hidden" "hidden.out" ] \
783 [list "Run normal with versioned libfoo.so" \
784 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \
785 {main.c} "normalv" "normal.out" ] \
786 [list "Run warn with versioned libfoo.so" \
787 "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
788 {main.c} "warn" "warn.out" \
789 "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated$} ] \
790 [list "Run protected with versioned libfoo.so" \
791 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
792 {main.c} "protected" "normal.out" ] \
793 [list "Run hidden with versioned libfoo.so" \
794 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \
795 {main.c} "hiddenv" "hidden.out" ] \
796 [list "Run normal libbar.so with libfoo.so" \
797 "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \
798 {main.c} "normal" "normal.out" ] \
799 [list "Run protected libbar.so with libfoo.so" \
800 "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \
801 {main.c} "protected" "normal.out" ] \
802 [list "Run hidden libbar.so with libfoo.so" \
803 "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \
804 {main.c} "hidden" "hidden.out" ] \
805 [list "Run normal libbar.so with versioned libfoo.so" \
806 "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \
807 {main.c} "normal" "normal.out" ] \
808 [list "Run protected libbar.so with versioned libfoo.so" \
809 "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \
810 {main.c} "protected" "normal.out" ] \
811 [list "Run hidden libbar.so with versioned libfoo.so" \
812 "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
813 {main.c} "hidden" "hidden.out" ] \
814 [list "Run with libdl2a.so" \
815 "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
816 {dl2main.c} "dl2a" "dl2a.out" ] \
817 [list "Run with libdl2b.so" \
818 "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \
819 {dl2main.c} "dl2b" "dl2b.out" ] \
820 [list "Run with libdl2c.so" \
821 "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
822 {dl2main.c} "dl2c" "dl2b.out" ] \
823 [list "Run with libdl4a.so" \
824 "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
825 {dl4main.c} "dl4a" "dl4a.out" ] \
826 [list "Run with libdl4b.so" \
827 "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \
828 {dl4main.c} "dl4b" "dl4a.out" ] \
829 [list "Run with libdl4c.so" \
830 "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \
831 {dl4main.c} "dl4c" "dl4b.out" ] \
832 [list "Run with libdl4d.so" \
833 "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \
834 {dl4main.c} "dl4d" "dl4b.out" ] \
835 [list "Run with libdl4e.so" \
836 "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
837 {dl4main.c} "dl4e" "dl4a.out" ] \
838 [list "Run with libdl4f.so" \
839 "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
840 {dl4main.c} "dl4f" "dl4a.out" ] \
841 [list "Run with libdata1.so" \
842 "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
843 {dynbss1.c} "dynbss1" "pass.out" ] \
844 [list "Run with libdata2.so" \
845 "-Wl,--no-as-needed tmpdir/libdata2.so" "" \
846 {weakdef1.c} "weakdef1" "pass.out" ] \
847 [list "Run with libfunc1.so comm1.o" \
848 "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \
849 {dummy.c} "comm1" "pass.out" ] \
850 [list "Run with comm1.o libfunc1.so" \
851 "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \
852 {dummy.c} "comm1" "pass.out" ] \
853 [list "Run with pr11138-2.c libpr11138-1.so" \
854 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \
855 {dummy.c} "pr11138a" "pr11138.out" ] \
856 [list "Run with libpr11138-1.so pr11138-2.c" \
857 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \
858 {dummy.c} "pr11138b" "pr11138.out" ] \
859 [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \
860 "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" \
861 {dummy.c} "pr13250" "pass.out" ] \
862 [list "Run with pr14323-1.c pr14323-2.so" \
863 "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \
864 {pr14323-1.c} "pr14323" "pass.out" ] \
865 [list "Run with pr14862-1.c libpr14862.so" \
866 "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
867 {dummy.c} "pr14862" "pr14862.out" ] \
868 [list "Link with --add-needed" \
869 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
870 {dummy.c} "needed1a" "needed1.out" ] \
871 [list "Link with --copy-dt-needed-entries" \
872 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
873 {dummy.c} "needed1b" "needed1.out" ] \
874 [list "Run relmain" \
875 "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
876 {relmain.c} "relmain" "relmain.out" ] \
878 "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
879 {dummy.c} "pr2404" "pr2404.out" ] \
880 [list "Run pr2404n" \
881 "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
882 {dummy.c} "pr2404n" "pr2404.out" ] \
883 [list "Run pr18458" \
884 "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
885 {pr18458c.c} "pr18458" "pass.out" ] \
886 [list "Run pr21964-1" \
887 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \
888 {pr21964-1c.c} "pr21964-1" "pass.out" ] \
889 [list "Run pr21964-3" \
890 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \
891 {pr21964-3c.c} "pr21964-3" "pass.out" ] \
894 # NetBSD ELF systems do not currently support the .*_array sections.
895 run_ld_link_exec_tests $run_tests "*-*-netbsdelf*"
897 # These tests require dlopen support.
898 set dlopen_run_tests [list \
899 [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
900 "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
901 {dl1main.c} "dl1a" "dl1.out" ] \
902 [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
903 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
904 {dl1main.c} "dl1b" "dl1.out" ] \
905 [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
906 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
907 {dl6amain.c} "dl6a1" "dl6a.out" ] \
908 [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
909 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
910 {dl6amain.c} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \
911 [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
912 "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
913 {dl6amain.c} "dl6a3" "dl6b.out" ] \
914 [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
915 "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
916 {dl6amain.c} "dl6a4" "dl6a.out" ] \
917 [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
918 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
919 {dl6amain.c} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \
920 [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
921 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
922 {dl6amain.c} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \
923 [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
924 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
925 {dl6amain.c} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \
926 [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
927 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
928 {dl6bmain.c} "dl6b1" "dl6a.out" ] \
929 [list "Run dl6b2 with dlopen on libdl6b.so" \
930 "-Wl,--no-as-needed $extralibs" "" \
931 {dl6bmain.c} "dl6b2" "dl6b.out" ] \
932 [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
933 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
934 {dl6cmain.c} "dl6c1" "dl6b.out" ] \
935 [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
936 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
937 {dl6dmain.c} "dl6d1" "dl6b.out" ] \
938 [list "Run pr21964-2" \
939 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \
940 {pr21964-2c.c} "pr21964-2" "pass.out" ] \
941 [list "Run pr21964-5" \
942 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \
943 {pr21964-5.c} "pr21964-5" "pass.out" ] \
946 # Only run them when libdl is available.
947 if [check_libdl_available] {
948 # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
950 run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*"
953 # Check --no-add-needed and --no-copy-dt-needed-entries
954 set testname "--no-add-needed"
955 set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
956 if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
961 set testname "--no-copy-dt-needed-entries"
962 set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
963 if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
968 set testname "--no-add-needed -shared"
969 set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"]
970 if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
975 set testname "--no-copy-dt-needed-entries -shared"
976 set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"]
977 if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
983 # Check to see if the C++ compiler works
984 if { [which $CXX] == 0 } {
988 set build_cxx_tests {
989 {"Build libdl3a.so with --dynamic-list=dl3.list"
990 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
991 {dl3.cc} {} "libdl3a.so" "c++"}
992 {"Build libdl3b.so with -Bsymbolic"
993 "-shared -Wl,-Bsymbolic" "-fPIC"
994 {dl3.cc} {} "libdl3b.so" "c++"}
995 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
996 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
997 {dl3.cc} {} "libdl3c.so" "c++"}
998 {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
999 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi"
1000 {del.cc new.cc} {} "libnew1a.so" "c++"}
1001 {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
1002 "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi"
1003 {del.cc new.cc} {} "libnew1b.so" "c++"}
1006 # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
1007 # {"Run with libdl3b.so"
1008 # "tmpdir/libdl3b.so" ""
1009 # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
1011 {"Run with libdl3a.so"
1012 "-Wl,--no-as-needed tmpdir/libdl3a.so" ""
1013 {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
1014 {"Run with libdl3c.so"
1015 "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
1016 {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
1017 {"Run with libnew1a.so"
1018 "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
1019 {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"}
1020 {"Run with libnew1b.so"
1021 "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
1022 {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"}
1025 run_cc_link_tests $build_cxx_tests
1026 run_ld_link_exec_tests $run_cxx_tests
1028 if { [istarget *-*-linux*]
1029 || [istarget *-*-nacl*]
1030 || [istarget *-*-gnu*] } {
1031 run_cc_link_tests [list \
1033 "Build libpr2404b.a with PIE" \
1041 "Build pr19579a.o" \
1048 "Build libpr19579.so" \
1056 "Build libpr19579now.so" \
1057 "-shared -Wl,-z,now" \
1064 "Build pr22393-2a.so" \
1065 "-shared -Wl,-z,separate-code" \
1068 {{readelf -lW pr22393-2a.rd} \
1069 {readelf -lW pr22393-2b.rd}} \
1073 "Build pr22393-2a-now.so" \
1074 "-shared -Wl,-z,separate-code,-z,now" \
1077 {{readelf -lW pr22393-2a.rd} \
1078 {readelf -lW pr22393-2b.rd}} \
1079 "pr22393-2a-now.so" \
1083 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
1086 {{readelf -lW pr22393-2a.rd} \
1087 {readelf -lW pr22393-2b.rd}} \
1091 "Build pr22393-2 (PIE)" \
1092 "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
1095 {{readelf -lW pr22393-2a.rd} \
1096 {readelf -lW pr22393-2b.rd}} \
1100 "Build pr22393-2 (static)" \
1101 "-static -Wl,-z,separate-code" \
1103 {pr22393-2a.c pr22393-2b.c} \
1104 {{readelf -lW pr22393-2a.rd} \
1105 {readelf -lW pr22393-2b.rd}} \
1106 "pr22393-2-static" \
1109 run_ld_link_exec_tests [list \
1111 "Run pr18458 with PIE" \
1112 "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \
1120 "Run pr2404 with PIE" \
1121 "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
1129 "Run pr2404 with PIE (-z now)" \
1130 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
1141 { pr18718.c check-ptr-eq.c } \
1147 "Run pr18718 (-z now)" \
1150 { pr18718.c check-ptr-eq.c } \
1156 "Run pr18718 with PIE (1)" \
1159 { pr18718.c check-ptr-eq.c } \
1162 "-O2 -fPIE -I../bfd" \
1165 "Run pr18718 with PIE (2)" \
1168 { pr18718.c check-ptr-eq.c } \
1171 "-O2 -fPIE -I../bfd" \
1174 "Run pr18718 with PIE (3)" \
1177 { pr18718.c check-ptr-eq.c } \
1180 "-O2 -fPIE -I../bfd" \
1183 "Run pr18718 with PIE (4)" \
1186 { pr18718.c check-ptr-eq.c } \
1189 "-O2 -fPIE -I../bfd" \
1192 "Run pr18718 with PIC (1)" \
1195 { pr18718.c check-ptr-eq.c } \
1198 "-O2 -fPIC -I../bfd" \
1201 "Run pr18718 with PIC (2)" \
1204 { pr18718.c check-ptr-eq.c } \
1207 "-O2 -fPIC -I../bfd" \
1210 "Run pr18718 with PIC (3)" \
1213 { pr18718.c check-ptr-eq.c } \
1216 "-O2 -fPIC -I../bfd" \
1219 "Run pr18718 with PIC (4)" \
1222 { pr18718.c check-ptr-eq.c } \
1225 "-O2 -fPIC -I../bfd" \
1229 "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
1237 "Run pr19579 (-z now)" \
1238 "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
1247 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
1255 "Run pr22393-2 (PIE)" \
1256 "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
1264 "Run pr22393-2 (static)" \
1265 "-static -Wl,-z,separate-code" \
1267 {pr22393-2a.c pr22393-2b.c} \
1268 "pr22393-2-static" \
1286 proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
1287 run_cc_link_tests [list \
1289 "Build libpr19719a.so" \
1290 "-shared -Wl,-soname,libpr19719.so" \
1297 "Build libpr19719b.so" \
1298 "-shared -Wl,-soname,libpr19719.so" \
1305 "Build libpr19719b.o" \
1314 send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n"
1315 exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so
1317 run_ld_link_exec_tests [list \
1319 "Run $exe fun defined" \
1320 "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
1322 { pr19719a.c pr19719c.c } \
1329 send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n"
1330 exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so
1332 foreach targ $xfails {
1337 unsupported "Run $exe fun undefined"
1341 set exec_output [run_host_cmd "tmpdir/$exe" ""]
1342 if {![string match "PASS" $exec_output]} {
1343 fail "Run $exe fun undefined"
1345 pass "Run $exe fun undefined"
1349 mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719"
1350 mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie"