1 # Expect script
for various ELF tests.
2 # Copyright
(C
) 2006-2024 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 set old_ASFLAGS $ASFLAGS
36 # This target requires extra GAS options when building code
for shared
39 if [istarget
"nds32*-*"] {
40 append AFLAGS_PIC
" -mpic"
42 if [istarget
"tic6x-*-*"] {
43 append AFLAGS_PIC
" -mpic -mpid=near"
45 if [istarget
"sparc*-*-*"] {
46 append AFLAGS_PIC
" -K PIC -Av9"
49 # GAS options to disable
program property note.
51 if { [istarget
"i?86-*-*"] || [istarget "x86_64-*-*"] } {
52 append AFLAGS_NOTE
"-mx86-used-note=no"
55 # This target requires a non
-default emulation
for successful shared
56 # library
/executable builds.
58 if [istarget
"tic6x-*-*"] {
59 append LFLAGS
" -melf32_tic6x_le"
61 # HPUX targets use a different .comm syntax.
63 if [istarget
"*-*-hpux*"] {
64 set hpux
"--defsym HPUX=1"
66 # These targets
do not default to linking with shared libraries.
67 if { [istarget
"mips*vr4100*-*-elf*"] \
68 ||
[istarget
"mips*vr4300*-*-elf*"] \
69 ||
[istarget
"mips*vr5000*-*-elf*"] } {
70 append LFLAGS
" -call_shared"
73 if [is_underscore_target
] {
74 append ASFLAGS
" --defsym UNDERSCORE=1"
77 run_ld_link_tests
[list \
89 "$LFLAGS -shared --version-script pr22471.t" \
90 "tmpdir/pr22471a.so" \
97 "Build pr22649-1.so" \
107 run_ld_link_tests
[list \
110 "$LFLAGS -rpath-link . -rpath-link tmpdir" \
111 "tmpdir/pr22471b.so" \
117 ] bfin
-*-* frv
-*-* lm32
-*-*
119 if { [check_gc_sections_available
] } {
120 if [istarget mips
*-*-*] {
121 set actions
{{ld pr22649
-2ab
-mips.msg
}}
123 set actions
{{ld pr22649.msg
}}
125 run_ld_link_tests
[list \
127 "Build pr22649-2a.so" \
128 "$LFLAGS -shared -gc-sections -print-gc-sections" \
136 "Build pr22649-2b.so" \
137 "$LFLAGS -shared -gc-sections -print-gc-sections" \
138 "tmpdir/pr22649-1.so" \
145 if { [istarget mips
*-*-*] && ![istarget
*-*-elf
*] } {
146 set actions
{{ld pr22649
-2cd
-mips.msg
}}
150 run_ld_link_tests
[list \
152 "Build pr22649-2c.so" \
153 "$LFLAGS -shared -gc-sections -print-gc-sections" \
161 "Build pr22649-2d.so" \
162 "$LFLAGS -shared -gc-sections -print-gc-sections" \
163 "tmpdir/pr22649-1.so" \
172 run_ld_link_tests
[list \
174 "DT_TEXTREL in shared lib" \
175 "$LFLAGS -shared --warn-shared-textrel" \
180 {readelf
{-d
--wide
} textrel.rd
}} \
183 ] bfin
-*-* frv
-*-* lm32
-*-* xtensa
-*-*
185 # The MIPS backend sets SHF_WRITE
, in `mips_elf_create_dynamic_relocation
',
186 # for any section that has a dynamic relocation attached and consequently
187 # this test is irrelevant for MIPS targets. We don't have a clean way to
188 # request UNSUPPORTED result
, which would be the most appropriate here
,
189 # so we just XFAIL the test instead.
190 run_ld_link_tests
[list \
192 "DT_TEXTREL map file warning" \
193 "$LFLAGS -shared -M" \
200 ] bfin
-*-* cris
*-*-* frv
-*-* lm32
-*-* mips
*-*-*
202 # PR
ld/20828 check
for correct dynamic symbol table entries where
:
203 #
- symbols have been defined with a linker script
,
204 #
- the same symbols have been seen in shared library used in the link
,
205 #
- the shared library symbols have been swept in section garbage collection.
206 # Verify that the symbols are global rather than local and that a version
207 # script adjusts them accordingly.
208 # Also verify that a version definition supplied by an object rather than
209 # a version script and forcibly exported is unaffected by section GC.
210 if { [check_gc_sections_available
] } {
211 run_ld_link_tests
[list \
213 "PR ld/20828 dynamic symbols with section GC\
214 (auxiliary shared library
)" \
215 "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \
217 {{readelf
--dyn
-syms pr20828
-a.sd
} \
218 {readelf
--dyn
-syms pr20828
-b.sd
}} \
221 "PR ld/20828 dynamic symbols with section GC (plain)" \
222 "$LFLAGS -shared --gc-sections -T pr20828.ld" \
223 "tmpdir/libpr20828.so" "$AFLAGS_PIC" \
225 {{readelf
--dyn
-syms pr20828
-a.sd
} \
226 {readelf
--dyn
-syms pr20828
-b.sd
}} \
229 "PR ld/20828 dynamic symbols with section GC (version script)" \
230 "$LFLAGS -shared --gc-sections -T pr20828.ld\
231 --version
-script
=pr20828.ver
" \
232 "tmpdir/libpr20828.so" \
235 {{readelf
--dyn
-syms pr20828
-b.sd
} \
236 {readelf
--dyn
-syms pr20828
-c.sd
}} \
239 "PR ld/20828 dynamic symbols with section GC\
240 (versioned shared library
)" \
241 "$LFLAGS -shared --gc-sections -T pr20828.ld\
242 --version
-script
=pr20828
-v.ver
" \
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 dynamic symbols with section GC (versioned)" \
251 "$LFLAGS -shared --gc-sections -T pr20828.ld\
252 --version
-script
=pr20828
-v.ver
" \
253 "tmpdir/libpr20828-v.so" \
256 {{readelf
--dyn
-syms pr20828
-c.sd
} \
257 {readelf
--dyn
-syms pr20828
-d.sd
} \
258 {readelf
--dyn
-syms pr20828
-e.sd
}} \
261 "PR ld/20828 forcibly exported symbol version without section GC" \
262 "$LFLAGS --no-dynamic-linker -e foo -E -T pr20828-v.ld --no-error-rwx-segments" "" "" \
264 {{objdump
-p pr20828
-v.od
}} \
267 "PR ld/20828 forcibly exported symbol version with section GC" \
268 "$LFLAGS --no-dynamic-linker -e foo --gc-sections -E -T pr20828-v.ld --no-error-rwx-segments" "" "" \
270 {{objdump
-p pr20828
-v.od
}} \
273 # PR
ld/21233 check
for correct dynamic symbol table entries where
:
274 #
- a symbol has been defined in a shared library used in the link
,
275 #
- the symbol has been referenced from a section swept in garbage collection
,
276 #
- the symbol has also been forced to be entered in the output file as an
277 # undefined symbol
, either with a command
-line option or a linker script
279 # Verify that the undefined symbol is global rather than local.
280 if { [check_gc_sections_available
] } {
281 run_ld_link_tests
[list \
283 "PR ld/21233 dynamic symbols with section GC\
284 (auxiliary shared library
)" \
285 "$LFLAGS -shared -T pr21233.ld --no-error-rwx-segments" "" "$AFLAGS_PIC" \
287 {{readelf
--dyn
-syms pr21233
-l.sd
}} \
290 run_ld_link_tests
[list \
292 "PR ld/21233 dynamic symbols with section GC (--undefined)" \
293 "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld --no-error-rwx-segments" \
294 "tmpdir/libpr21233.so" "" \
296 {{readelf
--dyn
-syms pr21233.sd
}} \
299 run_ld_link_tests
[list \
301 "PR ld/21233 dynamic symbols with section GC (--require-defined)" \
302 "$LFLAGS --gc-sections -e foo --require-defined=bar\
303 -T pr21233.
ld --no
-error
-rwx
-segments
" \
304 "tmpdir/libpr21233.so" "" \
306 {{readelf
--dyn
-syms pr21233.sd
}} \
309 run_ld_link_tests
[list \
311 "PR ld/21233 dynamic symbols with section GC (EXTERN)" \
312 "$LFLAGS --gc-sections -e foo -T pr21233-e.ld --no-error-rwx-segments" \
313 "tmpdir/libpr21233.so" "" \
315 {{readelf
--dyn
-syms pr21233.sd
}} \
319 if { [check_gc_sections_available
] } {
320 run_ld_link_tests
[list \
323 "$LFLAGS -shared --version-script pr22150.ver" \
332 "$LFLAGS -e _start --gc-sections" \
333 "tmpdir/pr22150.so" \
336 {{readelf
-V pr22150.vd
}} \
341 switch -glob $target_triplet
{
342 # exclude targets that don
't support copy relocs
351 run_ld_link_tests [list \
354 "$LFLAGS -shared --version-script=pr25458.map" \
363 "$LFLAGS -e _start --gc-sections" \
364 "tmpdir/pr25458.so" \
367 {{readelf {--dyn-sym --wide} pr25458.rd}} \
375 set ASFLAGS $old_ASFLAGS
378 {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" }
380 run_ld_link_tests [list \
381 [list "Build shared library for pr14170" \
382 "-shared" "" "$AFLAGS_PIC" "pr14170b.s" {} "pr14170.so" ] \
385 # bfin does not currently support copy relocs.
387 clear_xfail bfin-*-linux*
388 run_ld_link_tests [list \
389 [list "PR ld/14170" \
390 "$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \
392 {pr14170c.s} { } "pr14170" ] \
395 # Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests
396 # Nor will hppa64 with dot
-symbols.
397 run_ld_link_tests
[list \
398 [list
"PR ld/21703 shared" \
399 "$LFLAGS -shared --allow-multiple-definition --version-script pr21703.ver\
400 tmpdir
/pr21703
-3.o tmpdir
/pr21703
-4.o
" "" "$AFLAGS_PIC" \
401 {pr21703
-3.s pr21703
-4.s
} {{readelf
{--dyn
-syms
} pr21703
-shared.sd
}} \
403 ] \
[is_generic\
] hppa64
-*-*
405 # This target requires extra GAS options when building non
-PIC code
406 #
for linking with shared libraries.
408 if [istarget
"mips*-*-*"] {
409 append AFLAGS_NONPIC
" -call_nonpic"
412 # Run a test to check linking a shared library with a broken linker
413 # script that accidentally marks dynamic sections as notes. The
414 # resulting executable is not expected to work
, but the linker
415 # should not seg
-fault whilst creating the binary.
416 run_ld_link_tests
[list \
417 [list
"Build shared library for broken linker script test" \
418 "-shared --hash-style=sysv" "" "$AFLAGS_PIC" "note-3.s" \
421 [list
"Link using broken linker script" \
422 "$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" "" \
423 { { ld "note-3.l" } } \
427 run_ld_link_tests
[list \
428 [list
"Build pr17068.so" \
429 "-shared" "" "$AFLAGS_PIC" \
430 {pr17068d.s
} {} "pr17068.so"] \
431 [list
"Build pr17068a.a" \
433 {pr17068a.s pr17068c.s pr17068ez.s
} {} "pr17068a.a"] \
434 [list
"Build pr17068b.a" \
436 {pr17068b.s pr17068e.s
} {} "pr17068b.a"] \
439 # bfin does not currently support copy relocs.
441 clear_xfail bfin
-*-linux
*
443 {"pr17068 link --as-needed lib in group"
444 "$LFLAGS --as-needed --no-dynamic-linker"
445 "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\
447 {start.s pr17068.s
} {} "pr17068"}
450 # Fails
on MIPS because ABI trickery means that a NULL reloc is emitted.
451 # Fails
on bfin because relocations are not created.
452 setup_xfail mips
*-*-* bfin
-*-*
453 clear_xfail bfin
-*-linux
*
454 run_ld_link_tests
[list \
455 [list
"-Bsymbolic-functions" \
456 "-shared -Bsymbolic-functions $NO_DT_RELR_LDFLAGS" \
458 {symbolic
-func.s
} {{readelf
{-r
--wide
} symbolic
-func.r
}} \
459 "symbolic-func.so"] \
462 run_ld_link_tests
[list \
463 [list
"Build pr20995.so" \
464 "-shared" "" "$AFLAGS_PIC" \
465 {pr20995b.s
} {} "pr20995.so"] \
468 # These targets don
't copy dynamic variables into .bss.
469 setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" *loongarch*-*-*
470 # or don't have .data.rel.ro
471 setup_xfail
"hppa*64*-*-hpux*" "tic6x-*-*" "kvx*-*-*"
472 # or complain about relocs in read
-only sections
473 setup_xfail frv
-*-* lm32
-*-*
474 run_ld_link_tests
[list \
477 "$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
478 {pr20995a.s
} {{readelf
{-S
--wide
} pr20995.r
}} "pr20995"]]
480 # xfail
on targets that don
't support GNU_RELRO.
481 # For more details, please see discussions at:
482 # https://sourceware.org/ml/binutils/2017-01/msg00441.html
483 run_ld_link_tests [list \
484 [list "Build pr20995-2.so" \
485 "-shared -z relro" "" "$AFLAGS_PIC" \
486 {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \
487 ] {![check_relro_support]}
489 # LoongArch: Read-only sections, merged into text segment in normal exe.
490 setup_xfail alpha-*-* xtensa-*-* loongarch*-*-*
491 run_ld_link_tests [list \
494 "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
495 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]
496 ] {![check_relro_support]}
498 run_ld_link_tests [list \
499 [list "Build pr22374 shared library" \
500 "-shared" "" "$AFLAGS_PIC" "pr22374b.s" {} "pr22374.so" ] \
503 # The next test checks that copy relocs are not used unnecessarily,
504 # but that is just an optimization so don't complain loudly.
506 clear_xfail alpha
-*-* bfin
-*-linux
* csky
-*-* frv
-*-* hppa
*-*-* i?
86-*-*
507 clear_xfail ia64
-*-* loongarch
*-*-* microblaze
-*-* powerpc
*-*-* x86_64
-*-*
508 clear_xfail xtensa
-*-*
510 {"pr22374 function pointer initialization"
511 "" "tmpdir/pr22374.so" "" "pr22374a.s"
512 { {readelf
{--wide
-r
--dyn
-syms
} "pr22374-1.r"}
513 {readelf
{--wide
-r
} "pr22374-2.r"} }
517 if { [istarget
*-*-linux
*]
518 ||
[istarget kvx
-*-*]
519 ||
[istarget
*-*-nacl
*]
520 ||
[istarget
*-*-gnu
*] } {
522 {"Weak symbols in dynamic objects 1 (support)"
523 "-shared" "" "" {weak-dyn-1a.s}
526 {"Weak symbols in dynamic objects 1 (main test)"
527 "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s}
528 {{readelf
{--relocs
--wide
} weak
-dyn
-1.rd
}}
533 # Check to see
if the C compiler works
534 if { ![check_compiler_available
] } {
538 # Add
-ldl to extralibs
if needed
540 if { ![istarget
*-*-freebsd
*]} {
547 {foo.c
} {} "libfoo.so"}
548 {"Build versioned libfoo.so"
549 "-shared -Wl,--version-script=foo.map" "-fPIC"
550 {foo.c
} {} "libfoov.so"}
553 {begin.c end.c
} {} "libbar.so"}
554 {"Build warn libbar.so"
557 {{readelf
{-S
--wide
} libbarw.rd
}
558 {warning
{^.
*beginwarn.c
:7:\
(.
*\
): warning
: function foo is deprecated
\n?$
}}}
560 {"Build hidden libbar.so"
562 {begin.c endhidden.c
} {} "libbarh.so"}
563 {"Build protected libbar.so"
565 {begin.c endprotected.c
} {} "libbarp.so"}
566 {"Build libbar.so with libfoo.so"
567 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
568 {end.c
} {} "libbarfoo.so"}
569 {"Build libar.so with versioned libfoo.so"
570 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
571 {end.c
} {} "libbarfoov.so"}
572 {"Build hidden libbar.so with libfoo.so"
573 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
574 {endhidden.c
} {} "libbarhfoo.so"}
575 {"Build hidden libar.so with versioned libfoo.so"
576 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
577 {endhidden.c
} {} "libbarhfoov.so"}
578 {"Build protected libbar.so with libfoo.so"
579 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
580 {endprotected.c
} {} "libbarpfoo.so"}
581 {"Build protected libbar.so with versioned libfoo.so"
582 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
583 {endprotected.c
} {} "libbarpfoov.so"}
586 {dl1.c
} {} "libdl1.so"}
587 {"Build libdl2a.so with --dynamic-list=dl2.list"
588 "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
589 {dl2.c dl2xxx.c
} {} "libdl2a.so"}
590 {"Build libdl2a.so with --dynamic-list=dl2a.list"
591 "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC"
592 {dl2.c dl2xxx.c
} {} "libdl2a.so"}
593 {"Build libdl2a.so with --dynamic-list-data"
594 "-shared -Wl,--dynamic-list-data" "-fPIC"
595 {dl2.c dl2xxx.c
} {} "libdl2a.so"}
596 {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
597 "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
598 {dl2.c dl2xxx.c
} {} "libdl2b.so"}
599 {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
600 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
601 {dl2.c dl2xxx.c
} {} "libdl2c.so"}
602 {"Build libdl2d.so with --dynamic-list-data -Bsymbolic"
603 "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
604 {dl2.c dl2xxx.c
} {} "libdl2d.so"}
605 {"Build libdl2e.so with --export-dynamic-symbol=foo"
606 "-shared -Wl,--export-dynamic-symbol=foo" "-fPIC"
607 {dl2.c dl2xxx.c
} {} "libdl2e.so"}
608 {"Build libdl2f.so with --dynamic-list=dlempty.list and --export-dynamic-symbol=foo"
609 "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol=foo" "-fPIC"
610 {dl2.c dl2xxx.c
} {} "libdl2f.so"}
611 {"Build libdl2g.so with --export-dynamic-symbol-list=dl2.list"
612 "-shared -Wl,--export-dynamic-symbol-list=dl2.list" "-fPIC"
613 {dl2.c dl2xxx.c
} {} "libdl2g.so"}
614 {"Build libdl2h.so with --dynamic-list=dlempty.list and --export-dynamic-symbol-list=dl2.list"
615 "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol-list=dl2.list" "-fPIC"
616 {dl2.c dl2xxx.c
} {} "libdl2h.so"}
617 {"Build libdl2i.so with -Bsymbolic and --export-dynamic-symbol=foo"
618 "-shared -Wl,-Bsymbolic,--export-dynamic-symbol=foo" "-fPIC"
619 {dl2.c dl2xxx.c
} {} "libdl2i.so"}
620 {"Build libdl2j.so with -Bsymbolic and --export-dynamic-symbol-list=dl2.list"
621 "-shared -Wl,-Bsymbolic,--export-dynamic-symbol-list=dl2.list" "-fPIC"
622 {dl2.c dl2xxx.c
} {} "libdl2j.so"}
623 {"Build libdl2k.so with --export-dynamic-symbol-list=dl2.list and -Bsymbolic"
624 "-shared -Wl,--export-dynamic-symbol-list=dl2.list,-Bsymbolic" "-fPIC"
625 {dl2.c dl2xxx.c
} {} "libdl2k.so"}
626 # Check that
-Bno
-symbolic cancels
-Bsymbolic.
627 {"Build libdl2l.so with -Bsymbolic -Bno-symbolic and --export-dynamic-symbol=foo"
628 "-shared -Wl,-Bsymbolic,-Bno-symbolic,--export-dynamic-symbol=foo" "-fPIC"
629 {dl2.c dl2xxx.c
} {} "libdl2l.so"}
630 {"Build libdl4a.so with --dynamic-list=dl4.list"
631 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
632 {dl4.c dl4xxx.c
} {} "libdl4a.so"}
633 {"Build libdl4b.so with --dynamic-list-data"
634 "-shared -Wl,--dynamic-list-data" "-fPIC"
635 {dl4.c dl4xxx.c
} {} "libdl4b.so"}
636 {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list"
637 "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
638 {dl4.c dl4xxx.c
} {} "libdl4c.so"}
639 {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list"
640 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
641 {dl4.c dl4xxx.c
} {} "libdl4d.so"}
642 {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new"
643 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
644 {dl4.c dl4xxx.c
} {} "libdl4e.so"}
645 {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions"
646 "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC"
647 {dl4.c dl4xxx.c
} {} "libdl4f.so"}
650 {dl6.c
} {} "libdl6a.so"}
651 {"Build libdl6b.so with -Bsymbolic --dynamic-list-data"
652 "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
653 {dl6.c
} {} "libdl6b.so"}
654 {"Build libdl6c.so with -Bsymbolic"
655 "-shared -Wl,-Bsymbolic" "-fPIC"
656 {dl6.c
} {} "libdl6c.so"}
657 {"Build libdl6d.so with --dynamic-list-data -Bsymbolic"
658 "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC"
659 {dl6.c
} {} "libdl6d.so"}
662 {data1.c
} {} "libdata1.so"}
665 {data2.c
} {} "libdata2.so"}
667 "-r -nostdlib" "-fcommon"
668 {comm1.c
} {} "libcomm1.o"}
671 {func1.c
} {} "libfunc1.so"}
672 {"Build libpr9676-1.a"
674 {pr9676
-1.c
} {} "libpr9676-1.a"}
675 {"Build libpr9676-2.a"
677 {pr9676
-2.c
} {} "libpr9676-2.a"}
678 {"Build libpr9676-3.so"
680 {pr9676
-3.c
} {} "libpr9676-3.so"}
681 {"Build libpr9676-4.so"
683 {pr9676
-4.c
} {} "libpr9676-4.so"}
684 {"Build libpr9676-4a.so"
685 "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group"
687 {dummy.c
} {{readelf
{-s
} pr9676.rd
}} "libpr9676-4a.so"}
688 {"Build libpr9679.so"
689 "-shared" "-fPIC -O0"
690 {pr9679
-1.c pr9679
-2.c
} {{readelf
{-s
} pr9679.rd
}} "libpr9679.so"}
691 {"Build libpr11138-1.so"
692 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
693 {pr11138
-1.c
} {} "libpr11138-1.so"}
694 {"Build libpr11138-2.o"
696 {pr11138
-2.c
} {} "libpr11138-2.o"}
697 {"Build pr13250-1.so"
698 "-shared" "-fPIC -fcommon"
699 {pr13250
-1.c
} {} "libpr13250-1.so"}
700 {"Build pr13250-2.so with libpr13250-1.so"
701 "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC -fcommon"
702 {pr13250
-2.c
} {} "libpr13250-2.so"}
703 {"Build libpr13250-3.o"
704 "-r -nostdlib" "-fcommon"
705 {pr13250
-3.c
} {} "libpr13250-3.o"}
706 {"Build libpr14323-2.so"
707 "-shared" "-fPIC -fcommon"
708 {pr14323
-2.c
} {} "libpr14323-2.so"}
711 {pr14862
-1.c
} {} "libpr14862-1.o"}
712 {"Build libpr14862.so"
713 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
714 {pr14862
-2.c
} {} "libpr14862.so"}
715 {"Build libneeded1b.so"
717 {needed1b.c
} {} "libneeded1b.so"}
718 {"Build libneeded1a.so"
719 "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC"
720 {needed1a.c
} {} "libneeded1a.so"}
721 {"Build libneeded1c.o"
723 {needed1c.c
} {} "libneeded1c.o"}
724 {"Build libneeded1pic.o"
725 "-r -nostdlib" "-fPIC"
726 {needed1c.c
} {} "libneeded1pic.o"}
727 {"Build needed1a.so with --add-needed"
728 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
729 {dummy.c
} {} "needed1a.so"}
730 {"Build needed1b.so with --copy-dt-needed-entries"
731 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
732 {dummy.c
} {} "needed1b.so"}
733 {"Build needed1a.so with --no-add-needed"
734 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" ""
735 {dummy.c
} {} "needed1c.so"}
736 {"Build needed1b.so with --no-copy-dt-needed-entries"
737 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
738 {dummy.c
} {} "needed1d.so"}
741 {rel.c
} {} "librel.so"}
742 {"Build libneeded2a.so"
744 {needed2a.c
} {} "libneeded2a.so"}
745 {"Build libneeded2b.so"
746 "-shared -Wl,--version-script,needed2.ver" "-fPIC"
747 {needed2b.c
} {} "libneeded2b.so"}
748 {"Build libneeded2c.o"
750 {needed2c.c
} {} "libneeded2c.o"}
752 "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" ""
753 {dummy.c
} {} "needed2"}
754 {"Build libneeded3a.so"
755 "-shared -Wl,--no-add-needed" "-fPIC"
756 {needed1a.c
} {} "libneeded3a.so"}
757 {"Build libneeded3b.so"
758 "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC"
759 {dummy.c
} {} "libneeded3b.so"}
762 {needed3.c
} {} "libneeded3.so"}
764 "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
765 {dummy.c
} {} "needed3"}
767 "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
768 {rdynamic
-1.c
} {{readelf
{-s
} rdynamic
-1.rd
}} "rdynamic-1"}
770 "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
771 {dynamic
-1.c
} {{readelf
{-s
} dynamic
-1.rd
}} "dynamic-1"}
772 {"Build libpr16496a.so"
773 "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
774 {pr16496a.c
} {} "libpr16496a.so"}
775 {"Build libpr16496b.a"
777 {pr16496b.c
} {} "libpr16496b.a"}
778 {"Build libpr16496b.so"
779 "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
780 {dummy.c
} {{objdump
{-R
} pr16496b.od
}} "libpr16496b.so"}
781 {"Build libpr16452a.so"
782 "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC"
783 {pr16452a.c
} {} "libpr16452a.so"}
784 {"Build libpr16452b.so"
785 "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC"
786 {dummy.c
} {} "libpr16452b.so"}
788 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
789 {pr16452b.c
} {{objdump
{-p
} pr16452.od
}} "pr16452"}
791 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
792 {pr16452b.c
} {{objdump
{-p
} pr16457.od
}} "pr16457"}
793 {"Build libpr18458a.so"
794 "-shared -Wl,-z,now" "-fPIC"
795 {pr18458a.c
} {} "libpr18458a.so"}
796 {"Build libpr18458b.so"
797 "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC"
798 {pr18458b.c
} {} "libpr18458b.so"}
801 run_cc_link_tests
[list \
803 "Build libpr2404a.so" \
804 "-shared $NOSANITIZE_CFLAGS" \
805 "-fPIC $NOSANITIZE_CFLAGS" \
811 "Build libpr2404n.so" \
812 "-shared -Wl,-z,now $NOSANITIZE_CFLAGS" \
813 "-fPIC $NOSANITIZE_CFLAGS" \
819 "Build libpr2404b.a" \
821 "$NOSANITIZE_CFLAGS" \
827 "Build libpr26590a.so" \
835 "Build libpr26590b.so (1)" \
843 "Build pr26590c.o and pr26590d.o" \
846 {pr26590c.c pr26590d.c
} \
850 "Build pr26590 (1)" \
851 "tmpdir/pr26590c.o tmpdir/pr26590d.o \
852 -Wl
,--as
-needed tmpdir
/libpr26590a.so tmpdir
/libpr26590b.so
" \
855 {{error_output pr26590.err
}} \
859 "Build libpr26590b.so (2)" \
860 "-shared -Wl,--no-as-needed \
861 tmpdir
/libpr26590a.so
" \
868 "Build pr26590 (2)" \
869 "tmpdir/pr26590c.o tmpdir/pr26590d.o \
870 -Wl
,--as
-needed tmpdir
/libpr26590a.so tmpdir
/libpr26590b.so
" \
877 "Build libpr28348a.so" \
878 "-shared -Wl,--version-script=pr28348.t" \
897 "Build libpr28348b.so" \
898 "-shared -Wl,--version-script=pr28348.t \
899 -Wl
,--no
-as
-needed tmpdir
/pr28348b.o tmpdir
/libpr28348a.so
" \
907 "-Wl,--no-as-needed tmpdir/pr28348c.o \
908 tmpdir
/pr28348a.o tmpdir
/libpr28348a.so tmpdir
/libpr28348b.so \
909 tmpdir
/libpr28348a.so
" \
912 {{readelf
{--dyn
-syms
--wide
} pr28348.rd
}} \
916 "Build pr31482b-no-lto.so" \
919 {pr31482b
-no
-lto.c
} \
921 "pr31482b-no-lto.so" \
924 "Build pr31482c-no-lto.a" \
927 {pr31482c
-no
-lto.c
} \
929 "pr31482c-no-lto.a" \
932 "Build pr31482d-no-lto.a" \
935 {pr31482d
-no
-lto.c
} \
937 "pr31482d-no-lto.a" \
941 # pr19073.s uses .
set, which has a different meaning
on alpha.
942 if { ![istarget alpha
-*-*] } {
945 "-r -nostdlib -z noexecstack" ""
946 {pr19073.s
} {} "pr19073a.o"}
947 {"Build libpr19073.so"
948 "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC"
949 {dummy.c
} {{readelf
{--dyn
-syms
--wide
} pr19073.rd
}} "libpr19073.so"}
953 {"Build pr21964-1a.so"
955 {pr21964
-1a.c
} {} "pr21964-1a.so"}
956 {"Build pr21964-1b.so"
958 {pr21964
-1b.c
} {} "pr21964-1b.so"}
959 {"Build pr21964-2a.so"
961 {pr21964
-2a.c
} {} "pr21964-2a.so"}
962 {"Build pr21964-2b.so"
964 {pr21964
-2b.c
} {} "pr21964-2b.so"}
965 {"Build pr21964-3a.so"
967 {pr21964
-3a.c
} {} "pr21964-3a.so"}
969 "-shared" "-fPIC -g -O2"
970 {pr21978a.c pr21978b.c
} {{objdump
{-Sl
} pr21978.od
}} "pr21978.so"}
972 "-shared" "-fPIC -fcommon"
973 {pr26580
-b.c
} {} "libpr26580-2.so"}
976 run_cc_link_tests $build_tests
978 run_cc_link_tests
[list \
980 "Build pr26094-1.so" \
981 "-shared -Wl,--version-script=pr26094-1.ver" \
984 {{readelf
{--dyn
-syms
--wide
} pr26094
-1a.rd
}} \
989 "-Wl,--no-as-needed tmpdir/pr26094-1.so" \
991 {pr26094
-1b.c pr26094
-1c.c
} \
992 {{readelf
{--dyn
-syms
--wide
} pr26094
-1b.rd
}} \
996 "Build pr26302a.so" \
997 "-shared -Wl,--version-script=pr26302.ver" \
1004 "Build pr26302b.so" \
1005 "-shared -Wl,--no-as-needed tmpdir/pr26302a.so" \
1008 {{readelf
{-sW
} pr26302.rd
} \
1009 {nm
{-u
} pr26302.nd
} \
1010 {nm
{-u
-D
} pr26302.nd
} \
1011 {nm
{-u
-D
--with
-symbol
-versions
} pr26302.nd
}} \
1016 run_ld_link_tests
[list \
1018 "pr22269-1 (static pie undefined weak)" \
1019 "-pie -e _start --no-dynamic-linker -z text -z nocombreloc " \
1023 {{readelf
-rW pr22269
-1.rd
}} \
1025 "-fPIE -O2 $NOSANITIZE_CFLAGS" \
1029 set run_tests
[list \
1030 [list
"Run normal with libfoo.so" \
1031 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
1032 {main.c
} "normal" "normal.out" ] \
1033 [list
"Run protected with libfoo.so" \
1034 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \
1035 {main.c
} "protected" "normal.out" ] \
1036 [list
"Run hidden with libfoo.so" \
1037 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \
1038 {main.c
} "hidden" "hidden.out" ] \
1039 [list
"Run normal with versioned libfoo.so" \
1040 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \
1041 {main.c
} "normalv" "normal.out" ] \
1042 [list
"Run warn with versioned libfoo.so" \
1043 "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
1044 {main.c
} "warn" "warn.out" \
1045 "" "c" {^.*beginwarn.c:7:\(.*\): warning: function foo is deprecated\n?$} ] \
1046 [list
"Run protected with versioned libfoo.so" \
1047 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
1048 {main.c
} "protected" "normal.out" ] \
1049 [list
"Run hidden with versioned libfoo.so" \
1050 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \
1051 {main.c
} "hiddenv" "hidden.out" ] \
1052 [list
"Run normal libbar.so with libfoo.so" \
1053 "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \
1054 {main.c
} "normal" "normal.out" ] \
1055 [list
"Run protected libbar.so with libfoo.so" \
1056 "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \
1057 {main.c
} "protected" "normal.out" ] \
1058 [list
"Run hidden libbar.so with libfoo.so" \
1059 "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \
1060 {main.c
} "hidden" "hidden.out" ] \
1061 [list
"Run normal libbar.so with versioned libfoo.so" \
1062 "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \
1063 {main.c
} "normal" "normal.out" ] \
1064 [list
"Run protected libbar.so with versioned libfoo.so" \
1065 "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \
1066 {main.c
} "protected" "normal.out" ] \
1067 [list
"Run hidden libbar.so with versioned libfoo.so" \
1068 "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
1069 {main.c
} "hidden" "hidden.out" ] \
1070 [list
"Run with libdl2a.so" \
1071 "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
1072 {dl2main.c
} "dl2a" "dl2a.out" ] \
1073 [list
"Run with libdl2b.so" \
1074 "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \
1075 {dl2main.c
} "dl2b" "dl2b.out" ] \
1076 [list
"Run with libdl2c.so" \
1077 "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
1078 {dl2main.c
} "dl2c" "dl2b.out" ] \
1079 [list
"Run with libdl2d.so" \
1080 "-Wl,--no-as-needed tmpdir/libdl2d.so" "" \
1081 {dl2main.c
} "dl2d" "dl2a.out" ] \
1082 [list
"Run with libdl2e.so" \
1083 "-Wl,--no-as-needed tmpdir/libdl2e.so" "" \
1084 {dl2main.c
} "dl2e" "dl2b.out" ] \
1085 [list
"Run with libdl2f.so" \
1086 "-Wl,--no-as-needed tmpdir/libdl2f.so" "" \
1087 {dl2main.c
} "dl2f" "dl2a.out" ] \
1088 [list
"Run with libdl2g.so" \
1089 "-Wl,--no-as-needed tmpdir/libdl2g.so" "" \
1090 {dl2main.c
} "dl2g" "dl2b.out" ] \
1091 [list
"Run with libdl2h.so" \
1092 "-Wl,--no-as-needed tmpdir/libdl2h.so" "" \
1093 {dl2main.c
} "dl2h" "dl2a.out" ] \
1094 [list
"Run with libdl2i.so" \
1095 "-Wl,--no-as-needed tmpdir/libdl2i.so" "" \
1096 {dl2main.c
} "dl2i" "dl2a.out" ] \
1097 [list
"Run with libdl2j.so" \
1098 "-Wl,--no-as-needed tmpdir/libdl2j.so" "" \
1099 {dl2main.c
} "dl2j" "dl2a.out" ] \
1100 [list
"Run with libdl2k.so" \
1101 "-Wl,--no-as-needed tmpdir/libdl2k.so" "" \
1102 {dl2main.c
} "dl2k" "dl2a.out" ] \
1103 [list
"Run with libdl2l.so" \
1104 "-Wl,--no-as-needed tmpdir/libdl2l.so" "" \
1105 {dl2main.c
} "dl2l" "dl2b.out" ] \
1106 [list
"Run with libdl4a.so" \
1107 "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
1108 {dl4main.c
} "dl4a" "dl4a.out" "-fPIC"] \
1109 [list
"Run with libdl4b.so" \
1110 "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \
1111 {dl4main.c
} "dl4b" "dl4a.out" "-fPIC"] \
1112 [list
"Run with libdl4c.so" \
1113 "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \
1114 {dl4main.c
} "dl4c" "dl4b.out" "-fPIC"] \
1115 [list
"Run with libdl4d.so" \
1116 "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \
1117 {dl4main.c
} "dl4d" "dl4b.out" "-fPIC"] \
1118 [list
"Run with libdl4e.so" \
1119 "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
1120 {dl4main.c
} "dl4e" "dl4a.out" "-fPIC"] \
1121 [list
"Run with libdl4f.so" \
1122 "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
1123 {dl4main.c
} "dl4f" "dl4a.out" "-fPIC"] \
1124 [list
"Run with libdata1.so" \
1125 "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
1126 {dynbss1.c
} "dynbss1" "pass.out" ] \
1127 [list
"Run with libdata2.so" \
1128 "-Wl,--no-as-needed tmpdir/libdata2.so" "" \
1129 {weakdef1.c
} "weakdef1" "pass.out" ] \
1130 [list
"Run with libfunc1.so comm1.o" \
1131 "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \
1132 {dummy.c
} "comm1" "pass.out" ] \
1133 [list
"Run with comm1.o libfunc1.so" \
1134 "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \
1135 {dummy.c
} "comm1" "pass.out" ] \
1136 [list
"Run with pr11138-2.c libpr11138-1.so" \
1137 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \
1138 {dummy.c
} "pr11138a" "pr11138.out" ] \
1139 [list
"Run with libpr11138-1.so pr11138-2.c" \
1140 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \
1141 {dummy.c
} "pr11138b" "pr11138.out" ] \
1142 [list
"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \
1143 "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "-fcommon" \
1144 {dummy.c
} "pr13250" "pass.out" ] \
1145 [list
"Run with pr14323-1.c pr14323-2.so" \
1146 "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \
1147 {pr14323
-1.c
} "pr14323" "pass.out" ] \
1148 [list
"Run with pr14862-1.c libpr14862.so" \
1149 "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
1150 {dummy.c
} "pr14862" "pr14862.out" ] \
1151 [list
"Link with --add-needed" \
1152 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
1153 {dummy.c
} "needed1a" "needed1.out" ] \
1154 [list
"Link with --copy-dt-needed-entries" \
1155 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
1156 {dummy.c
} "needed1b" "needed1.out" ] \
1157 [list
"Run relmain" \
1158 "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
1159 {relmain.c
} "relmain" "relmain.out" ] \
1160 [list
"Run pr2404" \
1161 "$NOSANITIZE_CFLAGS -Wl,--no-as-needed \
1162 tmpdir
/pr2404b.o tmpdir
/libpr2404a.so
" \
1164 {dummy.c
} "pr2404" "pr2404.out" \
1165 "$NOSANITIZE_CFLAGS" ] \
1166 [list
"Run pr2404n" \
1167 "$NOSANITIZE_CFLAGS -Wl,-z,now \
1168 -Wl
,--no
-as
-needed tmpdir
/pr2404b.o tmpdir
/libpr2404n.so
" "" \
1169 {dummy.c
} "pr2404n" "pr2404.out" \
1170 "$NOSANITIZE_CFLAGS" ] \
1171 [list
"Run pr18458" \
1172 "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
1173 {pr18458c.c
} "pr18458" "pass.out" ] \
1174 [list
"Run pr21964-1" \
1175 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \
1176 {pr21964
-1c.c
} "pr21964-1" "pass.out" ] \
1177 [list
"Run pr21964-3" \
1178 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \
1179 {pr21964
-3c.c
} "pr21964-3" "pass.out" ] \
1182 {pr26580
-a.c
} "pr26580-3" "pr26580-3.out" "-fcommon" "c" "" \
1183 "-Wl,--as-needed tmpdir/libpr26580-2.so" ] \
1186 {pr26580
-a.c
} "pr26580-4" "pr26580-4.out" "-fcommon" "c" "" \
1187 "-Wl,--no-as-needed tmpdir/libpr26580-2.so" ] \
1188 [list
"Run pr26590 (2)" \
1190 {pr26590c.c pr26590d.c
} "pr26590" "pass.out" "" "c" "" \
1191 "-Wl,--as-needed tmpdir/libpr26590a.so tmpdir/libpr26590b.so" ] \
1192 [list
"Run pr31482 (no-lto)" \
1193 "-Wl,--no-as-needed" \
1195 {pr31482a
-no
-lto.c
} \
1201 "tmpdir/pr31482b-no-lto.so tmpdir/pr31482c-no-lto.a \
1202 tmpdir
/pr31482d
-no
-lto.a
" \
1206 # NetBSD ELF systems
do not currently support the .
*_array sections.
1207 run_ld_link_exec_tests $run_tests
"*-*-netbsd*"
1209 # These tests require dlopen support.
1210 set dlopen_run_tests
[list \
1211 [list
"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
1212 "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
1213 {dl1main.c
} "dl1a" "dl1.out" ] \
1214 [list
"Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
1215 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
1216 {dl1main.c
} "dl1b" "dl1.out" ] \
1217 [list
"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
1218 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
1219 {dl6amain.c
} "dl6a1" "dl6a.out" ] \
1220 [list
"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
1221 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
1222 {dl6amain.c
} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \
1223 [list
"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
1224 "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
1225 {dl6amain.c
} "dl6a3" "dl6b.out" ] \
1226 [list
"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
1227 "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
1228 {dl6amain.c
} "dl6a4" "dl6a.out" ] \
1229 [list
"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
1230 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
1231 {dl6amain.c
} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \
1232 [list
"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
1233 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
1234 {dl6amain.c
} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \
1235 [list
"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
1236 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
1237 {dl6amain.c
} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \
1238 [list
"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
1239 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
1240 {dl6bmain.c
} "dl6b1" "dl6a.out" ] \
1241 [list
"Run dl6b2 with dlopen on libdl6b.so" \
1242 "-Wl,--no-as-needed $extralibs" "" \
1243 {dl6bmain.c
} "dl6b2" "dl6b.out" ] \
1244 [list
"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
1245 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
1246 {dl6cmain.c
} "dl6c1" "dl6b.out" ] \
1247 [list
"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
1248 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
1249 {dl6dmain.c
} "dl6d1" "dl6a.out" ] \
1250 [list
"Run pr21964-2" \
1251 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \
1252 {pr21964
-2c.c
} "pr21964-2" "pass.out" ] \
1253 [list
"Run pr21964-5" \
1254 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \
1255 {pr21964
-5.c
} "pr21964-5" "pass.out" ] \
1258 # Only run them when libdl is available.
1259 if [check_libdl_available
] {
1260 # XFAIL
on NetBSD ELF systems as they
do not currently support the .
*_array
1262 # Disable all sanitizers.
1263 set old_CFLAGS
"$CFLAGS_FOR_TARGET"
1264 append CFLAGS_FOR_TARGET
" $NOSANITIZE_CFLAGS"
1265 run_ld_link_exec_tests $dlopen_run_tests
"*-*-netbsd*"
1266 set CFLAGS_FOR_TARGET
"$old_CFLAGS"
1269 # Check
--no
-add
-needed and
--no
-copy
-dt
-needed
-entries
1270 set testname
"--no-add-needed"
1271 set exec_output
[run_host_cmd
"$CC_FOR_TARGET" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
1272 if { [ regexp
"tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
1277 set testname
"--no-copy-dt-needed-entries"
1278 set exec_output
[run_host_cmd
"$CC_FOR_TARGET" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
1279 if { [ regexp
"tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
1284 set testname
"--no-add-needed -shared"
1285 set exec_output
[run_host_cmd
"$CC_FOR_TARGET" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"]
1286 if { [ regexp
"undefined reference to `\.?bar'" $exec_output ] } {
1291 set testname
"--no-copy-dt-needed-entries -shared"
1292 set exec_output
[run_host_cmd
"$CC_FOR_TARGET" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"]
1293 if { [ regexp
"undefined reference to `\.?bar'" $exec_output ] } {
1299 # Check to see
if the C
++ compiler works
1300 if { [which $CXX_FOR_TARGET
] == 0 } {
1304 set build_cxx_tests
{
1305 {"Build libdl3a.so with --dynamic-list=dl3.list"
1306 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
1307 {dl3.cc
} {} "libdl3a.so" "c++"}
1308 {"Build libdl3b.so with -Bsymbolic"
1309 "-shared -Wl,-Bsymbolic" "-fPIC"
1310 {dl3.cc
} {} "libdl3b.so" "c++"}
1311 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
1312 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
1313 {dl3.cc
} {} "libdl3c.so" "c++"}
1316 run_cc_link_tests
[list \
1318 "Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" \
1319 "-shared $NOSANITIZE_CFLAGS -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" \
1320 "-fPIC -ansi $NOSANITIZE_CFLAGS" \
1327 "Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" \
1328 "-shared $NOSANITIZE_CFLAGS -Wl,--dynamic-list-data,--dynamic-list-cpp-new" \
1329 "-fPIC -ansi $NOSANITIZE_CFLAGS" \
1337 #
"-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
1338 #
{"Run with libdl3b.so"
1339 #
"tmpdir/libdl3b.so" ""
1340 #
{dl3main.cc
} "dl3b" "dl3b.out" "" "c++"}
1342 {"Run with libdl3a.so"
1343 "-Wl,--no-as-needed tmpdir/libdl3a.so" ""
1344 {dl3main.cc
} "dl3a" "dl3a.out" "" "c++"}
1345 {"Run with libdl3c.so"
1346 "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
1347 {dl3main.cc
} "dl3c" "dl3a.out" "" "c++"}
1350 run_ld_link_exec_tests
[list \
1352 "Run with libnew1a.so" \
1353 "-Wl,--no-as-needed tmpdir/libnew1a.so $NOSANITIZE_CFLAGS" \
1358 "-ansi $NOSANITIZE_CFLAGS" \
1362 "Run with libnew1b.so" \
1363 "-Wl,--no-as-needed tmpdir/libnew1b.so $NOSANITIZE_CFLAGS" \
1368 "-ansi $NOSANITIZE_CFLAGS" \
1373 run_cc_link_tests $build_cxx_tests
1374 run_ld_link_exec_tests $run_cxx_tests
1376 if { [istarget
*-*-linux
*]
1377 ||
[istarget
*-*-nacl
*]
1378 ||
[istarget
*-*-gnu
*] } {
1379 run_cc_link_tests
[list \
1381 "Build libpr2404b.a with PIE" \
1383 "-fPIE $NOSANITIZE_CFLAGS" \
1389 "Build pr19579a.o" \
1390 "" "-fPIE -fcommon" \
1396 "Build libpr19579.so" \
1404 "Build libpr19579now.so" \
1405 "-shared -Wl,-z,now" \
1412 "Build pr22393-2a.so" \
1413 "-shared -Wl,-z,separate-code,--no-rosegment" \
1416 {{readelf
-lW pr22393
-2a.rd
} \
1417 {readelf
-lW pr22393
-2b.rd
}} \
1421 "Build pr22393-2a-now.so" \
1422 "-shared -Wl,-z,separate-code,-z,now,--no-rosegment" \
1425 {{readelf
-lW pr22393
-2a.rd
} \
1426 {readelf
-lW pr22393
-2b.rd
}} \
1427 "pr22393-2a-now.so" \
1431 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-rosegment,--no-as-needed tmpdir/pr22393-2a.so" \
1434 {{readelf
-lW pr22393
-2a.rd
} \
1435 {readelf
-lW pr22393
-2b.rd
}} \
1439 "Build pr22393-2 (PIE)" \
1440 "-pie -Wl,-z,separate-code,--no-rosegment,--no-as-needed tmpdir/pr22393-2a-now.so" \
1443 {{readelf
-lW pr22393
-2a.rd
} \
1444 {readelf
-lW pr22393
-2b.rd
}} \
1448 "Build pr22393-2 (static)" \
1449 "-static -Wl,-z,separate-code,--no-rosegment" \
1451 {pr22393
-2a.c pr22393
-2b.c
} \
1452 {{readelf
-lW pr22393
-2a.rd
} \
1453 {readelf
-lW pr22393
-2b.rd
}} \
1454 "pr22393-2-static" \
1457 run_ld_link_exec_tests
[list \
1459 "Run pr18458 with PIE" \
1460 "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \
1468 "Run pr2404 with PIE" \
1469 "-pie $NOSANITIZE_CFLAGS -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
1474 "-fPIE $NOSANITIZE_CFLAGS" \
1477 "Run pr2404 with PIE (-z now)" \
1478 "-pie $NOSANITIZE_CFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
1483 "-fPIE $NOSANITIZE_CFLAGS" \
1489 { pr18718.c check
-ptr
-eq.c
} \
1495 "Run pr18718 (-z now)" \
1498 { pr18718.c check
-ptr
-eq.c
} \
1504 "Run pr18718 with PIE (1)" \
1507 { pr18718.c check
-ptr
-eq.c
} \
1510 "-O2 -fPIE -I../bfd" \
1513 "Run pr18718 with PIE (2)" \
1516 { pr18718.c check
-ptr
-eq.c
} \
1519 "-O2 -fPIE -I../bfd" \
1522 "Run pr18718 with PIE (3)" \
1525 { pr18718.c check
-ptr
-eq.c
} \
1528 "-O2 -fPIE -I../bfd" \
1531 "Run pr18718 with PIE (4)" \
1534 { pr18718.c check
-ptr
-eq.c
} \
1537 "-O2 -fPIE -I../bfd" \
1540 "Run pr18718 with PIC (1)" \
1543 { pr18718.c check
-ptr
-eq.c
} \
1546 "-O2 -fPIC -I../bfd" \
1549 "Run pr18718 with PIC (2)" \
1552 { pr18718.c check
-ptr
-eq.c
} \
1555 "-O2 -fPIC -I../bfd" \
1558 "Run pr18718 with PIC (3)" \
1561 { pr18718.c check
-ptr
-eq.c
} \
1564 "-O2 -fPIC -I../bfd" \
1567 "Run pr18718 with PIC (4)" \
1570 { pr18718.c check
-ptr
-eq.c
} \
1573 "-O2 -fPIC -I../bfd" \
1577 "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
1585 "Run pr19579 (-z now)" \
1586 "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
1595 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
1603 "Run pr22393-2 (PIE)" \
1604 "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
1612 "Run pr22393-2 (static)" \
1613 "-static -Wl,-z,separate-code" \
1615 {pr22393
-2a.c pr22393
-2b.c
} \
1616 "pr22393-2-static" \
1634 proc mix_pic_and_non_pic
{xfails cflags ldflags exe
} {
1635 run_cc_link_tests
[list \
1637 "Build libpr19719a.so" \
1638 "-shared -Wl,-soname,libpr19719.so" \
1645 "Build libpr19719b.so" \
1646 "-shared -Wl,-soname,libpr19719.so" \
1653 "Build libpr19719b.o" \
1662 send_log
"cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n"
1663 exec cp tmpdir
/libpr19719b.so tmpdir
/libpr19719.so
1665 run_ld_link_exec_tests
[list \
1667 "Run $exe fun defined" \
1668 "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
1670 { pr19719a.c pr19719c.c
} \
1677 send_log
"cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n"
1678 exec cp tmpdir
/libpr19719a.so tmpdir
/libpr19719.so
1680 foreach targ $xfails
{
1685 unsupported
"Run $exe fun undefined"
1689 set exec_output
[run_host_cmd
"tmpdir/$exe" ""]
1690 if {![string match
"PASS\n" $exec_output]} {
1691 fail
"Run $exe fun undefined"
1693 pass
"Run $exe fun undefined"
1697 mix_pic_and_non_pic
[list
"arm*-*-*"] "" "" "pr19719"
1698 mix_pic_and_non_pic
[] "-fPIE" "-pie" "pr19719pie"
1701 if { [istarget
"i?86-*-*"]
1702 ||
[istarget
"x86_64-*-*"] } {
1703 set AFLAGS_PIE
"-mrelax-relocations=yes"
1705 if [istarget
"sparc*-*-*"] {
1706 set AFLAGS_PIE
"-Av9"
1709 if { ([istarget
"*-*-linux*"]
1710 ||
[istarget
"*-*-nacl*"]
1711 ||
[istarget
"*-*-gnu*"])
1712 && ![istarget
"mips*-*-*"] } {
1713 run_ld_link_tests
[list \
1715 "Build libpr23162a.so" \
1722 "-fPIC -O2 $NOSANITIZE_CFLAGS" \
1726 "-pie --no-as-needed tmpdir/libpr23162a.so" \
1730 {{readelf
{-rW
} pr23162.rd
}} \
1732 "-fPIC -O0 $NOSANITIZE_CFLAGS" \
1735 "Build libpr23162b.so" \
1736 "-shared --version-script=pr23162.map" \
1742 "-fPIC -O2 $NOSANITIZE_CFLAGS" \
1746 "-pie --no-as-needed tmpdir/libpr23162b.so" \
1750 {{readelf
{-rW
} pr23162.rd
}} \
1752 "-fPIC -O0 $NOSANITIZE_CFLAGS" \
1755 "Build libpr23161a.so" \
1760 {{readelf
{--dyn
-syms
-rW
} pr23161a.rd
}} \
1762 "-fPIC -O2 $NOSANITIZE_CFLAGS" \
1766 "-pie --no-as-needed tmpdir/libpr23161a.so" \
1770 {{readelf
{--dyn
-syms
-rW
} pr23161b.rd
}} \
1772 "-fPIC -O0 $NOSANITIZE_CFLAGS" \
1775 "Build libpr23161b.so" \
1776 "-shared --version-script=pr23161.map" \
1780 {{readelf
{--dyn
-syms
-rW
} pr23161a.rd
}} \
1782 "-fPIC -O2 $NOSANITIZE_CFLAGS" \
1786 "-pie --no-as-needed tmpdir/libpr23161b.so" \
1790 {{readelf
{--dyn
-syms
-rW
} pr23161b.rd
}} \
1792 "-fPIC -O0 $NOSANITIZE_CFLAGS" \
1797 if { [istarget
"i?86-*-*"]
1798 ||
[istarget
"x86_64-*-*"] } {
1799 run_ld_link_tests
[list \
1801 "Build libpr23161c.so" \
1806 {{readelf
{--dyn
-syms
-rW
} pr23161c.rd
}} \
1808 "-fPIC -O2 $NOSANITIZE_CFLAGS" \
1812 "-pie --no-as-needed tmpdir/libpr23161c.so" \
1816 {{readelf
{--dyn
-syms
-rW
} pr23161d.rd
}} \
1818 "-fPIC -O0 $NOSANITIZE_CFLAGS" \
1823 run_ld_link_tests
[list \
1824 [list
"Build pr23658.so" \
1825 "-shared" "" "$AFLAGS_PIC" \
1826 {pr23658
-1a.s
} {} "pr23658.so"] \
1829 "--dynamic-linker tmpdir/pr23658.so --no-as-needed tmpdir/pr23658.so" \
1832 { pr23658
-1a.s pr23658
-1b.s pr23658
-1c.s pr23658
-1d.s start.s
} \
1833 {{readelf
{-lW
} pr23658
-2.rd
}} \