]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - ld/testsuite/ld-elf/shared.exp
Document setting experimental on release branch.
[thirdparty/binutils-gdb.git] / ld / testsuite / ld-elf / shared.exp
CommitLineData
d2dee3b2 1# Expect script for various ELF tests.
219d1afa 2# Copyright (C) 2006-2018 Free Software Foundation, Inc.
d2dee3b2 3#
f96b4a7b
NC
4# This file is part of the GNU Binutils.
5#
6# This program is free software; you can redistribute it and/or modify
d2dee3b2 7# it under the terms of the GNU General Public License as published by
f96b4a7b 8# the Free Software Foundation; either version 3 of the License, or
d2dee3b2
L
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
f96b4a7b
NC
18# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19# MA 02110-1301, USA.
d2dee3b2
L
20#
21
22# Exclude non-ELF targets.
23
24if ![is_elf_format] {
25 return
26}
27
47523653
AM
28# Skip targets where -shared is not supported
29
30if ![check_shared_lib_support] {
31 return
32}
33
6b737370
L
34# Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required.
35global NOPIE_CFLAGS NOPIE_LDFLAGS
36
66824765
AM
37set old_ASFLAGS $ASFLAGS
38
81ff47b3
MR
39# This target requires extra GAS options when building code for shared
40# libraries.
41set AFLAGS_PIC ""
18e404c4
AM
42if [istarget "nds32*-*"] {
43 append AFLAGS_PIC " -mpic"
44}
81ff47b3
MR
45if [istarget "tic6x-*-*"] {
46 append AFLAGS_PIC " -mpic -mpid=near"
47}
185cdb8c
EB
48if [istarget "sparc*-*-*"] {
49 append AFLAGS_PIC " -K PIC"
50}
51
81ff47b3
MR
52# This target requires a non-default emulation for successful shared
53# library/executable builds.
54set LFLAGS ""
55if [istarget "tic6x-*-*"] {
56 append LFLAGS " -melf32_tic6x_le"
57}
f3a9baf1
MR
58# HPUX targets use a different .comm syntax.
59set hpux ""
60if [istarget "*-*-hpux*"] {
61 set hpux "--defsym HPUX=1"
62}
8988502d
MR
63# These targets do not default to linking with shared libraries.
64if { [istarget "mips*vr4100*-*-elf*"] \
65 || [istarget "mips*vr4300*-*-elf*"] \
66 || [istarget "mips*vr5000*-*-elf*"] } {
67 append LFLAGS " -call_shared"
68}
81ff47b3 69
08f650e6
L
70if [is_underscore_target] {
71 set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
72}
73
74run_ld_link_tests [list \
75 [list \
76 "Build pr22471a.so" \
77 "$LFLAGS -shared" \
78 "" \
79 "$AFLAGS_PIC" \
80 {pr22471a.s} \
81 {} \
82 "pr22471a.so" \
83 ] \
84 [list \
85 "Build pr22471b.so" \
86 "$LFLAGS -shared --version-script pr22471.t" \
87 "tmpdir/pr22471a.so" \
88 "$AFLAGS_PIC" \
89 {pr22471a.s} \
90 {} \
91 "pr22471b.so" \
92 ] \
93 [list \
94 "Build pr22471" \
95 "$LFLAGS -rpath-link ." \
96 "tmpdir/pr22471b.so" \
97 "" \
98 {pr22471b.s} \
99 {} \
100 "pr22471" \
101 ] \
d664fd41
L
102 [list \
103 "Build pr22649-1.so" \
104 "$LFLAGS -shared" \
105 "" \
106 "$AFLAGS_PIC" \
107 {pr22649-1.s} \
108 {} \
109 "pr22649-1.so" \
110 ] \
08f650e6
L
111]
112
87e79a65 113if { [check_gc_sections_available] } {
af667f22
MR
114 if [istarget mips*-*-*] {
115 set actions {{ld pr22649-2ab-mips.msg}}
116 } else {
117 set actions {{ld pr22649.msg}}
118 }
87e79a65
AM
119 run_ld_link_tests [list \
120 [list \
121 "Build pr22649-2a.so" \
122 "$LFLAGS -shared -gc-sections -print-gc-sections" \
123 "" \
124 "$AFLAGS_PIC" \
125 {pr22649-2a.s} \
af667f22 126 $actions \
87e79a65
AM
127 "pr22649-2a.so" \
128 ] \
129 [list \
130 "Build pr22649-2b.so" \
131 "$LFLAGS -shared -gc-sections -print-gc-sections" \
132 "tmpdir/pr22649-1.so" \
133 "$AFLAGS_PIC" \
134 {pr22649-2a.s} \
af667f22 135 $actions \
87e79a65
AM
136 "pr22649-2b.so" \
137 ] \
af667f22
MR
138 ]
139 if { [istarget mips*-*-*] && ![istarget *-*-elf*] } {
140 set actions {{ld pr22649-2cd-mips.msg}}
141 } else {
142 set actions {}
143 }
144 run_ld_link_tests [list \
87e79a65
AM
145 [list \
146 "Build pr22649-2c.so" \
147 "$LFLAGS -shared -gc-sections -print-gc-sections" \
148 "" \
149 "$AFLAGS_PIC" \
150 {pr22649-2b.s} \
af667f22 151 $actions \
87e79a65
AM
152 "pr22649-2b.so" \
153 ] \
154 [list \
155 "Build pr22649-2d.so" \
156 "$LFLAGS -shared -gc-sections -print-gc-sections" \
157 "tmpdir/pr22649-1.so" \
158 "$AFLAGS_PIC" \
159 {pr22649-2b.s} \
af667f22 160 $actions \
87e79a65
AM
161 "pr22649-2b.so" \
162 ] \
163 ]
164}
165
63c1f59d
AM
166run_ld_link_tests [list \
167 [list \
168 "DT_TEXTREL in shared lib" \
169 "$LFLAGS -shared --warn-shared-textrel" \
170 "" \
171 "$AFLAGS_PIC" \
172 {textrel.s} \
173 {{ld textrel.warn} \
174 {readelf {-d --wide} textrel.rd}} \
175 "textrel.so" \
176 ] \
177] "xtensa-*-*"
178
a4eb6927
MR
179# The MIPS backend sets SHF_WRITE, in `mips_elf_create_dynamic_relocation',
180# for any section that has a dynamic relocation attached and consequently
181# this test is irrelevant for MIPS targets. We don't have a clean way to
182# request UNSUPPORTED result, which would be the most appropriate here,
183# so we just XFAIL the test instead.
63c1f59d
AM
184run_ld_link_tests [list \
185 [list \
186 "DT_TEXTREL map file warning" \
187 "$LFLAGS -shared -M" \
188 "" \
189 "$AFLAGS_PIC" \
190 {textrel.s} \
191 {{ld textrel.map}} \
192 "textrel.so" \
193 ] \
a4eb6927 194] "cris*-*-*" "mips*-*-*"
63c1f59d 195
81ff47b3
MR
196# PR ld/20828 check for correct dynamic symbol table entries where:
197# - symbols have been defined with a linker script,
198# - the same symbols have been seen in shared library used in the link,
199# - the shared library symbols have been swept in section garbage collection.
200# Verify that the symbols are global rather than local and that a version
201# script adjusts them accordingly.
902e9fc7
MR
202# Also verify that a version definition supplied by an object rather than
203# a version script and forcibly exported is unaffected by section GC.
81ff47b3
MR
204if { [check_gc_sections_available] } {
205 run_ld_link_tests [list \
206 [list \
207 "PR ld/20828 dynamic symbols with section GC\
15a00b13
MR
208 (auxiliary shared library)" \
209 "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \
210 {pr20828.s} \
211 {{readelf --dyn-syms pr20828-a.sd} \
212 {readelf --dyn-syms pr20828-b.sd}} \
213 "libpr20828.so"] \
81ff47b3
MR
214 [list \
215 "PR ld/20828 dynamic symbols with section GC (plain)" \
15a00b13
MR
216 "$LFLAGS -shared --gc-sections -T pr20828.ld" \
217 "tmpdir/libpr20828.so" "$AFLAGS_PIC" \
218 {pr20828.s} \
219 {{readelf --dyn-syms pr20828-a.sd} \
220 {readelf --dyn-syms pr20828-b.sd}} \
221 "pr20828-1.so"] \
81ff47b3
MR
222 [list \
223 "PR ld/20828 dynamic symbols with section GC (version script)" \
15a00b13
MR
224 "$LFLAGS -shared --gc-sections -T pr20828.ld\
225 --version-script=pr20828.ver" \
226 "tmpdir/libpr20828.so" \
227 "$AFLAGS_PIC" \
228 {pr20828.s} \
229 {{readelf --dyn-syms pr20828-b.sd} \
230 {readelf --dyn-syms pr20828-c.sd}} \
902e9fc7
MR
231 "pr20828-2.so"] \
232 [list \
233 "PR ld/20828 dynamic symbols with section GC\
234 (versioned shared library)" \
235 "$LFLAGS -shared --gc-sections -T pr20828.ld\
236 --version-script=pr20828-v.ver" \
237 "" "$AFLAGS_PIC" \
238 {pr20828.s} \
239 {{readelf --dyn-syms pr20828-c.sd} \
240 {readelf --dyn-syms pr20828-d.sd} \
241 {readelf --dyn-syms pr20828-e.sd}} \
242 "libpr20828-v.so"] \
243 [list \
244 "PR ld/20828 dynamic symbols with section GC (versioned)" \
245 "$LFLAGS -shared --gc-sections -T pr20828.ld\
246 --version-script=pr20828-v.ver" \
247 "tmpdir/libpr20828-v.so" \
248 "$AFLAGS_PIC" \
249 {pr20828.s} \
250 {{readelf --dyn-syms pr20828-c.sd} \
251 {readelf --dyn-syms pr20828-d.sd} \
252 {readelf --dyn-syms pr20828-e.sd}} \
253 "pr20828-v.so"] \
254 [list \
255 "PR ld/20828 forcibly exported symbol version without section GC" \
3c5fce9b 256 "$LFLAGS --no-dynamic-linker -e foo -E -T pr20828-v.ld" "" "" \
902e9fc7
MR
257 {pr20828-v.s} \
258 {{objdump -p pr20828-v.od}} \
259 "pr20828-v-1"] \
260 [list \
261 "PR ld/20828 forcibly exported symbol version with section GC" \
3c5fce9b 262 "$LFLAGS --no-dynamic-linker -e foo --gc-sections -E -T pr20828-v.ld" "" "" \
902e9fc7
MR
263 {pr20828-v.s} \
264 {{objdump -p pr20828-v.od}} \
265 "pr20828-v-2"]]
81ff47b3 266}
80070c0d
MR
267# PR ld/21233 check for correct dynamic symbol table entries where:
268# - a symbol has been defined in a shared library used in the link,
269# - the symbol has been referenced from a section swept in garbage collection,
270# - the symbol has also been forced to be entered in the output file as an
271# undefined symbol, either with a command-line option or a linker script
272# command.
273# Verify that the undefined symbol is global rather than local.
274if { [check_gc_sections_available] } {
275 run_ld_link_tests [list \
276 [list \
277 "PR ld/21233 dynamic symbols with section GC\
278 (auxiliary shared library)" \
279 "$LFLAGS -shared -T pr21233.ld" "" "$AFLAGS_PIC" \
280 {pr21233-l.s} \
281 {{readelf --dyn-syms pr21233-l.sd}} \
4d5efb85 282 "libpr21233.so"]]
6ca30fa5 283
4d5efb85 284 run_ld_link_tests [list \
80070c0d
MR
285 [list \
286 "PR ld/21233 dynamic symbols with section GC (--undefined)" \
287 "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld" \
288 "tmpdir/libpr21233.so" "" \
289 {pr21233.s} \
290 {{readelf --dyn-syms pr21233.sd}} \
6ca30fa5
HPN
291 "pr21233-1"]]
292
6ca30fa5 293 run_ld_link_tests [list \
80070c0d
MR
294 [list \
295 "PR ld/21233 dynamic symbols with section GC (--require-defined)" \
296 "$LFLAGS --gc-sections -e foo --require-defined=bar\
297 -T pr21233.ld" \
298 "tmpdir/libpr21233.so" "" \
299 {pr21233.s} \
300 {{readelf --dyn-syms pr21233.sd}} \
6ca30fa5
HPN
301 "pr21233-2"]]
302
6ca30fa5 303 run_ld_link_tests [list \
80070c0d
MR
304 [list \
305 "PR ld/21233 dynamic symbols with section GC (EXTERN)" \
306 "$LFLAGS --gc-sections -e foo -T pr21233-e.ld" \
307 "tmpdir/libpr21233.so" "" \
308 {pr21233.s} \
309 {{readelf --dyn-syms pr21233.sd}} \
6ca30fa5 310 "pr21233-3"]]
80070c0d 311}
81ff47b3 312
be2b629f
L
313if { [check_gc_sections_available] } {
314 run_ld_link_tests [list \
315 [list \
316 "Build pr22150.so" \
317 "$LFLAGS -shared --version-script pr22150.ver" \
318 "" \
319 "$AFLAGS_PIC" \
320 {pr22150a.s} \
321 {} \
322 "pr22150.so" \
323 ] \
324 [list \
325 "Build pr22150" \
326 "$LFLAGS -e _start --gc-sections" \
327 "tmpdir/pr22150.so" \
328 "" \
329 {pr22150b.s} \
330 {{readelf -V pr22150.vd}} \
331 "pr22150" \
332 ] \
333 ]
334}
335
66824765
AM
336set ASFLAGS $old_ASFLAGS
337
f3a9baf1
MR
338run_ld_link_tests {
339 {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" }
340}
e54d3c94
MR
341run_ld_link_tests [list \
342 [list "Build shared library for pr14170" \
343 "-shared" "" "$AFLAGS_PIC" "pr14170b.s" {} "pr14170.so" ] \
344]
f3a9baf1
MR
345
346# bfin does not currently support copy relocs.
347run_ld_link_tests [list \
348 [list "PR ld/14170" \
8988502d
MR
349 "$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \
350 $hpux \
f3a9baf1
MR
351 {pr14170c.s} { } "pr14170" ] \
352] "bfin-*-*"
353
354# Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests
e54d3c94
MR
355# Not will hppa64 with dot-symbols.
356run_ld_link_tests [list \
357 [list "PR ld/21703 shared" \
358 "-shared --allow-multiple-definition --version-script pr21703.ver\
359 tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "$AFLAGS_PIC" \
360 {pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} \
361 "pr21703.so" ] \
be570f06 362] "d30v-*-*" "dlx-*-*" "pj-*-*" "hppa64-*-*" "xgate-*-*"
f3a9baf1
MR
363
364# This target requires extra GAS options when building non-PIC code
365# for linking with shared libraries.
366set AFLAGS_NONPIC ""
367if [istarget "mips*-*-*"] {
368 append AFLAGS_NONPIC " -call_nonpic"
369}
370
371# Run a test to check linking a shared library with a broken linker
372# script that accidentally marks dynamic sections as notes. The
373# resulting executable is not expected to work, but the linker
374# should not seg-fault whilst creating the binary.
e54d3c94
MR
375run_ld_link_tests [list \
376 [list "Build shared library for broken linker script test" \
377 "-shared --hash-style=sysv" "" "$AFLAGS_PIC" "note-3.s" \
378 {} \
379 "note-3.so" ] \
380 [list "Link using broken linker script" \
381 "$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" "" \
382 { { ld "note-3.l" } } \
383 "a.out" ] \
384]
f3a9baf1 385
e54d3c94
MR
386run_ld_link_tests [list \
387 [list "Build pr17068.so" \
388 "-shared" "" "$AFLAGS_PIC" \
389 {pr17068d.s} {} "pr17068.so"] \
390 [list "Build pr17068a.a" \
391 "" "" "" \
392 {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"] \
393 [list "Build pr17068b.a" \
394 "" "" "" \
395 {pr17068b.s pr17068e.s} {} "pr17068b.a"] \
396]
f3a9baf1
MR
397
398# bfin does not currently support copy relocs.
399run_ld_link_tests {
400 {"pr17068 link --as-needed lib in group"
8988502d
MR
401 "$LFLAGS --as-needed --no-dynamic-linker"
402 "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\
403 --end-group" ""
f3a9baf1
MR
404 {start.s pr17068.s} {} "pr17068"}
405} "bfin-*-*"
406
f3a9baf1
MR
407# Fails on MIPS because ABI trickery means that a NULL reloc is emitted.
408# Fails on bfin because relocations are not created.
e54d3c94
MR
409run_ld_link_tests [list \
410 [list "-Bsymbolic-functions" \
411 "-shared -Bsymbolic-functions" "" "$AFLAGS_PIC" \
412 {symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}} \
413 "symbolic-func.so"] \
414] "mips*-*-*" "bfin-*-*"
f3a9baf1 415
e54d3c94
MR
416run_ld_link_tests [list \
417 [list "Build pr20995.so" \
418 "-shared" "" "$AFLAGS_PIC" \
419 {pr20995b.s} {} "pr20995.so"] \
420]
f3a9baf1
MR
421
422# xfail on arm*-*-eabi*. The list can be enlarged to those targets that
423# don't support GNU_RELRO. For more details, please see discussions at:
424# https://sourceware.org/ml/binutils/2017-01/msg00441.html
e54d3c94
MR
425run_ld_link_tests [list \
426 [list "Build pr20995-2.so" \
427 "-shared -z relro" "" "$AFLAGS_PIC" \
428 {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \
cbac2231 429] "tic6x-*-*" "arm*-*-eabi*" "hppa*64*-*-hpux*" "aarch64*-*-elf*"
f3a9baf1
MR
430
431# These targets don't copy dynamic variables into .bss.
432setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
433# or don't have .data.rel.ro
434setup_xfail "hppa*64*-*-hpux*"
435run_ld_link_tests [list \
436 [list \
437 "pr20995" \
8988502d 438 "$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
f3a9baf1
MR
439 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]]
440
441# xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO.
442# Please see the link above for details.
443setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*"
cbac2231 444setup_xfail "hppa*64*-*-hpux*" "aarch64*-*-elf*"
f3a9baf1
MR
445run_ld_link_tests [list \
446 [list \
447 "pr20995-2" \
8988502d 448 "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
f3a9baf1
MR
449 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]]
450
e54d3c94
MR
451run_ld_link_tests [list \
452 [list "Build pr22374 shared library" \
453 "-shared" "" "$AFLAGS_PIC" "pr22374b.s" {} "pr22374.so" ] \
454]
f3a9baf1
MR
455if { ![istarget "alpha-*-*"]
456 && ![istarget "frv-*-*"]
457 && ![istarget "hppa*-*-*"]
458 && ![istarget "i?86-*-*"]
459 && ![istarget "ia64-*-*"]
460 && ![istarget "microblaze-*-*"]
461 && ![istarget "powerpc*-*-*"]
462 && ![istarget "x86_64-*-*"]
463 && ![istarget "xtensa-*-*"] } {
464 # The next test checks that copy relocs are not used unnecessarily,
465 # but that is just an optimization so don't complain loudly.
466 setup_xfail "*-*-*"
467}
468run_ld_link_tests {
469 {"pr22374 function pointer initialization"
470 "" "tmpdir/pr22374.so" "" "pr22374a.s"
471 { {readelf {--wide -r --dyn-syms} "pr22374-1.r"}
472 {readelf {--wide -r} "pr22374-2.r"} }
473 "pr22374" }
474}
475
476if { [istarget *-*-linux*]
477 || [istarget *-*-nacl*]
478 || [istarget *-*-gnu*] } {
479 run_ld_link_tests {
480 {"Weak symbols in dynamic objects 1 (support)"
481 "-shared" "" "" {weak-dyn-1a.s}
482 {}
483 "libweakdyn1a.so"}
484 {"Weak symbols in dynamic objects 1 (main test)"
485 "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s}
486 {{readelf {--relocs --wide} weak-dyn-1.rd}}
487 "libweakdyn1b.so"}
488 }
489}
490
dd98f8d2 491# Check to see if the C compiler works
d2dee3b2
L
492if { [which $CC] == 0 } {
493 return
494}
495
fb2c6e43 496# Add -ldl to extralibs if needed
d9816402 497set extralibs ""
fb2c6e43
AT
498if { ![istarget *-*-freebsd*]} {
499 set extralibs "-ldl"
500}
501
d2dee3b2
L
502set build_tests {
503 {"Build libfoo.so"
504 "-shared" "-fPIC"
505 {foo.c} {} "libfoo.so"}
506 {"Build versioned libfoo.so"
507 "-shared -Wl,--version-script=foo.map" "-fPIC"
55255dae 508 {foo.c} {} "libfoov.so"}
d2dee3b2
L
509 {"Build libbar.so"
510 "-shared" "-fPIC"
511 {begin.c end.c} {} "libbar.so"}
fab4a87f
L
512 {"Build warn libbar.so"
513 "-shared" "-fPIC"
2bd7f877
AB
514 {beginwarn.c end.c}
515 {{readelf {-S --wide} libbarw.rd}
3239a423 516 {warning "^.*beginwarn.c:7: warning: function foo is deprecated$"}}
2bd7f877 517 "libbarw.so" "c"}
d2dee3b2
L
518 {"Build hidden libbar.so"
519 "-shared" "-fPIC"
520 {begin.c endhidden.c} {} "libbarh.so"}
521 {"Build protected libbar.so"
522 "-shared" "-fPIC"
523 {begin.c endprotected.c} {} "libbarp.so"}
524 {"Build libbar.so with libfoo.so"
525 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
526 {end.c} {} "libbarfoo.so"}
527 {"Build libar.so with versioned libfoo.so"
528 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
529 {end.c} {} "libbarfoov.so"}
530 {"Build hidden libbar.so with libfoo.so"
531 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
532 {endhidden.c} {} "libbarhfoo.so"}
533 {"Build hidden libar.so with versioned libfoo.so"
534 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
535 {endhidden.c} {} "libbarhfoov.so"}
536 {"Build protected libbar.so with libfoo.so"
537 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
538 {endprotected.c} {} "libbarpfoo.so"}
539 {"Build protected libbar.so with versioned libfoo.so"
540 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
541 {endprotected.c} {} "libbarpfoov.so"}
55255dae
L
542 {"Build libdl1.so"
543 "-shared" "-fPIC"
544 {dl1.c} {} "libdl1.so"}
545 {"Build libdl2a.so with --dynamic-list=dl2.list"
546 "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
547 {dl2.c dl2xxx.c} {} "libdl2a.so"}
b7b7fe3f
AS
548 {"Build libdl2a.so with --dynamic-list=dl2a.list"
549 "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC"
550 {dl2.c dl2xxx.c} {} "libdl2a.so"}
40b36307
L
551 {"Build libdl2a.so with --dynamic-list-data"
552 "-shared -Wl,--dynamic-list-data" "-fPIC"
553 {dl2.c dl2xxx.c} {} "libdl2a.so"}
55255dae
L
554 {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
555 "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
556 {dl2.c dl2xxx.c} {} "libdl2b.so"}
d8cf8b51 557 {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
40b36307 558 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
d8cf8b51 559 {dl2.c dl2xxx.c} {} "libdl2c.so"}
c555238b
L
560 {"Build libdl4a.so with --dynamic-list=dl4.list"
561 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
562 {dl4.c dl4xxx.c} {} "libdl4a.so"}
d8cf8b51 563 {"Build libdl4b.so with --dynamic-list-data"
40b36307 564 "-shared -Wl,--dynamic-list-data" "-fPIC"
c555238b 565 {dl4.c dl4xxx.c} {} "libdl4b.so"}
d8cf8b51
L
566 {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list"
567 "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
568 {dl4.c dl4xxx.c} {} "libdl4c.so"}
569 {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list"
40b36307 570 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
d8cf8b51
L
571 {dl4.c dl4xxx.c} {} "libdl4d.so"}
572 {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new"
573 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
574 {dl4.c dl4xxx.c} {} "libdl4e.so"}
575 {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions"
576 "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC"
577 {dl4.c dl4xxx.c} {} "libdl4f.so"}
578 {"Build libdl6a.so"
579 "-shared" "-fPIC"
580 {dl6.c} {} "libdl6a.so"}
581 {"Build libdl6b.so with -Bsymbolic --dynamic-list-data"
582 "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
583 {dl6.c} {} "libdl6b.so"}
584 {"Build libdl6c.so with -Bsymbolic"
585 "-shared -Wl,-Bsymbolic" "-fPIC"
586 {dl6.c} {} "libdl6c.so"}
587 {"Build libdl6d.so with --dynamic-list-data -Bsymbolic"
588 "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC"
589 {dl6.c} {} "libdl6d.so"}
43edfb7f
L
590 {"Build libdata1.so"
591 "-shared" "-fPIC"
592 {data1.c} {} "libdata1.so"}
a47edf27
L
593 {"Build libdata2.so"
594 "-shared" "-fPIC"
595 {data2.c} {} "libdata2.so"}
0a36a439
L
596 {"Build libcomm1.o"
597 "-r -nostdlib" ""
598 {comm1.c} {} "libcomm1.o"}
599 {"Build libfunc1.so"
600 "-shared" "-fPIC"
601 {func1.c} {} "libfunc1.so"}
d8880531
L
602 {"Build libpr9676-1.a"
603 "" "-fPIC"
604 {pr9676-1.c} {} "libpr9676-1.a"}
605 {"Build libpr9676-2.a"
606 "" "-fPIC"
607 {pr9676-2.c} {} "libpr9676-2.a"}
608 {"Build libpr9676-3.so"
609 "-shared" "-fPIC"
610 {pr9676-3.c} {} "libpr9676-3.so"}
611 {"Build libpr9676-4.so"
612 "-shared" "-fPIC"
613 {pr9676-4.c} {} "libpr9676-4.so"}
614 {"Build libpr9676-4a.so"
615 "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group"
616 "-fPIC"
617 {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"}
54ac0771
L
618 {"Build libpr9679.so"
619 "-shared" "-fPIC -O0"
620 {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"}
d023c380
L
621 {"Build libpr11138-1.so"
622 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
623 {pr11138-1.c} {} "libpr11138-1.so"}
624 {"Build libpr11138-2.o"
625 "-r -nostdlib" ""
626 {pr11138-2.c} {} "libpr11138-2.o"}
3e0882af
L
627 {"Build pr13250-1.so"
628 "-shared" "-fPIC"
629 {pr13250-1.c} {} "libpr13250-1.so"}
630 {"Build pr13250-2.so with libpr13250-1.so"
5cb49709 631 "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC"
3e0882af
L
632 {pr13250-2.c} {} "libpr13250-2.so"}
633 {"Build libpr13250-3.o"
634 "-r -nostdlib" ""
635 {pr13250-3.c} {} "libpr13250-3.o"}
bc9ad2e4
L
636 {"Build libpr14323-2.so"
637 "-shared" "-fPIC"
638 {pr14323-2.c} {} "libpr14323-2.so"}
dda8ddc5
L
639 {"Build pr14862-1.o"
640 "-r -nostdlib" ""
641 {pr14862-1.c} {} "libpr14862-1.o"}
642 {"Build libpr14862.so"
643 "-shared -Wl,--version-script=pr11138-1.map" "-fPIC"
644 {pr14862-2.c} {} "libpr14862.so"}
63406f0a
L
645 {"Build libneeded1b.so"
646 "-shared" "-fPIC"
647 {needed1b.c} {} "libneeded1b.so"}
648 {"Build libneeded1a.so"
2eb64a9f 649 "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC"
63406f0a
L
650 {needed1a.c} {} "libneeded1a.so"}
651 {"Build libneeded1c.o"
652 "-r -nostdlib" ""
653 {needed1c.c} {} "libneeded1c.o"}
8fbb09e8
L
654 {"Build libneeded1pic.o"
655 "-r -nostdlib" "-fPIC"
656 {needed1c.c} {} "libneeded1pic.o"}
657 {"Build needed1a.so with --add-needed"
8cfc7cf8 658 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
8fbb09e8
L
659 {dummy.c} {} "needed1a.so"}
660 {"Build needed1b.so with --copy-dt-needed-entries"
8cfc7cf8 661 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" ""
8fbb09e8
L
662 {dummy.c} {} "needed1b.so"}
663 {"Build needed1a.so with --no-add-needed"
8cfc7cf8 664 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" ""
8fbb09e8
L
665 {dummy.c} {} "needed1c.so"}
666 {"Build needed1b.so with --no-copy-dt-needed-entries"
8cfc7cf8 667 "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" ""
8fbb09e8 668 {dummy.c} {} "needed1d.so"}
8877b5e5
AM
669 {"Build librel.so"
670 "-shared" "-fPIC"
671 {rel.c} {} "librel.so"}
5e319dd3
L
672 {"Build libneeded2a.so"
673 "-shared" "-fPIC"
674 {needed2a.c} {} "libneeded2a.so"}
675 {"Build libneeded2b.so"
676 "-shared -Wl,--version-script,needed2.ver" "-fPIC"
677 {needed2b.c} {} "libneeded2b.so"}
678 {"Build libneeded2c.o"
679 "-r -nostdlib" ""
680 {needed2c.c} {} "libneeded2c.o"}
681 {"Build needed2"
682 "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" ""
683 {dummy.c} {} "needed2"}
1240be6b
AM
684 {"Build libneeded3a.so"
685 "-shared -Wl,--no-add-needed" "-fPIC"
686 {needed1a.c} {} "libneeded3a.so"}
687 {"Build libneeded3b.so"
688 "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC"
689 {dummy.c} {} "libneeded3b.so"}
690 {"Build needed3.o"
691 "-r -nostdlib" ""
692 {needed3.c} {} "libneeded3.so"}
693 {"Build needed3"
694 "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" ""
695 {dummy.c} {} "needed3"}
cec2c50d
L
696 {"Build libpr2404a.so"
697 "-shared" "-fPIC"
698 {pr2404a.c} {} "libpr2404a.so"}
d6f48aed
L
699 {"Build libpr2404n.so"
700 "-shared -Wl,-z,now" "-fPIC"
701 {pr2404a.c} {} "libpr2404n.so"}
cec2c50d
L
702 {"Build libpr2404b.a"
703 "" ""
704 {pr2404b.c} {} "libpr2404b.a"}
50a53d3f 705 {"Build rdynamic-1"
8569cfa7 706 "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections"
50a53d3f 707 {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"}
d6f6f455 708 {"Build dynamic-1"
8569cfa7 709 "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections"
d6f6f455 710 {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"}
bb4d2ac2
L
711 {"Build libpr16496a.so"
712 "-shared -Wl,--version-script=pr16496a.map" "-fPIC"
713 {pr16496a.c} {} "libpr16496a.so"}
714 {"Build libpr16496b.a"
715 "" "-fPIC"
716 {pr16496b.c} {} "libpr16496b.a"}
717 {"Build libpr16496b.so"
8cfc7cf8 718 "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" ""
bb4d2ac2 719 {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"}
fb389763
L
720 {"Build libpr16452a.so"
721 "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC"
722 {pr16452a.c} {} "libpr16452a.so"}
723 {"Build libpr16452b.so"
724 "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC"
725 {dummy.c} {} "libpr16452b.so"}
726 {"Build pr16452"
8cfc7cf8 727 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
fb389763
L
728 {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"}
729 {"Build pr16457"
8cfc7cf8 730 "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" ""
fb389763 731 {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"}
8ded2ddc
L
732 {"Build libpr18458a.so"
733 "-shared -Wl,-z,now" "-fPIC"
734 {pr18458a.c} {} "libpr18458a.so"}
735 {"Build libpr18458b.so"
736 "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC"
737 {pr18458b.c} {} "libpr18458b.so"}
4373f8af
L
738 {"Build pr19073a.o"
739 "-r -nostdlib" ""
740 {pr19073.s} {} "pr19073a.o"}
741 {"Build libpr19073.so"
742 "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC"
743 {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"}
8dfb7cbf 744 {"Build pr21964-1a.so"
487b6440 745 "-shared" "-fPIC"
8dfb7cbf
L
746 {pr21964-1a.c} {} "pr21964-1a.so"}
747 {"Build pr21964-1b.so"
487b6440 748 "-shared" "-fPIC"
8dfb7cbf
L
749 {pr21964-1b.c} {} "pr21964-1b.so"}
750 {"Build pr21964-2a.so"
751 "-shared" "-fPIC"
752 {pr21964-2a.c} {} "pr21964-2a.so"}
753 {"Build pr21964-2b.so"
754 "-shared" "-fPIC"
755 {pr21964-2b.c} {} "pr21964-2b.so"}
36b8fda5
AM
756 {"Build pr21964-3a.so"
757 "-shared" "-fPIC"
758 {pr21964-3a.c} {} "pr21964-3a.so"}
2715765b
L
759 {"Dump pr21978.so"
760 "-shared" "-fPIC -g -O2"
761 {pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"}
d2dee3b2
L
762}
763
dd98f8d2
NC
764run_cc_link_tests $build_tests
765
f3012016
L
766run_ld_link_tests [list \
767 [list \
768 "Build pr22269-1" \
769 "-pie -e _start --no-dynamic-linker -z text" \
770 "" \
185cdb8c 771 "$AFLAGS_PIC" \
f3012016
L
772 { pr22269-1.c } \
773 {{readelf -rW pr22269-1.rd}} \
774 "pr22269-1" \
775 "-fPIE -O2" \
776 ] \
777]
778
d9816402
AM
779set run_tests [list \
780 [list "Run normal with libfoo.so" \
781 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \
782 {main.c} "normal" "normal.out" ] \
783 [list "Run protected with libfoo.so" \
784 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \
785 {main.c} "protected" "normal.out" ] \
786 [list "Run hidden with libfoo.so" \
787 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \
788 {main.c} "hidden" "hidden.out" ] \
789 [list "Run normal with versioned libfoo.so" \
790 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \
791 {main.c} "normalv" "normal.out" ] \
792 [list "Run warn with versioned libfoo.so" \
793 "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \
794 {main.c} "warn" "warn.out" \
3239a423 795 "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated$} ] \
d9816402
AM
796 [list "Run protected with versioned libfoo.so" \
797 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \
798 {main.c} "protected" "normal.out" ] \
799 [list "Run hidden with versioned libfoo.so" \
800 "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \
801 {main.c} "hiddenv" "hidden.out" ] \
802 [list "Run normal libbar.so with libfoo.so" \
803 "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \
804 {main.c} "normal" "normal.out" ] \
805 [list "Run protected libbar.so with libfoo.so" \
806 "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \
807 {main.c} "protected" "normal.out" ] \
808 [list "Run hidden libbar.so with libfoo.so" \
809 "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \
810 {main.c} "hidden" "hidden.out" ] \
811 [list "Run normal libbar.so with versioned libfoo.so" \
812 "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \
813 {main.c} "normal" "normal.out" ] \
814 [list "Run protected libbar.so with versioned libfoo.so" \
815 "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \
816 {main.c} "protected" "normal.out" ] \
817 [list "Run hidden libbar.so with versioned libfoo.so" \
818 "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \
819 {main.c} "hidden" "hidden.out" ] \
d9816402
AM
820 [list "Run with libdl2a.so" \
821 "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \
822 {dl2main.c} "dl2a" "dl2a.out" ] \
823 [list "Run with libdl2b.so" \
824 "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \
825 {dl2main.c} "dl2b" "dl2b.out" ] \
826 [list "Run with libdl2c.so" \
827 "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \
828 {dl2main.c} "dl2c" "dl2b.out" ] \
829 [list "Run with libdl4a.so" \
830 "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \
831 {dl4main.c} "dl4a" "dl4a.out" ] \
832 [list "Run with libdl4b.so" \
833 "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \
834 {dl4main.c} "dl4b" "dl4a.out" ] \
835 [list "Run with libdl4c.so" \
836 "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \
837 {dl4main.c} "dl4c" "dl4b.out" ] \
838 [list "Run with libdl4d.so" \
839 "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \
840 {dl4main.c} "dl4d" "dl4b.out" ] \
841 [list "Run with libdl4e.so" \
842 "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \
843 {dl4main.c} "dl4e" "dl4a.out" ] \
844 [list "Run with libdl4f.so" \
845 "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \
846 {dl4main.c} "dl4f" "dl4a.out" ] \
d9816402
AM
847 [list "Run with libdata1.so" \
848 "-Wl,--no-as-needed tmpdir/libdata1.so" "" \
849 {dynbss1.c} "dynbss1" "pass.out" ] \
850 [list "Run with libdata2.so" \
851 "-Wl,--no-as-needed tmpdir/libdata2.so" "" \
852 {weakdef1.c} "weakdef1" "pass.out" ] \
853 [list "Run with libfunc1.so comm1.o" \
854 "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \
855 {dummy.c} "comm1" "pass.out" ] \
856 [list "Run with comm1.o libfunc1.so" \
857 "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \
858 {dummy.c} "comm1" "pass.out" ] \
859 [list "Run with pr11138-2.c libpr11138-1.so" \
860 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \
861 {dummy.c} "pr11138a" "pr11138.out" ] \
862 [list "Run with libpr11138-1.so pr11138-2.c" \
863 "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \
864 {dummy.c} "pr11138b" "pr11138.out" ] \
865 [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \
866 "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" \
867 {dummy.c} "pr13250" "pass.out" ] \
868 [list "Run with pr14323-1.c pr14323-2.so" \
869 "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \
870 {pr14323-1.c} "pr14323" "pass.out" ] \
871 [list "Run with pr14862-1.c libpr14862.so" \
872 "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \
873 {dummy.c} "pr14862" "pr14862.out" ] \
874 [list "Link with --add-needed" \
8cfc7cf8 875 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
d9816402
AM
876 {dummy.c} "needed1a" "needed1.out" ] \
877 [list "Link with --copy-dt-needed-entries" \
8cfc7cf8 878 "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \
d9816402
AM
879 {dummy.c} "needed1b" "needed1.out" ] \
880 [list "Run relmain" \
881 "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \
882 {relmain.c} "relmain" "relmain.out" ] \
883 [list "Run pr2404" \
884 "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \
885 {dummy.c} "pr2404" "pr2404.out" ] \
d6f48aed
L
886 [list "Run pr2404n" \
887 "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \
888 {dummy.c} "pr2404n" "pr2404.out" ] \
d9816402
AM
889 [list "Run pr18458" \
890 "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \
891 {pr18458c.c} "pr18458" "pass.out" ] \
487b6440 892 [list "Run pr21964-1" \
8dfb7cbf
L
893 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \
894 {pr21964-1c.c} "pr21964-1" "pass.out" ] \
36b8fda5
AM
895 [list "Run pr21964-3" \
896 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \
897 {pr21964-3c.c} "pr21964-3" "pass.out" ] \
d9816402 898]
d2dee3b2 899
d2dee3b2 900# NetBSD ELF systems do not currently support the .*_array sections.
982c6f26 901run_ld_link_exec_tests $run_tests "*-*-netbsdelf*"
55255dae 902
fd121c5c
JW
903# These tests require dlopen support.
904set dlopen_run_tests [list \
905 [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \
906 "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \
907 {dl1main.c} "dl1a" "dl1.out" ] \
908 [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \
909 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
910 {dl1main.c} "dl1b" "dl1.out" ] \
911 [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \
912 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
913 {dl6amain.c} "dl6a1" "dl6a.out" ] \
914 [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \
6b737370
L
915 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \
916 {dl6amain.c} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \
fd121c5c
JW
917 [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \
918 "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \
919 {dl6amain.c} "dl6a3" "dl6b.out" ] \
920 [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \
921 "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \
922 {dl6amain.c} "dl6a4" "dl6a.out" ] \
923 [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \
6b737370
L
924 "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \
925 {dl6amain.c} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \
fd121c5c 926 [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \
6b737370
L
927 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \
928 {dl6amain.c} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \
fd121c5c 929 [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \
6b737370
L
930 "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \
931 {dl6amain.c} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \
fd121c5c
JW
932 [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \
933 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
934 {dl6bmain.c} "dl6b1" "dl6a.out" ] \
935 [list "Run dl6b2 with dlopen on libdl6b.so" \
936 "-Wl,--no-as-needed $extralibs" "" \
937 {dl6bmain.c} "dl6b2" "dl6b.out" ] \
938 [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \
939 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
940 {dl6cmain.c} "dl6c1" "dl6b.out" ] \
941 [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \
942 "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \
943 {dl6dmain.c} "dl6d1" "dl6b.out" ] \
487b6440 944 [list "Run pr21964-2" \
8dfb7cbf
L
945 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \
946 {pr21964-2c.c} "pr21964-2" "pass.out" ] \
bf3077a6
MM
947 [list "Run pr21964-5" \
948 "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \
949 {pr21964-5.c} "pr21964-5" "pass.out" ] \
fd121c5c
JW
950]
951
952# Only run them when libdl is available.
953if [check_libdl_available] {
954 # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
955 # sections.
956 run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*"
957}
958
63406f0a
L
959# Check --no-add-needed and --no-copy-dt-needed-entries
960set testname "--no-add-needed"
f1d7f4a6 961set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
e65cb106 962if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
63406f0a
L
963 pass $testname
964} {
965 fail $testname
966}
967set testname "--no-copy-dt-needed-entries"
f1d7f4a6 968set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
e65cb106 969if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
63406f0a
L
970 pass $testname
971} {
972 fail $testname
973}
8fbb09e8 974set testname "--no-add-needed -shared"
f1d7f4a6 975set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"]
4e95fbcd 976if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
8fbb09e8
L
977 pass $testname
978} {
979 fail $testname
980}
981set testname "--no-copy-dt-needed-entries -shared"
f1d7f4a6 982set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"]
4e95fbcd 983if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
8fbb09e8
L
984 pass $testname
985} {
986 fail $testname
987}
63406f0a 988
dd98f8d2 989# Check to see if the C++ compiler works
55255dae
L
990if { [which $CXX] == 0 } {
991 return
992}
993
994set build_cxx_tests {
995 {"Build libdl3a.so with --dynamic-list=dl3.list"
996 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
997 {dl3.cc} {} "libdl3a.so" "c++"}
998 {"Build libdl3b.so with -Bsymbolic"
999 "-shared -Wl,-Bsymbolic" "-fPIC"
1000 {dl3.cc} {} "libdl3b.so" "c++"}
1001 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
1002 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
1003 {dl3.cc} {} "libdl3c.so" "c++"}
d8cf8b51 1004 {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
199add01 1005 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi"
d8cf8b51
L
1006 {del.cc new.cc} {} "libnew1a.so" "c++"}
1007 {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
199add01 1008 "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi"
d8cf8b51 1009 {del.cc new.cc} {} "libnew1b.so" "c++"}
55255dae
L
1010}
1011
b37470e4
L
1012# "-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
1013# {"Run with libdl3b.so"
1014# "tmpdir/libdl3b.so" ""
1015# {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
cb5ab6c8
L
1016set run_cxx_tests {
1017 {"Run with libdl3a.so"
1018 "-Wl,--no-as-needed tmpdir/libdl3a.so" ""
1019 {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
55255dae 1020 {"Run with libdl3c.so"
5cb49709 1021 "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
55255dae 1022 {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
d8cf8b51 1023 {"Run with libnew1a.so"
d9816402 1024 "-Wl,--no-as-needed tmpdir/libnew1a.so" ""
199add01 1025 {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"}
d8cf8b51 1026 {"Run with libnew1b.so"
d9816402 1027 "-Wl,--no-as-needed tmpdir/libnew1b.so" ""
199add01 1028 {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"}
55255dae
L
1029}
1030
1031run_cc_link_tests $build_cxx_tests
982c6f26 1032run_ld_link_exec_tests $run_cxx_tests
22ef172a
L
1033
1034if { [istarget *-*-linux*]
1035 || [istarget *-*-nacl*]
1036 || [istarget *-*-gnu*] } {
1037 run_cc_link_tests [list \
1038 [list \
1039 "Build libpr2404b.a with PIE" \
1040 "" \
1041 "-fPIE" \
1042 { pr2404b.c } \
1043 {} \
1044 "libpr2404b.a" \
1045 ] \
07492f66
L
1046 [list \
1047 "Build pr19579a.o" \
1048 "" "-fPIE" \
1049 {pr19579a.c} \
1050 {} \
1051 "libpr19579a.a" \
1052 ] \
1053 [list \
1054 "Build libpr19579.so" \
1055 "-shared" \
1056 "-fPIC" \
1057 {pr19579b.c} \
1058 {} \
1059 "libpr19579.so" \
1060 ] \
d6f48aed
L
1061 [list \
1062 "Build libpr19579now.so" \
1063 "-shared -Wl,-z,now" \
1064 "-fPIC" \
1065 {pr19579b.c} \
1066 {} \
1067 "libpr19579.so" \
1068 ] \
d346bb27
L
1069 [list \
1070 "Build pr22393-2a.so" \
1071 "-shared -Wl,-z,separate-code" \
1072 "-fPIC" \
1073 {pr22393-2a.c} \
1074 {{readelf -lW pr22393-2a.rd} \
1075 {readelf -lW pr22393-2b.rd}} \
1076 "pr22393-2a.so" \
1077 ] \
1078 [list \
1079 "Build pr22393-2a-now.so" \
1080 "-shared -Wl,-z,separate-code,-z,now" \
1081 "-fPIC" \
1082 {pr22393-2a.c} \
1083 {{readelf -lW pr22393-2a.rd} \
1084 {readelf -lW pr22393-2b.rd}} \
1085 "pr22393-2a-now.so" \
1086 ] \
1087 [list \
1088 "Build pr22393-2" \
1089 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
1090 "$NOPIE_CFLAGS" \
1091 {pr22393-2b.c} \
1092 {{readelf -lW pr22393-2a.rd} \
1093 {readelf -lW pr22393-2b.rd}} \
1094 "pr22393-2" \
1095 ] \
1096 [list \
1097 "Build pr22393-2 (PIE)" \
1098 "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
1099 "-fPIE" \
1100 {pr22393-2b.c} \
1101 {{readelf -lW pr22393-2a.rd} \
1102 {readelf -lW pr22393-2b.rd}} \
1103 "pr22393-2-pie" \
1104 ] \
1105 [list \
1106 "Build pr22393-2 (static)" \
1107 "-static -Wl,-z,separate-code" \
1108 "" \
1109 {pr22393-2a.c pr22393-2b.c} \
1110 {{readelf -lW pr22393-2a.rd} \
1111 {readelf -lW pr22393-2b.rd}} \
1112 "pr22393-2-static" \
1113 ] \
22ef172a 1114 ]
982c6f26 1115 run_ld_link_exec_tests [list \
d6f48aed
L
1116 [list \
1117 "Run pr18458 with PIE" \
1118 "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \
1119 "" \
1120 {pr18458c.c} \
1121 "pr18458p" \
1122 "pass.out" \
1123 "-fPIE" \
1124 ] \
22ef172a
L
1125 [list \
1126 "Run pr2404 with PIE" \
d9816402 1127 "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \
22ef172a
L
1128 "" \
1129 { dummy.c } \
1130 "pr2404pie" \
1131 "pr2404.out" \
1132 "-fPIE" \
1133 ] \
d6f48aed
L
1134 [list \
1135 "Run pr2404 with PIE (-z now)" \
1136 "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \
1137 "" \
1138 { dummy.c } \
1139 "pr2404pien" \
1140 "pr2404.out" \
1141 "-fPIE" \
1142 ] \
1659f720
L
1143 [list \
1144 "Run pr18718" \
1145 "" \
1146 "" \
c45bd4fd 1147 { pr18718.c check-ptr-eq.c } \
1659f720
L
1148 "pr18718" \
1149 "pass.out" \
edcab5e8 1150 "-O2 -I../bfd" \
1659f720 1151 ] \
d6f48aed
L
1152 [list \
1153 "Run pr18718 (-z now)" \
1154 "-Wl,-z,now" \
1155 "" \
1156 { pr18718.c check-ptr-eq.c } \
1157 "pr18718" \
1158 "pass.out" \
1159 "-O2 -I../bfd" \
1160 ] \
1659f720
L
1161 [list \
1162 "Run pr18718 with PIE (1)" \
1163 "-pie" \
1164 "" \
c45bd4fd 1165 { pr18718.c check-ptr-eq.c } \
1659f720
L
1166 "pr18718pie1" \
1167 "pass.out" \
edcab5e8 1168 "-O2 -fPIE -I../bfd" \
1659f720
L
1169 ] \
1170 [list \
1171 "Run pr18718 with PIE (2)" \
1172 "" \
1173 "" \
c45bd4fd 1174 { pr18718.c check-ptr-eq.c } \
1659f720
L
1175 "pr18718pie2" \
1176 "pass.out" \
edcab5e8 1177 "-O2 -fPIE -I../bfd" \
1659f720 1178 ] \
d6f48aed
L
1179 [list \
1180 "Run pr18718 with PIE (3)" \
1181 "-pie -Wl,-z,now" \
1182 "" \
1183 { pr18718.c check-ptr-eq.c } \
1184 "pr18718pie3" \
1185 "pass.out" \
1186 "-O2 -fPIE -I../bfd" \
1187 ] \
1188 [list \
1189 "Run pr18718 with PIE (4)" \
1190 "-Wl,-z,now" \
1191 "" \
1192 { pr18718.c check-ptr-eq.c } \
1193 "pr18718pie4" \
1194 "pass.out" \
1195 "-O2 -fPIE -I../bfd" \
1196 ] \
1659f720
L
1197 [list \
1198 "Run pr18718 with PIC (1)" \
1199 "" \
1200 "" \
c45bd4fd 1201 { pr18718.c check-ptr-eq.c } \
1659f720
L
1202 "pr18718pic1" \
1203 "pass.out" \
edcab5e8 1204 "-O2 -fPIC -I../bfd" \
1659f720
L
1205 ] \
1206 [list \
1207 "Run pr18718 with PIC (2)" \
1208 "-pie" \
1209 "" \
c45bd4fd 1210 { pr18718.c check-ptr-eq.c } \
1659f720
L
1211 "pr18718pic2" \
1212 "pass.out" \
edcab5e8 1213 "-O2 -fPIC -I../bfd" \
1659f720 1214 ] \
d6f48aed
L
1215 [list \
1216 "Run pr18718 with PIC (3)" \
1217 "-Wl,-z,now" \
1218 "" \
1219 { pr18718.c check-ptr-eq.c } \
1220 "pr18718pic3" \
1221 "pass.out" \
1222 "-O2 -fPIC -I../bfd" \
1223 ] \
1224 [list \
1225 "Run pr18718 with PIC (4)" \
1226 "-pie -Wl,-z,now" \
1227 "" \
1228 { pr18718.c check-ptr-eq.c } \
1229 "pr18718pic4" \
1230 "pass.out" \
1231 "-O2 -fPIC -I../bfd" \
1232 ] \
07492f66
L
1233 [list \
1234 "Run pr19579" \
d9816402 1235 "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
07492f66
L
1236 "" \
1237 {dummy.c} \
1238 "pr19579" \
1239 "pass.out" \
1240 "-fPIE" \
1241 ] \
d6f48aed
L
1242 [list \
1243 "Run pr19579 (-z now)" \
1244 "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \
1245 "" \
1246 {dummy.c} \
1247 "pr19579n" \
1248 "pass.out" \
1249 "-fPIE" \
1250 ] \
d346bb27
L
1251 [list \
1252 "Run pr22393-2" \
1253 "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \
1254 "" \
1255 {pr22393-2b.c} \
1256 "pr22393-2" \
1257 "pass.out" \
1258 "$NOPIE_CFLAGS" \
1259 ] \
1260 [list \
1261 "Run pr22393-2 (PIE)" \
1262 "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \
1263 "" \
1264 {pr22393-2b.c} \
1265 "pr22393-2-pie" \
1266 "pass.out" \
1267 "-fPIE" \
1268 ] \
1269 [list \
1270 "Run pr22393-2 (static)" \
1271 "-static -Wl,-z,separate-code" \
1272 "" \
1273 {pr22393-2a.c pr22393-2b.c} \
1274 "pr22393-2-static" \
1275 "pass.out" \
1276 ] \
823143c6
L
1277 [list \
1278 "Run pr21964-4" \
1279 "" \
1280 "" \
1281 {pr21964-4.c} \
1282 "pr21964-4" \
1283 "pass.out" \
1284 "" \
1285 "" \
1286 "" \
1287 "-ldl" \
1288 ] \
22ef172a
L
1289 ]
1290}
aec6b87e 1291
f1b2ca70 1292proc mix_pic_and_non_pic {xfails cflags ldflags exe} {
aec6b87e
L
1293 run_cc_link_tests [list \
1294 [list \
1295 "Build libpr19719a.so" \
1296 "-shared -Wl,-soname,libpr19719.so" \
1297 "-fPIC" \
1298 { pr19719d.c } \
1299 {} \
1300 "libpr19719a.so" \
1301 ] \
1302 [list \
1303 "Build libpr19719b.so" \
1304 "-shared -Wl,-soname,libpr19719.so" \
1305 "-fPIC" \
1306 { dummy.c } \
1307 {} \
1308 "libpr19719b.so" \
1309 ] \
1310 [list \
f1b2ca70 1311 "Build libpr19719b.o" \
aec6b87e
L
1312 "-r -nostdlib" \
1313 "-fPIC" \
1314 { pr19719b.c } \
1315 {} \
1316 "libpr19719b.o" \
1317 ] \
1318 ]
1319
f1b2ca70 1320 send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n"
aec6b87e
L
1321 exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so
1322
982c6f26 1323 run_ld_link_exec_tests [list \
aec6b87e 1324 [list \
f1b2ca70 1325 "Run $exe fun defined" \
d9816402 1326 "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \
aec6b87e
L
1327 "" \
1328 { pr19719a.c pr19719c.c } \
f1b2ca70 1329 $exe \
aec6b87e
L
1330 "pass.out" \
1331 "$cflags" \
1332 ] \
1333 ]
1334
f1b2ca70 1335 send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n"
aec6b87e
L
1336 exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so
1337
7494161b
L
1338 foreach targ $xfails {
1339 setup_xfail $targ
1340 }
1341
d9816402
AM
1342 if ![isnative] {
1343 unsupported "Run $exe fun undefined"
1344 return
1345 }
1346
f1b2ca70 1347 set exec_output [run_host_cmd "tmpdir/$exe" ""]
aec6b87e 1348 if {![string match "PASS" $exec_output]} {
f1b2ca70 1349 fail "Run $exe fun undefined"
aec6b87e 1350 } else {
f1b2ca70 1351 pass "Run $exe fun undefined"
aec6b87e
L
1352 }
1353}
1354
f1b2ca70
AM
1355mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719"
1356mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie"
9bc935ef 1357
7f923b7f
AM
1358set AFLAGS_PIE ""
1359if { [istarget "i?86-*-*"]
1360 || [istarget "x86_64-*-*"] } {
1361 set AFLAGS_PIE "-mrelax-relocations=yes"
1362}
1363
1364if { ([istarget "*-*-linux*"]
1365 || [istarget "*-*-nacl*"]
1366 || [istarget "*-*-gnu*"])
1367 && ![istarget "mips*-*-*"] } {
9bc935ef
L
1368 run_ld_link_tests [list \
1369 [list \
1370 "Build libpr23162a.so" \
1371 "-shared" \
1372 "" \
1373 "$AFLAGS_PIC" \
1374 { pr23162a.c } \
1375 "" \
1376 "libpr23162a.so" \
1377 "-fPIC -O2" \
1378 ] \
1379 [list \
1380 "Build pr23162a" \
1381 "-pie --no-as-needed tmpdir/libpr23162a.so" \
1382 "" \
7f923b7f 1383 $AFLAGS_PIE \
9bc935ef 1384 { pr23162b.c } \
7f923b7f 1385 {{readelf {-rW} pr23162.rd}} \
9bc935ef
L
1386 "pr23162a" \
1387 "-fPIC -O0" \
1388 ] \
1389 [list \
1390 "Build libpr23162b.so" \
1391 "-shared --version-script=pr23162.map" \
1392 "" \
1393 "$AFLAGS_PIC" \
1394 { pr23162a.c } \
1395 "" \
1396 "libpr23162b.so" \
1397 "-fPIC -O2" \
1398 ] \
1399 [list \
1400 "Build pr23162b" \
1401 "-pie --no-as-needed tmpdir/libpr23162b.so" \
1402 "" \
7f923b7f 1403 $AFLAGS_PIE \
9bc935ef 1404 { pr23162b.c } \
7f923b7f 1405 {{readelf {-rW} pr23162.rd}} \
9bc935ef
L
1406 "pr23162b" \
1407 "-fPIC -O0" \
1408 ] \
fd161d86
AM
1409 [list \
1410 "Build libpr23161a.so" \
1411 "-shared" \
1412 "" \
1413 "$AFLAGS_PIC" \
1414 { pr23161a.c } \
1415 {{readelf {--dyn-syms -rW} pr23161a.rd}} \
1416 "libpr23161a.so" \
1417 "-fPIC -O2" \
1418 ] \
1419 [list \
1420 "Build pr23161a" \
1421 "-pie --no-as-needed tmpdir/libpr23161a.so" \
1422 "" \
7f923b7f 1423 $AFLAGS_PIE \
fd161d86
AM
1424 { pr23161b.c } \
1425 {{readelf {--dyn-syms -rW} pr23161b.rd}} \
1426 "pr23161a" \
1427 "-fPIC -O0" \
1428 ] \
1429 [list \
1430 "Build libpr23161b.so" \
1431 "-shared --version-script=pr23161.map" \
1432 "" \
1433 "$AFLAGS_PIC" \
1434 { pr23161a.c } \
1435 {{readelf {--dyn-syms -rW} pr23161a.rd}} \
1436 "libpr23161b.so" \
1437 "-fPIC -O2" \
1438 ] \
1439 [list \
1440 "Build pr23161b" \
1441 "-pie --no-as-needed tmpdir/libpr23161b.so" \
1442 "" \
7f923b7f 1443 $AFLAGS_PIE \
fd161d86
AM
1444 { pr23161b.c } \
1445 {{readelf {--dyn-syms -rW} pr23161b.rd}} \
1446 "pr23161b" \
1447 "-fPIC -O0" \
1448 ] \
7f923b7f
AM
1449 ]
1450}
1451
1452if { [istarget "i?86-*-*"]
1453 || [istarget "x86_64-*-*"] } {
1454 run_ld_link_tests [list \
fd161d86
AM
1455 [list \
1456 "Build libpr23161c.so" \
1457 "-shared" \
1458 "" \
1459 "$AFLAGS_PIC" \
1460 { pr23161c.c } \
1461 {{readelf {--dyn-syms -rW} pr23161c.rd}} \
1462 "libpr23161c.so" \
1463 "-fPIC -O2" \
1464 ] \
1465 [list \
1466 "Build pr23161c" \
1467 "-pie --no-as-needed tmpdir/libpr23161c.so" \
1468 "" \
7f923b7f 1469 $AFLAGS_PIE \
fd161d86
AM
1470 { pr23161b.c } \
1471 {{readelf {--dyn-syms -rW} pr23161d.rd}} \
1472 "pr23161c" \
1473 "-fPIC -O0" \
1474 ] \
9bc935ef
L
1475 ]
1476}