Commit | Line | Data |
---|---|---|
d2dee3b2 | 1 | # Expect script for various ELF tests. |
250d07de | 2 | # Copyright (C) 2006-2021 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 | ||
24 | if ![is_elf_format] { | |
25 | return | |
26 | } | |
27 | ||
47523653 AM |
28 | # Skip targets where -shared is not supported |
29 | ||
30 | if ![check_shared_lib_support] { | |
31 | return | |
32 | } | |
33 | ||
66824765 AM |
34 | set old_ASFLAGS $ASFLAGS |
35 | ||
81ff47b3 MR |
36 | # This target requires extra GAS options when building code for shared |
37 | # libraries. | |
38 | set AFLAGS_PIC "" | |
18e404c4 AM |
39 | if [istarget "nds32*-*"] { |
40 | append AFLAGS_PIC " -mpic" | |
41 | } | |
81ff47b3 MR |
42 | if [istarget "tic6x-*-*"] { |
43 | append AFLAGS_PIC " -mpic -mpid=near" | |
44 | } | |
185cdb8c | 45 | if [istarget "sparc*-*-*"] { |
ae4b1d73 | 46 | append AFLAGS_PIC " -K PIC -Av9" |
185cdb8c EB |
47 | } |
48 | ||
fb9bbfd7 L |
49 | # GAS options to disable program property note. |
50 | set AFLAGS_NOTE "" | |
51 | if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } { | |
52 | append AFLAGS_NOTE "-mx86-used-note=no" | |
53 | } | |
54 | ||
81ff47b3 MR |
55 | # This target requires a non-default emulation for successful shared |
56 | # library/executable builds. | |
57 | set LFLAGS "" | |
58 | if [istarget "tic6x-*-*"] { | |
59 | append LFLAGS " -melf32_tic6x_le" | |
60 | } | |
f3a9baf1 MR |
61 | # HPUX targets use a different .comm syntax. |
62 | set hpux "" | |
63 | if [istarget "*-*-hpux*"] { | |
64 | set hpux "--defsym HPUX=1" | |
65 | } | |
8988502d MR |
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" | |
71 | } | |
81ff47b3 | 72 | |
08f650e6 | 73 | if [is_underscore_target] { |
4018f4e0 | 74 | append ASFLAGS " --defsym UNDERSCORE=1" |
08f650e6 L |
75 | } |
76 | ||
77 | run_ld_link_tests [list \ | |
78 | [list \ | |
79 | "Build pr22471a.so" \ | |
80 | "$LFLAGS -shared" \ | |
81 | "" \ | |
82 | "$AFLAGS_PIC" \ | |
83 | {pr22471a.s} \ | |
84 | {} \ | |
85 | "pr22471a.so" \ | |
86 | ] \ | |
87 | [list \ | |
88 | "Build pr22471b.so" \ | |
89 | "$LFLAGS -shared --version-script pr22471.t" \ | |
90 | "tmpdir/pr22471a.so" \ | |
91 | "$AFLAGS_PIC" \ | |
92 | {pr22471a.s} \ | |
93 | {} \ | |
94 | "pr22471b.so" \ | |
95 | ] \ | |
d664fd41 L |
96 | [list \ |
97 | "Build pr22649-1.so" \ | |
98 | "$LFLAGS -shared" \ | |
99 | "" \ | |
100 | "$AFLAGS_PIC" \ | |
101 | {pr22649-1.s} \ | |
102 | {} \ | |
103 | "pr22649-1.so" \ | |
104 | ] \ | |
08f650e6 L |
105 | ] |
106 | ||
4018f4e0 AM |
107 | run_ld_link_tests [list \ |
108 | [list \ | |
109 | "Build pr22471" \ | |
110 | "$LFLAGS -rpath-link . -rpath-link tmpdir" \ | |
111 | "tmpdir/pr22471b.so" \ | |
112 | "" \ | |
113 | {pr22471b.s} \ | |
114 | {} \ | |
115 | "pr22471" \ | |
116 | ] \ | |
117 | ] bfin-*-* frv-*-* lm32-*-* | |
118 | ||
87e79a65 | 119 | if { [check_gc_sections_available] } { |
af667f22 MR |
120 | if [istarget mips*-*-*] { |
121 | set actions {{ld pr22649-2ab-mips.msg}} | |
122 | } else { | |
123 | set actions {{ld pr22649.msg}} | |
124 | } | |
87e79a65 AM |
125 | run_ld_link_tests [list \ |
126 | [list \ | |
127 | "Build pr22649-2a.so" \ | |
128 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
129 | "" \ | |
130 | "$AFLAGS_PIC" \ | |
131 | {pr22649-2a.s} \ | |
af667f22 | 132 | $actions \ |
87e79a65 AM |
133 | "pr22649-2a.so" \ |
134 | ] \ | |
135 | [list \ | |
136 | "Build pr22649-2b.so" \ | |
137 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
138 | "tmpdir/pr22649-1.so" \ | |
139 | "$AFLAGS_PIC" \ | |
140 | {pr22649-2a.s} \ | |
af667f22 | 141 | $actions \ |
87e79a65 AM |
142 | "pr22649-2b.so" \ |
143 | ] \ | |
af667f22 MR |
144 | ] |
145 | if { [istarget mips*-*-*] && ![istarget *-*-elf*] } { | |
146 | set actions {{ld pr22649-2cd-mips.msg}} | |
147 | } else { | |
148 | set actions {} | |
149 | } | |
150 | run_ld_link_tests [list \ | |
87e79a65 AM |
151 | [list \ |
152 | "Build pr22649-2c.so" \ | |
153 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
154 | "" \ | |
155 | "$AFLAGS_PIC" \ | |
156 | {pr22649-2b.s} \ | |
af667f22 | 157 | $actions \ |
87e79a65 AM |
158 | "pr22649-2b.so" \ |
159 | ] \ | |
160 | [list \ | |
161 | "Build pr22649-2d.so" \ | |
162 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
163 | "tmpdir/pr22649-1.so" \ | |
164 | "$AFLAGS_PIC" \ | |
165 | {pr22649-2b.s} \ | |
af667f22 | 166 | $actions \ |
87e79a65 AM |
167 | "pr22649-2b.so" \ |
168 | ] \ | |
169 | ] | |
170 | } | |
171 | ||
63c1f59d AM |
172 | run_ld_link_tests [list \ |
173 | [list \ | |
174 | "DT_TEXTREL in shared lib" \ | |
175 | "$LFLAGS -shared --warn-shared-textrel" \ | |
176 | "" \ | |
177 | "$AFLAGS_PIC" \ | |
178 | {textrel.s} \ | |
179 | {{ld textrel.warn} \ | |
180 | {readelf {-d --wide} textrel.rd}} \ | |
181 | "textrel.so" \ | |
182 | ] \ | |
8e604ff0 | 183 | ] bfin-*-* frv-*-* lm32-*-* xtensa-*-* |
63c1f59d | 184 | |
a4eb6927 MR |
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. | |
63c1f59d AM |
190 | run_ld_link_tests [list \ |
191 | [list \ | |
192 | "DT_TEXTREL map file warning" \ | |
193 | "$LFLAGS -shared -M" \ | |
194 | "" \ | |
195 | "$AFLAGS_PIC" \ | |
196 | {textrel.s} \ | |
197 | {{ld textrel.map}} \ | |
198 | "textrel.so" \ | |
199 | ] \ | |
8e604ff0 | 200 | ] bfin-*-* cris*-*-* frv-*-* lm32-*-* mips*-*-* |
63c1f59d | 201 | |
81ff47b3 MR |
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. | |
902e9fc7 MR |
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. | |
81ff47b3 MR |
210 | if { [check_gc_sections_available] } { |
211 | run_ld_link_tests [list \ | |
212 | [list \ | |
213 | "PR ld/20828 dynamic symbols with section GC\ | |
15a00b13 MR |
214 | (auxiliary shared library)" \ |
215 | "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \ | |
216 | {pr20828.s} \ | |
217 | {{readelf --dyn-syms pr20828-a.sd} \ | |
218 | {readelf --dyn-syms pr20828-b.sd}} \ | |
219 | "libpr20828.so"] \ | |
81ff47b3 MR |
220 | [list \ |
221 | "PR ld/20828 dynamic symbols with section GC (plain)" \ | |
15a00b13 MR |
222 | "$LFLAGS -shared --gc-sections -T pr20828.ld" \ |
223 | "tmpdir/libpr20828.so" "$AFLAGS_PIC" \ | |
224 | {pr20828.s} \ | |
225 | {{readelf --dyn-syms pr20828-a.sd} \ | |
226 | {readelf --dyn-syms pr20828-b.sd}} \ | |
227 | "pr20828-1.so"] \ | |
81ff47b3 MR |
228 | [list \ |
229 | "PR ld/20828 dynamic symbols with section GC (version script)" \ | |
15a00b13 MR |
230 | "$LFLAGS -shared --gc-sections -T pr20828.ld\ |
231 | --version-script=pr20828.ver" \ | |
232 | "tmpdir/libpr20828.so" \ | |
233 | "$AFLAGS_PIC" \ | |
234 | {pr20828.s} \ | |
235 | {{readelf --dyn-syms pr20828-b.sd} \ | |
236 | {readelf --dyn-syms pr20828-c.sd}} \ | |
902e9fc7 MR |
237 | "pr20828-2.so"] \ |
238 | [list \ | |
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" \ | |
243 | "" "$AFLAGS_PIC" \ | |
244 | {pr20828.s} \ | |
245 | {{readelf --dyn-syms pr20828-c.sd} \ | |
246 | {readelf --dyn-syms pr20828-d.sd} \ | |
247 | {readelf --dyn-syms pr20828-e.sd}} \ | |
248 | "libpr20828-v.so"] \ | |
249 | [list \ | |
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" \ | |
254 | "$AFLAGS_PIC" \ | |
255 | {pr20828.s} \ | |
256 | {{readelf --dyn-syms pr20828-c.sd} \ | |
257 | {readelf --dyn-syms pr20828-d.sd} \ | |
258 | {readelf --dyn-syms pr20828-e.sd}} \ | |
259 | "pr20828-v.so"] \ | |
260 | [list \ | |
261 | "PR ld/20828 forcibly exported symbol version without section GC" \ | |
3c5fce9b | 262 | "$LFLAGS --no-dynamic-linker -e foo -E -T pr20828-v.ld" "" "" \ |
902e9fc7 MR |
263 | {pr20828-v.s} \ |
264 | {{objdump -p pr20828-v.od}} \ | |
265 | "pr20828-v-1"] \ | |
266 | [list \ | |
267 | "PR ld/20828 forcibly exported symbol version with section GC" \ | |
3c5fce9b | 268 | "$LFLAGS --no-dynamic-linker -e foo --gc-sections -E -T pr20828-v.ld" "" "" \ |
902e9fc7 MR |
269 | {pr20828-v.s} \ |
270 | {{objdump -p pr20828-v.od}} \ | |
271 | "pr20828-v-2"]] | |
81ff47b3 | 272 | } |
80070c0d MR |
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 | |
278 | # command. | |
279 | # Verify that the undefined symbol is global rather than local. | |
280 | if { [check_gc_sections_available] } { | |
281 | run_ld_link_tests [list \ | |
282 | [list \ | |
283 | "PR ld/21233 dynamic symbols with section GC\ | |
284 | (auxiliary shared library)" \ | |
285 | "$LFLAGS -shared -T pr21233.ld" "" "$AFLAGS_PIC" \ | |
286 | {pr21233-l.s} \ | |
287 | {{readelf --dyn-syms pr21233-l.sd}} \ | |
4d5efb85 | 288 | "libpr21233.so"]] |
6ca30fa5 | 289 | |
4d5efb85 | 290 | run_ld_link_tests [list \ |
80070c0d MR |
291 | [list \ |
292 | "PR ld/21233 dynamic symbols with section GC (--undefined)" \ | |
293 | "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld" \ | |
294 | "tmpdir/libpr21233.so" "" \ | |
295 | {pr21233.s} \ | |
296 | {{readelf --dyn-syms pr21233.sd}} \ | |
6ca30fa5 HPN |
297 | "pr21233-1"]] |
298 | ||
6ca30fa5 | 299 | run_ld_link_tests [list \ |
80070c0d MR |
300 | [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" \ | |
304 | "tmpdir/libpr21233.so" "" \ | |
305 | {pr21233.s} \ | |
306 | {{readelf --dyn-syms pr21233.sd}} \ | |
6ca30fa5 HPN |
307 | "pr21233-2"]] |
308 | ||
6ca30fa5 | 309 | run_ld_link_tests [list \ |
80070c0d MR |
310 | [list \ |
311 | "PR ld/21233 dynamic symbols with section GC (EXTERN)" \ | |
312 | "$LFLAGS --gc-sections -e foo -T pr21233-e.ld" \ | |
313 | "tmpdir/libpr21233.so" "" \ | |
314 | {pr21233.s} \ | |
315 | {{readelf --dyn-syms pr21233.sd}} \ | |
6ca30fa5 | 316 | "pr21233-3"]] |
80070c0d | 317 | } |
81ff47b3 | 318 | |
be2b629f L |
319 | if { [check_gc_sections_available] } { |
320 | run_ld_link_tests [list \ | |
321 | [list \ | |
322 | "Build pr22150.so" \ | |
323 | "$LFLAGS -shared --version-script pr22150.ver" \ | |
324 | "" \ | |
325 | "$AFLAGS_PIC" \ | |
326 | {pr22150a.s} \ | |
327 | {} \ | |
328 | "pr22150.so" \ | |
329 | ] \ | |
330 | [list \ | |
331 | "Build pr22150" \ | |
332 | "$LFLAGS -e _start --gc-sections" \ | |
333 | "tmpdir/pr22150.so" \ | |
334 | "" \ | |
335 | {pr22150b.s} \ | |
336 | {{readelf -V pr22150.vd}} \ | |
337 | "pr22150" \ | |
338 | ] \ | |
339 | ] | |
3024a17a AM |
340 | |
341 | switch -glob $target_triplet { | |
342 | # exclude targets that don't support copy relocs | |
343 | bfin-*-* { } | |
344 | frv-*-* { } | |
345 | lm32-*-* { } | |
346 | mips*-*-* { } | |
347 | tic6x-*-* { } | |
348 | xtensa-*-* { } | |
349 | default { | |
350 | run_ld_link_tests [list \ | |
351 | [list \ | |
352 | "Build pr25458.so" \ | |
353 | "$LFLAGS -shared --version-script=pr25458.map" \ | |
354 | "" \ | |
355 | "$AFLAGS_PIC" \ | |
356 | {pr25458b.s} \ | |
357 | {} \ | |
358 | "pr25458.so" \ | |
359 | ] \ | |
360 | [list \ | |
361 | "Build pr25458" \ | |
362 | "$LFLAGS -e _start --gc-sections" \ | |
363 | "tmpdir/pr25458.so" \ | |
364 | "$AFLAGS_PIC" \ | |
365 | {pr25458a.s} \ | |
366 | {{readelf {--dyn-sym --wide} pr25458.rd}} \ | |
367 | "pr25458" \ | |
368 | ] \ | |
369 | ] | |
370 | } | |
371 | } | |
be2b629f L |
372 | } |
373 | ||
66824765 AM |
374 | set ASFLAGS $old_ASFLAGS |
375 | ||
f3a9baf1 MR |
376 | run_ld_link_tests { |
377 | {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" } | |
378 | } | |
e54d3c94 MR |
379 | run_ld_link_tests [list \ |
380 | [list "Build shared library for pr14170" \ | |
381 | "-shared" "" "$AFLAGS_PIC" "pr14170b.s" {} "pr14170.so" ] \ | |
382 | ] | |
f3a9baf1 MR |
383 | |
384 | # bfin does not currently support copy relocs. | |
c7c970e4 AM |
385 | setup_xfail bfin-*-* |
386 | clear_xfail bfin-*-linux* | |
f3a9baf1 MR |
387 | run_ld_link_tests [list \ |
388 | [list "PR ld/14170" \ | |
8988502d MR |
389 | "$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \ |
390 | $hpux \ | |
f3a9baf1 | 391 | {pr14170c.s} { } "pr14170" ] \ |
c7c970e4 | 392 | ] |
f3a9baf1 MR |
393 | |
394 | # Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests | |
1336939d | 395 | # Nor will hppa64 with dot-symbols. |
e54d3c94 MR |
396 | run_ld_link_tests [list \ |
397 | [list "PR ld/21703 shared" \ | |
597344c9 | 398 | "$LFLAGS -shared --allow-multiple-definition --version-script pr21703.ver\ |
e54d3c94 MR |
399 | tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "$AFLAGS_PIC" \ |
400 | {pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} \ | |
401 | "pr21703.so" ] \ | |
1336939d | 402 | ] \[is_generic\] hppa64-*-* |
f3a9baf1 MR |
403 | |
404 | # This target requires extra GAS options when building non-PIC code | |
405 | # for linking with shared libraries. | |
406 | set AFLAGS_NONPIC "" | |
407 | if [istarget "mips*-*-*"] { | |
408 | append AFLAGS_NONPIC " -call_nonpic" | |
409 | } | |
410 | ||
411 | # Run a test to check linking a shared library with a broken linker | |
412 | # script that accidentally marks dynamic sections as notes. The | |
413 | # resulting executable is not expected to work, but the linker | |
414 | # should not seg-fault whilst creating the binary. | |
e54d3c94 MR |
415 | run_ld_link_tests [list \ |
416 | [list "Build shared library for broken linker script test" \ | |
417 | "-shared --hash-style=sysv" "" "$AFLAGS_PIC" "note-3.s" \ | |
418 | {} \ | |
419 | "note-3.so" ] \ | |
420 | [list "Link using broken linker script" \ | |
421 | "$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" "" \ | |
422 | { { ld "note-3.l" } } \ | |
423 | "a.out" ] \ | |
424 | ] | |
f3a9baf1 | 425 | |
e54d3c94 MR |
426 | run_ld_link_tests [list \ |
427 | [list "Build pr17068.so" \ | |
428 | "-shared" "" "$AFLAGS_PIC" \ | |
429 | {pr17068d.s} {} "pr17068.so"] \ | |
430 | [list "Build pr17068a.a" \ | |
431 | "" "" "" \ | |
432 | {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"] \ | |
433 | [list "Build pr17068b.a" \ | |
434 | "" "" "" \ | |
435 | {pr17068b.s pr17068e.s} {} "pr17068b.a"] \ | |
436 | ] | |
f3a9baf1 MR |
437 | |
438 | # bfin does not currently support copy relocs. | |
c7c970e4 AM |
439 | setup_xfail bfin-*-* |
440 | clear_xfail bfin-*-linux* | |
f3a9baf1 MR |
441 | run_ld_link_tests { |
442 | {"pr17068 link --as-needed lib in group" | |
8988502d MR |
443 | "$LFLAGS --as-needed --no-dynamic-linker" |
444 | "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\ | |
445 | --end-group" "" | |
f3a9baf1 | 446 | {start.s pr17068.s} {} "pr17068"} |
c7c970e4 | 447 | } |
f3a9baf1 | 448 | |
f3a9baf1 MR |
449 | # Fails on MIPS because ABI trickery means that a NULL reloc is emitted. |
450 | # Fails on bfin because relocations are not created. | |
c7c970e4 AM |
451 | setup_xfail mips*-*-* bfin-*-* |
452 | clear_xfail bfin-*-linux* | |
e54d3c94 MR |
453 | run_ld_link_tests [list \ |
454 | [list "-Bsymbolic-functions" \ | |
455 | "-shared -Bsymbolic-functions" "" "$AFLAGS_PIC" \ | |
456 | {symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}} \ | |
457 | "symbolic-func.so"] \ | |
c7c970e4 | 458 | ] |
f3a9baf1 | 459 | |
e54d3c94 MR |
460 | run_ld_link_tests [list \ |
461 | [list "Build pr20995.so" \ | |
462 | "-shared" "" "$AFLAGS_PIC" \ | |
463 | {pr20995b.s} {} "pr20995.so"] \ | |
464 | ] | |
f3a9baf1 | 465 | |
f3a9baf1 MR |
466 | # These targets don't copy dynamic variables into .bss. |
467 | setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" | |
468 | # or don't have .data.rel.ro | |
656e4a22 | 469 | setup_xfail "hppa*64*-*-hpux*" "tic6x-*-*" |
8e604ff0 AM |
470 | # or complain about relocs in read-only sections |
471 | setup_xfail frv-*-* lm32-*-* | |
f3a9baf1 MR |
472 | run_ld_link_tests [list \ |
473 | [list \ | |
474 | "pr20995" \ | |
8988502d | 475 | "$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \ |
f3a9baf1 MR |
476 | {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]] |
477 | ||
5fd104ad AM |
478 | # xfail on targets that don't support GNU_RELRO. |
479 | # For more details, please see discussions at: | |
480 | # https://sourceware.org/ml/binutils/2017-01/msg00441.html | |
481 | run_ld_link_tests [list \ | |
482 | [list "Build pr20995-2.so" \ | |
483 | "-shared -z relro" "" "$AFLAGS_PIC" \ | |
484 | {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \ | |
485 | ] {![check_relro_support]} | |
486 | ||
487 | setup_xfail alpha-*-* xtensa-*-* | |
f3a9baf1 MR |
488 | run_ld_link_tests [list \ |
489 | [list \ | |
490 | "pr20995-2" \ | |
8988502d | 491 | "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \ |
c93c0e7f | 492 | {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"] |
5fd104ad | 493 | ] {![check_relro_support]} |
f3a9baf1 | 494 | |
e54d3c94 MR |
495 | run_ld_link_tests [list \ |
496 | [list "Build pr22374 shared library" \ | |
497 | "-shared" "" "$AFLAGS_PIC" "pr22374b.s" {} "pr22374.so" ] \ | |
498 | ] | |
c7c970e4 AM |
499 | |
500 | # The next test checks that copy relocs are not used unnecessarily, | |
501 | # but that is just an optimization so don't complain loudly. | |
502 | setup_xfail *-*-* | |
503 | clear_xfail alpha-*-* bfin-*-linux* csky-*-* frv-*-* hppa*-*-* i?86-*-* | |
504 | clear_xfail ia64-*-* microblaze-*-* powerpc*-*-* x86_64-*-* xtensa-*-* | |
f3a9baf1 MR |
505 | run_ld_link_tests { |
506 | {"pr22374 function pointer initialization" | |
507 | "" "tmpdir/pr22374.so" "" "pr22374a.s" | |
508 | { {readelf {--wide -r --dyn-syms} "pr22374-1.r"} | |
509 | {readelf {--wide -r} "pr22374-2.r"} } | |
510 | "pr22374" } | |
511 | } | |
512 | ||
513 | if { [istarget *-*-linux*] | |
514 | || [istarget *-*-nacl*] | |
515 | || [istarget *-*-gnu*] } { | |
516 | run_ld_link_tests { | |
517 | {"Weak symbols in dynamic objects 1 (support)" | |
518 | "-shared" "" "" {weak-dyn-1a.s} | |
519 | {} | |
520 | "libweakdyn1a.so"} | |
521 | {"Weak symbols in dynamic objects 1 (main test)" | |
522 | "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s} | |
523 | {{readelf {--relocs --wide} weak-dyn-1.rd}} | |
524 | "libweakdyn1b.so"} | |
525 | } | |
526 | } | |
527 | ||
dd98f8d2 | 528 | # Check to see if the C compiler works |
44ed8092 | 529 | if { ![check_compiler_available] } { |
d2dee3b2 L |
530 | return |
531 | } | |
532 | ||
fb2c6e43 | 533 | # Add -ldl to extralibs if needed |
d9816402 | 534 | set extralibs "" |
fb2c6e43 AT |
535 | if { ![istarget *-*-freebsd*]} { |
536 | set extralibs "-ldl" | |
537 | } | |
538 | ||
d2dee3b2 L |
539 | set build_tests { |
540 | {"Build libfoo.so" | |
541 | "-shared" "-fPIC" | |
542 | {foo.c} {} "libfoo.so"} | |
543 | {"Build versioned libfoo.so" | |
544 | "-shared -Wl,--version-script=foo.map" "-fPIC" | |
55255dae | 545 | {foo.c} {} "libfoov.so"} |
d2dee3b2 L |
546 | {"Build libbar.so" |
547 | "-shared" "-fPIC" | |
548 | {begin.c end.c} {} "libbar.so"} | |
fab4a87f L |
549 | {"Build warn libbar.so" |
550 | "-shared" "-fPIC" | |
2bd7f877 AB |
551 | {beginwarn.c end.c} |
552 | {{readelf {-S --wide} libbarw.rd} | |
7dd36a6f | 553 | {warning "^.*beginwarn.c:7: warning: function foo is deprecated\n?$"}} |
2bd7f877 | 554 | "libbarw.so" "c"} |
d2dee3b2 L |
555 | {"Build hidden libbar.so" |
556 | "-shared" "-fPIC" | |
557 | {begin.c endhidden.c} {} "libbarh.so"} | |
558 | {"Build protected libbar.so" | |
559 | "-shared" "-fPIC" | |
560 | {begin.c endprotected.c} {} "libbarp.so"} | |
561 | {"Build libbar.so with libfoo.so" | |
562 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
563 | {end.c} {} "libbarfoo.so"} | |
564 | {"Build libar.so with versioned libfoo.so" | |
565 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
566 | {end.c} {} "libbarfoov.so"} | |
567 | {"Build hidden libbar.so with libfoo.so" | |
568 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
569 | {endhidden.c} {} "libbarhfoo.so"} | |
570 | {"Build hidden libar.so with versioned libfoo.so" | |
571 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
572 | {endhidden.c} {} "libbarhfoov.so"} | |
573 | {"Build protected libbar.so with libfoo.so" | |
574 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
575 | {endprotected.c} {} "libbarpfoo.so"} | |
576 | {"Build protected libbar.so with versioned libfoo.so" | |
577 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
578 | {endprotected.c} {} "libbarpfoov.so"} | |
55255dae L |
579 | {"Build libdl1.so" |
580 | "-shared" "-fPIC" | |
581 | {dl1.c} {} "libdl1.so"} | |
582 | {"Build libdl2a.so with --dynamic-list=dl2.list" | |
583 | "-shared -Wl,--dynamic-list=dl2.list" "-fPIC" | |
584 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
b7b7fe3f AS |
585 | {"Build libdl2a.so with --dynamic-list=dl2a.list" |
586 | "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC" | |
587 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
40b36307 L |
588 | {"Build libdl2a.so with --dynamic-list-data" |
589 | "-shared -Wl,--dynamic-list-data" "-fPIC" | |
590 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
55255dae L |
591 | {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list" |
592 | "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC" | |
593 | {dl2.c dl2xxx.c} {} "libdl2b.so"} | |
d8cf8b51 | 594 | {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list" |
40b36307 | 595 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC" |
d8cf8b51 | 596 | {dl2.c dl2xxx.c} {} "libdl2c.so"} |
bb68f22c FS |
597 | {"Build libdl2d.so with --dynamic-list-data -Bsymbolic" |
598 | "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC" | |
599 | {dl2.c dl2xxx.c} {} "libdl2d.so"} | |
37a141bf FS |
600 | {"Build libdl2e.so with --export-dynamic-symbol=foo" |
601 | "-shared -Wl,--export-dynamic-symbol=foo" "-fPIC" | |
602 | {dl2.c dl2xxx.c} {} "libdl2e.so"} | |
603 | {"Build libdl2f.so with --dynamic-list=dlempty.list and --export-dynamic-symbol=foo" | |
604 | "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol=foo" "-fPIC" | |
605 | {dl2.c dl2xxx.c} {} "libdl2f.so"} | |
606 | {"Build libdl2g.so with --export-dynamic-symbol-list=dl2.list" | |
607 | "-shared -Wl,--export-dynamic-symbol-list=dl2.list" "-fPIC" | |
608 | {dl2.c dl2xxx.c} {} "libdl2g.so"} | |
609 | {"Build libdl2h.so with --dynamic-list=dlempty.list and --export-dynamic-symbol-list=dl2.list" | |
610 | "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol-list=dl2.list" "-fPIC" | |
611 | {dl2.c dl2xxx.c} {} "libdl2h.so"} | |
612 | {"Build libdl2i.so with -Bsymbolic and --export-dynamic-symbol=foo" | |
613 | "-shared -Wl,-Bsymbolic,--export-dynamic-symbol=foo" "-fPIC" | |
614 | {dl2.c dl2xxx.c} {} "libdl2i.so"} | |
615 | {"Build libdl2j.so with -Bsymbolic and --export-dynamic-symbol-list=dl2.list" | |
616 | "-shared -Wl,-Bsymbolic,--export-dynamic-symbol-list=dl2.list" "-fPIC" | |
617 | {dl2.c dl2xxx.c} {} "libdl2j.so"} | |
618 | {"Build libdl2k.so with --export-dynamic-symbol-list=dl2.list and -Bsymbolic" | |
619 | "-shared -Wl,--export-dynamic-symbol-list=dl2.list,-Bsymbolic" "-fPIC" | |
620 | {dl2.c dl2xxx.c} {} "libdl2k.so"} | |
cf893b0e FS |
621 | # Check that -Bno-symbolic cancels -Bsymbolic. |
622 | {"Build libdl2l.so with -Bsymbolic -Bno-symbolic and --export-dynamic-symbol=foo" | |
623 | "-shared -Wl,-Bsymbolic,-Bno-symbolic,--export-dynamic-symbol=foo" "-fPIC" | |
624 | {dl2.c dl2xxx.c} {} "libdl2l.so"} | |
c555238b L |
625 | {"Build libdl4a.so with --dynamic-list=dl4.list" |
626 | "-shared -Wl,--dynamic-list=dl4.list" "-fPIC" | |
627 | {dl4.c dl4xxx.c} {} "libdl4a.so"} | |
d8cf8b51 | 628 | {"Build libdl4b.so with --dynamic-list-data" |
40b36307 | 629 | "-shared -Wl,--dynamic-list-data" "-fPIC" |
c555238b | 630 | {dl4.c dl4xxx.c} {} "libdl4b.so"} |
d8cf8b51 L |
631 | {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list" |
632 | "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC" | |
633 | {dl4.c dl4xxx.c} {} "libdl4c.so"} | |
634 | {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list" | |
40b36307 | 635 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC" |
d8cf8b51 L |
636 | {dl4.c dl4xxx.c} {} "libdl4d.so"} |
637 | {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new" | |
638 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" | |
639 | {dl4.c dl4xxx.c} {} "libdl4e.so"} | |
640 | {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions" | |
641 | "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC" | |
642 | {dl4.c dl4xxx.c} {} "libdl4f.so"} | |
643 | {"Build libdl6a.so" | |
644 | "-shared" "-fPIC" | |
645 | {dl6.c} {} "libdl6a.so"} | |
646 | {"Build libdl6b.so with -Bsymbolic --dynamic-list-data" | |
647 | "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC" | |
648 | {dl6.c} {} "libdl6b.so"} | |
649 | {"Build libdl6c.so with -Bsymbolic" | |
650 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
651 | {dl6.c} {} "libdl6c.so"} | |
652 | {"Build libdl6d.so with --dynamic-list-data -Bsymbolic" | |
653 | "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC" | |
654 | {dl6.c} {} "libdl6d.so"} | |
43edfb7f L |
655 | {"Build libdata1.so" |
656 | "-shared" "-fPIC" | |
657 | {data1.c} {} "libdata1.so"} | |
a47edf27 L |
658 | {"Build libdata2.so" |
659 | "-shared" "-fPIC" | |
660 | {data2.c} {} "libdata2.so"} | |
0a36a439 | 661 | {"Build libcomm1.o" |
0e1f1593 | 662 | "-r -nostdlib" "-fcommon" |
0a36a439 L |
663 | {comm1.c} {} "libcomm1.o"} |
664 | {"Build libfunc1.so" | |
665 | "-shared" "-fPIC" | |
666 | {func1.c} {} "libfunc1.so"} | |
d8880531 L |
667 | {"Build libpr9676-1.a" |
668 | "" "-fPIC" | |
669 | {pr9676-1.c} {} "libpr9676-1.a"} | |
670 | {"Build libpr9676-2.a" | |
671 | "" "-fPIC" | |
672 | {pr9676-2.c} {} "libpr9676-2.a"} | |
673 | {"Build libpr9676-3.so" | |
674 | "-shared" "-fPIC" | |
675 | {pr9676-3.c} {} "libpr9676-3.so"} | |
676 | {"Build libpr9676-4.so" | |
677 | "-shared" "-fPIC" | |
678 | {pr9676-4.c} {} "libpr9676-4.so"} | |
679 | {"Build libpr9676-4a.so" | |
680 | "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group" | |
681 | "-fPIC" | |
682 | {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"} | |
54ac0771 L |
683 | {"Build libpr9679.so" |
684 | "-shared" "-fPIC -O0" | |
685 | {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"} | |
d023c380 L |
686 | {"Build libpr11138-1.so" |
687 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
688 | {pr11138-1.c} {} "libpr11138-1.so"} | |
689 | {"Build libpr11138-2.o" | |
690 | "-r -nostdlib" "" | |
691 | {pr11138-2.c} {} "libpr11138-2.o"} | |
3e0882af | 692 | {"Build pr13250-1.so" |
0e1f1593 | 693 | "-shared" "-fPIC -fcommon" |
3e0882af L |
694 | {pr13250-1.c} {} "libpr13250-1.so"} |
695 | {"Build pr13250-2.so with libpr13250-1.so" | |
0e1f1593 | 696 | "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC -fcommon" |
3e0882af L |
697 | {pr13250-2.c} {} "libpr13250-2.so"} |
698 | {"Build libpr13250-3.o" | |
0e1f1593 | 699 | "-r -nostdlib" "-fcommon" |
3e0882af | 700 | {pr13250-3.c} {} "libpr13250-3.o"} |
bc9ad2e4 | 701 | {"Build libpr14323-2.so" |
0e1f1593 | 702 | "-shared" "-fPIC -fcommon" |
bc9ad2e4 | 703 | {pr14323-2.c} {} "libpr14323-2.so"} |
dda8ddc5 L |
704 | {"Build pr14862-1.o" |
705 | "-r -nostdlib" "" | |
706 | {pr14862-1.c} {} "libpr14862-1.o"} | |
707 | {"Build libpr14862.so" | |
708 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
709 | {pr14862-2.c} {} "libpr14862.so"} | |
63406f0a L |
710 | {"Build libneeded1b.so" |
711 | "-shared" "-fPIC" | |
712 | {needed1b.c} {} "libneeded1b.so"} | |
713 | {"Build libneeded1a.so" | |
2eb64a9f | 714 | "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC" |
63406f0a L |
715 | {needed1a.c} {} "libneeded1a.so"} |
716 | {"Build libneeded1c.o" | |
717 | "-r -nostdlib" "" | |
718 | {needed1c.c} {} "libneeded1c.o"} | |
8fbb09e8 L |
719 | {"Build libneeded1pic.o" |
720 | "-r -nostdlib" "-fPIC" | |
721 | {needed1c.c} {} "libneeded1pic.o"} | |
722 | {"Build needed1a.so with --add-needed" | |
8cfc7cf8 | 723 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
724 | {dummy.c} {} "needed1a.so"} |
725 | {"Build needed1b.so with --copy-dt-needed-entries" | |
8cfc7cf8 | 726 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
727 | {dummy.c} {} "needed1b.so"} |
728 | {"Build needed1a.so with --no-add-needed" | |
8cfc7cf8 | 729 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
730 | {dummy.c} {} "needed1c.so"} |
731 | {"Build needed1b.so with --no-copy-dt-needed-entries" | |
8cfc7cf8 | 732 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" "" |
8fbb09e8 | 733 | {dummy.c} {} "needed1d.so"} |
8877b5e5 AM |
734 | {"Build librel.so" |
735 | "-shared" "-fPIC" | |
736 | {rel.c} {} "librel.so"} | |
5e319dd3 L |
737 | {"Build libneeded2a.so" |
738 | "-shared" "-fPIC" | |
739 | {needed2a.c} {} "libneeded2a.so"} | |
740 | {"Build libneeded2b.so" | |
741 | "-shared -Wl,--version-script,needed2.ver" "-fPIC" | |
742 | {needed2b.c} {} "libneeded2b.so"} | |
743 | {"Build libneeded2c.o" | |
744 | "-r -nostdlib" "" | |
745 | {needed2c.c} {} "libneeded2c.o"} | |
746 | {"Build needed2" | |
747 | "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" "" | |
748 | {dummy.c} {} "needed2"} | |
1240be6b AM |
749 | {"Build libneeded3a.so" |
750 | "-shared -Wl,--no-add-needed" "-fPIC" | |
751 | {needed1a.c} {} "libneeded3a.so"} | |
752 | {"Build libneeded3b.so" | |
753 | "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC" | |
754 | {dummy.c} {} "libneeded3b.so"} | |
755 | {"Build needed3.o" | |
756 | "-r -nostdlib" "" | |
757 | {needed3.c} {} "libneeded3.so"} | |
758 | {"Build needed3" | |
759 | "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" "" | |
760 | {dummy.c} {} "needed3"} | |
50a53d3f | 761 | {"Build rdynamic-1" |
8569cfa7 | 762 | "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections" |
50a53d3f | 763 | {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"} |
d6f6f455 | 764 | {"Build dynamic-1" |
8569cfa7 | 765 | "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections" |
d6f6f455 | 766 | {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"} |
bb4d2ac2 L |
767 | {"Build libpr16496a.so" |
768 | "-shared -Wl,--version-script=pr16496a.map" "-fPIC" | |
769 | {pr16496a.c} {} "libpr16496a.so"} | |
770 | {"Build libpr16496b.a" | |
771 | "" "-fPIC" | |
772 | {pr16496b.c} {} "libpr16496b.a"} | |
773 | {"Build libpr16496b.so" | |
8cfc7cf8 | 774 | "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" "" |
bb4d2ac2 | 775 | {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"} |
fb389763 L |
776 | {"Build libpr16452a.so" |
777 | "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC" | |
778 | {pr16452a.c} {} "libpr16452a.so"} | |
779 | {"Build libpr16452b.so" | |
780 | "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC" | |
781 | {dummy.c} {} "libpr16452b.so"} | |
782 | {"Build pr16452" | |
8cfc7cf8 | 783 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 L |
784 | {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"} |
785 | {"Build pr16457" | |
8cfc7cf8 | 786 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 | 787 | {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"} |
8ded2ddc L |
788 | {"Build libpr18458a.so" |
789 | "-shared -Wl,-z,now" "-fPIC" | |
790 | {pr18458a.c} {} "libpr18458a.so"} | |
791 | {"Build libpr18458b.so" | |
792 | "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC" | |
793 | {pr18458b.c} {} "libpr18458b.so"} | |
8e3152af | 794 | } |
05fd99cc L |
795 | |
796 | run_cc_link_tests [list \ | |
797 | [list \ | |
798 | "Build libpr2404a.so" \ | |
e062fcc8 L |
799 | "-shared $NOSANITIZE_CFLAGS" \ |
800 | "-fPIC $NOSANITIZE_CFLAGS" \ | |
05fd99cc L |
801 | {pr2404a.c} \ |
802 | {} \ | |
803 | "libpr2404a.so" \ | |
804 | ] \ | |
805 | [list \ | |
806 | "Build libpr2404n.so" \ | |
e062fcc8 L |
807 | "-shared -Wl,-z,now $NOSANITIZE_CFLAGS" \ |
808 | "-fPIC $NOSANITIZE_CFLAGS" \ | |
05fd99cc L |
809 | {pr2404a.c} \ |
810 | {} \ | |
811 | "libpr2404n.so" \ | |
812 | ] \ | |
813 | [list \ | |
814 | "Build libpr2404b.a" \ | |
815 | "" \ | |
e062fcc8 | 816 | "$NOSANITIZE_CFLAGS" \ |
05fd99cc L |
817 | {pr2404b.c} \ |
818 | {} \ | |
819 | "libpr2404b.a" \ | |
820 | ] \ | |
93d49941 L |
821 | [list \ |
822 | "Build libpr26590a.so" \ | |
823 | "-shared" \ | |
824 | "-fPIC" \ | |
825 | {pr26590a.c} \ | |
826 | {} \ | |
827 | "libpr26590a.so" \ | |
828 | ] \ | |
829 | [list \ | |
830 | "Build libpr26590b.so (1)" \ | |
831 | "-shared" \ | |
832 | "-fPIC" \ | |
833 | {pr26590b.c} \ | |
834 | {} \ | |
835 | "libpr26590b.so" \ | |
836 | ] \ | |
837 | [list \ | |
838 | "Build pr26590c.o and pr26590d.o" \ | |
839 | "" \ | |
840 | "" \ | |
841 | {pr26590c.c pr26590d.c} \ | |
842 | {} \ | |
843 | ] \ | |
844 | [list \ | |
845 | "Build pr26590 (1)" \ | |
846 | "tmpdir/pr26590c.o tmpdir/pr26590d.o \ | |
847 | -Wl,--as-needed tmpdir/libpr26590a.so tmpdir/libpr26590b.so" \ | |
848 | "" \ | |
849 | {dummy.c} \ | |
850 | {{error_output pr26590.err}} \ | |
851 | "pr26590" \ | |
852 | ] \ | |
853 | [list \ | |
854 | "Build libpr26590b.so (2)" \ | |
855 | "-shared -Wl,--no-as-needed \ | |
856 | tmpdir/libpr26590a.so" \ | |
857 | "-fPIC" \ | |
858 | {pr26590b.c} \ | |
859 | {} \ | |
860 | "libpr26590b.so" \ | |
861 | ] \ | |
862 | [list \ | |
863 | "Build pr26590 (2)" \ | |
864 | "tmpdir/pr26590c.o tmpdir/pr26590d.o \ | |
865 | -Wl,--as-needed tmpdir/libpr26590a.so tmpdir/libpr26590b.so" \ | |
866 | "" \ | |
867 | {dummy.c} \ | |
868 | {} \ | |
869 | "pr26590" \ | |
870 | ] \ | |
05fd99cc L |
871 | ] |
872 | ||
8e3152af AM |
873 | # pr19073.s uses .set, which has a different meaning on alpha. |
874 | if { ![istarget alpha-*-*] } { | |
875 | append build_tests { | |
876 | {"Build pr19073a.o" | |
877 | "-r -nostdlib" "" | |
878 | {pr19073.s} {} "pr19073a.o"} | |
879 | {"Build libpr19073.so" | |
880 | "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC" | |
881 | {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"} | |
882 | } | |
883 | } | |
884 | append build_tests { | |
8dfb7cbf | 885 | {"Build pr21964-1a.so" |
487b6440 | 886 | "-shared" "-fPIC" |
8dfb7cbf L |
887 | {pr21964-1a.c} {} "pr21964-1a.so"} |
888 | {"Build pr21964-1b.so" | |
487b6440 | 889 | "-shared" "-fPIC" |
8dfb7cbf L |
890 | {pr21964-1b.c} {} "pr21964-1b.so"} |
891 | {"Build pr21964-2a.so" | |
892 | "-shared" "-fPIC" | |
893 | {pr21964-2a.c} {} "pr21964-2a.so"} | |
894 | {"Build pr21964-2b.so" | |
895 | "-shared" "-fPIC" | |
896 | {pr21964-2b.c} {} "pr21964-2b.so"} | |
36b8fda5 AM |
897 | {"Build pr21964-3a.so" |
898 | "-shared" "-fPIC" | |
899 | {pr21964-3a.c} {} "pr21964-3a.so"} | |
2715765b L |
900 | {"Dump pr21978.so" |
901 | "-shared" "-fPIC -g -O2" | |
902 | {pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"} | |
7ba11550 AM |
903 | {"libpr26580-2.so" |
904 | "-shared" "-fPIC -fcommon" | |
905 | {pr26580-b.c} {} "libpr26580-2.so"} | |
d2dee3b2 L |
906 | } |
907 | ||
dd98f8d2 NC |
908 | run_cc_link_tests $build_tests |
909 | ||
e1b5d517 L |
910 | run_cc_link_tests [list \ |
911 | [list \ | |
912 | "Build pr26094-1.so" \ | |
913 | "-shared -Wl,--version-script=pr26094-1.ver" \ | |
914 | "-fPIC" \ | |
915 | {pr26094-1a.c} \ | |
916 | {{readelf {--dyn-syms --wide} pr26094-1a.rd}} \ | |
917 | "pr26094-1.so" \ | |
918 | ] \ | |
919 | [list \ | |
920 | "Build pr26094-1" \ | |
921 | "-Wl,--no-as-needed tmpdir/pr26094-1.so" \ | |
922 | "-fcommon" \ | |
923 | {pr26094-1b.c pr26094-1c.c} \ | |
924 | {{readelf {--dyn-syms --wide} pr26094-1b.rd}} \ | |
925 | "pr26094-1" \ | |
926 | ] \ | |
9b0ac51b L |
927 | [list \ |
928 | "Build pr26302a.so" \ | |
929 | "-shared -Wl,--version-script=pr26302.ver" \ | |
930 | "-fPIC" \ | |
931 | {pr26302a.c} \ | |
932 | {} \ | |
933 | "pr26302a.so" | |
934 | ] \ | |
935 | [list \ | |
936 | "Build pr26302b.so" \ | |
937 | "-shared -Wl,--no-as-needed tmpdir/pr26302a.so" \ | |
938 | "-fPIC" \ | |
939 | {pr26302b.c} \ | |
3f2e9699 L |
940 | {{readelf {-sW} pr26302.rd} \ |
941 | {nm {-u} pr26302.nd} \ | |
9b0ac51b L |
942 | {nm {-u -D} pr26302.nd} \ |
943 | {nm {-u -D --with-symbol-versions} pr26302.nd}} \ | |
944 | "pr26302b.so" \ | |
945 | ] \ | |
e1b5d517 L |
946 | ] |
947 | ||
f3012016 L |
948 | run_ld_link_tests [list \ |
949 | [list \ | |
ef0cc92e AM |
950 | "pr22269-1 (static pie undefined weak)" \ |
951 | "-pie -e _start --no-dynamic-linker -z text -z nocombreloc " \ | |
f3012016 | 952 | "" \ |
185cdb8c | 953 | "$AFLAGS_PIC" \ |
f3012016 L |
954 | { pr22269-1.c } \ |
955 | {{readelf -rW pr22269-1.rd}} \ | |
956 | "pr22269-1" \ | |
e062fcc8 | 957 | "-fPIE -O2 $NOSANITIZE_CFLAGS" \ |
f3012016 L |
958 | ] \ |
959 | ] | |
960 | ||
d9816402 AM |
961 | set run_tests [list \ |
962 | [list "Run normal with libfoo.so" \ | |
963 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \ | |
964 | {main.c} "normal" "normal.out" ] \ | |
965 | [list "Run protected with libfoo.so" \ | |
966 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \ | |
967 | {main.c} "protected" "normal.out" ] \ | |
968 | [list "Run hidden with libfoo.so" \ | |
969 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \ | |
970 | {main.c} "hidden" "hidden.out" ] \ | |
971 | [list "Run normal with versioned libfoo.so" \ | |
972 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \ | |
973 | {main.c} "normalv" "normal.out" ] \ | |
974 | [list "Run warn with versioned libfoo.so" \ | |
975 | "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \ | |
976 | {main.c} "warn" "warn.out" \ | |
7dd36a6f | 977 | "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated\n?$} ] \ |
d9816402 AM |
978 | [list "Run protected with versioned libfoo.so" \ |
979 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \ | |
980 | {main.c} "protected" "normal.out" ] \ | |
981 | [list "Run hidden with versioned libfoo.so" \ | |
982 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \ | |
983 | {main.c} "hiddenv" "hidden.out" ] \ | |
984 | [list "Run normal libbar.so with libfoo.so" \ | |
985 | "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \ | |
986 | {main.c} "normal" "normal.out" ] \ | |
987 | [list "Run protected libbar.so with libfoo.so" \ | |
988 | "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \ | |
989 | {main.c} "protected" "normal.out" ] \ | |
990 | [list "Run hidden libbar.so with libfoo.so" \ | |
991 | "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \ | |
992 | {main.c} "hidden" "hidden.out" ] \ | |
993 | [list "Run normal libbar.so with versioned libfoo.so" \ | |
994 | "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \ | |
995 | {main.c} "normal" "normal.out" ] \ | |
996 | [list "Run protected libbar.so with versioned libfoo.so" \ | |
997 | "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \ | |
998 | {main.c} "protected" "normal.out" ] \ | |
999 | [list "Run hidden libbar.so with versioned libfoo.so" \ | |
1000 | "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \ | |
1001 | {main.c} "hidden" "hidden.out" ] \ | |
d9816402 AM |
1002 | [list "Run with libdl2a.so" \ |
1003 | "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \ | |
1004 | {dl2main.c} "dl2a" "dl2a.out" ] \ | |
1005 | [list "Run with libdl2b.so" \ | |
1006 | "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \ | |
1007 | {dl2main.c} "dl2b" "dl2b.out" ] \ | |
1008 | [list "Run with libdl2c.so" \ | |
1009 | "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \ | |
1010 | {dl2main.c} "dl2c" "dl2b.out" ] \ | |
bb68f22c FS |
1011 | [list "Run with libdl2d.so" \ |
1012 | "-Wl,--no-as-needed tmpdir/libdl2d.so" "" \ | |
1013 | {dl2main.c} "dl2d" "dl2a.out" ] \ | |
37a141bf FS |
1014 | [list "Run with libdl2e.so" \ |
1015 | "-Wl,--no-as-needed tmpdir/libdl2e.so" "" \ | |
1016 | {dl2main.c} "dl2e" "dl2b.out" ] \ | |
1017 | [list "Run with libdl2f.so" \ | |
1018 | "-Wl,--no-as-needed tmpdir/libdl2f.so" "" \ | |
1019 | {dl2main.c} "dl2f" "dl2a.out" ] \ | |
1020 | [list "Run with libdl2g.so" \ | |
1021 | "-Wl,--no-as-needed tmpdir/libdl2g.so" "" \ | |
1022 | {dl2main.c} "dl2g" "dl2b.out" ] \ | |
1023 | [list "Run with libdl2h.so" \ | |
1024 | "-Wl,--no-as-needed tmpdir/libdl2h.so" "" \ | |
1025 | {dl2main.c} "dl2h" "dl2a.out" ] \ | |
1026 | [list "Run with libdl2i.so" \ | |
1027 | "-Wl,--no-as-needed tmpdir/libdl2i.so" "" \ | |
1028 | {dl2main.c} "dl2i" "dl2a.out" ] \ | |
1029 | [list "Run with libdl2j.so" \ | |
1030 | "-Wl,--no-as-needed tmpdir/libdl2j.so" "" \ | |
1031 | {dl2main.c} "dl2j" "dl2a.out" ] \ | |
1032 | [list "Run with libdl2k.so" \ | |
1033 | "-Wl,--no-as-needed tmpdir/libdl2k.so" "" \ | |
1034 | {dl2main.c} "dl2k" "dl2a.out" ] \ | |
cf893b0e FS |
1035 | [list "Run with libdl2l.so" \ |
1036 | "-Wl,--no-as-needed tmpdir/libdl2l.so" "" \ | |
1037 | {dl2main.c} "dl2l" "dl2b.out" ] \ | |
d9816402 AM |
1038 | [list "Run with libdl4a.so" \ |
1039 | "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \ | |
a61e3060 | 1040 | {dl4main.c} "dl4a" "dl4a.out" "-fPIC"] \ |
d9816402 AM |
1041 | [list "Run with libdl4b.so" \ |
1042 | "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \ | |
a61e3060 | 1043 | {dl4main.c} "dl4b" "dl4a.out" "-fPIC"] \ |
d9816402 AM |
1044 | [list "Run with libdl4c.so" \ |
1045 | "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \ | |
a61e3060 | 1046 | {dl4main.c} "dl4c" "dl4b.out" "-fPIC"] \ |
d9816402 AM |
1047 | [list "Run with libdl4d.so" \ |
1048 | "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \ | |
a61e3060 | 1049 | {dl4main.c} "dl4d" "dl4b.out" "-fPIC"] \ |
d9816402 AM |
1050 | [list "Run with libdl4e.so" \ |
1051 | "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \ | |
a61e3060 | 1052 | {dl4main.c} "dl4e" "dl4a.out" "-fPIC"] \ |
d9816402 AM |
1053 | [list "Run with libdl4f.so" \ |
1054 | "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \ | |
a61e3060 | 1055 | {dl4main.c} "dl4f" "dl4a.out" "-fPIC"] \ |
d9816402 AM |
1056 | [list "Run with libdata1.so" \ |
1057 | "-Wl,--no-as-needed tmpdir/libdata1.so" "" \ | |
1058 | {dynbss1.c} "dynbss1" "pass.out" ] \ | |
1059 | [list "Run with libdata2.so" \ | |
1060 | "-Wl,--no-as-needed tmpdir/libdata2.so" "" \ | |
1061 | {weakdef1.c} "weakdef1" "pass.out" ] \ | |
1062 | [list "Run with libfunc1.so comm1.o" \ | |
1063 | "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \ | |
1064 | {dummy.c} "comm1" "pass.out" ] \ | |
1065 | [list "Run with comm1.o libfunc1.so" \ | |
1066 | "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \ | |
1067 | {dummy.c} "comm1" "pass.out" ] \ | |
1068 | [list "Run with pr11138-2.c libpr11138-1.so" \ | |
1069 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \ | |
1070 | {dummy.c} "pr11138a" "pr11138.out" ] \ | |
1071 | [list "Run with libpr11138-1.so pr11138-2.c" \ | |
1072 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \ | |
1073 | {dummy.c} "pr11138b" "pr11138.out" ] \ | |
1074 | [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \ | |
0e1f1593 | 1075 | "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "-fcommon" \ |
d9816402 AM |
1076 | {dummy.c} "pr13250" "pass.out" ] \ |
1077 | [list "Run with pr14323-1.c pr14323-2.so" \ | |
1078 | "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \ | |
1079 | {pr14323-1.c} "pr14323" "pass.out" ] \ | |
1080 | [list "Run with pr14862-1.c libpr14862.so" \ | |
1081 | "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \ | |
1082 | {dummy.c} "pr14862" "pr14862.out" ] \ | |
1083 | [list "Link with --add-needed" \ | |
8cfc7cf8 | 1084 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
1085 | {dummy.c} "needed1a" "needed1.out" ] \ |
1086 | [list "Link with --copy-dt-needed-entries" \ | |
8cfc7cf8 | 1087 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
1088 | {dummy.c} "needed1b" "needed1.out" ] \ |
1089 | [list "Run relmain" \ | |
1090 | "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \ | |
1091 | {relmain.c} "relmain" "relmain.out" ] \ | |
1092 | [list "Run pr2404" \ | |
e062fcc8 | 1093 | "$NOSANITIZE_CFLAGS -Wl,--no-as-needed \ |
05fd99cc L |
1094 | tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ |
1095 | "" \ | |
1096 | {dummy.c} "pr2404" "pr2404.out" \ | |
e062fcc8 | 1097 | "$NOSANITIZE_CFLAGS" ] \ |
d6f48aed | 1098 | [list "Run pr2404n" \ |
e062fcc8 | 1099 | "$NOSANITIZE_CFLAGS -Wl,-z,now \ |
05fd99cc L |
1100 | -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \ |
1101 | {dummy.c} "pr2404n" "pr2404.out" \ | |
e062fcc8 | 1102 | "$NOSANITIZE_CFLAGS" ] \ |
d9816402 AM |
1103 | [list "Run pr18458" \ |
1104 | "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \ | |
1105 | {pr18458c.c} "pr18458" "pass.out" ] \ | |
487b6440 | 1106 | [list "Run pr21964-1" \ |
8dfb7cbf L |
1107 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \ |
1108 | {pr21964-1c.c} "pr21964-1" "pass.out" ] \ | |
36b8fda5 AM |
1109 | [list "Run pr21964-3" \ |
1110 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \ | |
1111 | {pr21964-3c.c} "pr21964-3" "pass.out" ] \ | |
7ba11550 AM |
1112 | [list "pr26580-3" \ |
1113 | "" "" \ | |
1114 | {pr26580-a.c} "pr26580-3" "pr26580-3.out" "-fcommon" "c" "" \ | |
1115 | "-Wl,--as-needed tmpdir/libpr26580-2.so" ] \ | |
1116 | [list "pr26580-4" \ | |
1117 | "" "" \ | |
1118 | {pr26580-a.c} "pr26580-4" "pr26580-4.out" "-fcommon" "c" "" \ | |
1119 | "-Wl,--no-as-needed tmpdir/libpr26580-2.so" ] \ | |
93d49941 L |
1120 | [list "Run pr26590 (2)" \ |
1121 | "" "" \ | |
1122 | {pr26590c.c pr26590d.c} "pr26590" "pass.out" "" "c" "" \ | |
1123 | "-Wl,--as-needed tmpdir/libpr26590a.so tmpdir/libpr26590b.so" ] \ | |
d9816402 | 1124 | ] |
d2dee3b2 | 1125 | |
d2dee3b2 | 1126 | # NetBSD ELF systems do not currently support the .*_array sections. |
982c6f26 | 1127 | run_ld_link_exec_tests $run_tests "*-*-netbsdelf*" |
55255dae | 1128 | |
fd121c5c JW |
1129 | # These tests require dlopen support. |
1130 | set dlopen_run_tests [list \ | |
1131 | [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \ | |
1132 | "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \ | |
1133 | {dl1main.c} "dl1a" "dl1.out" ] \ | |
1134 | [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \ | |
1135 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1136 | {dl1main.c} "dl1b" "dl1.out" ] \ | |
1137 | [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \ | |
1138 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1139 | {dl6amain.c} "dl6a1" "dl6a.out" ] \ | |
1140 | [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \ | |
6b737370 L |
1141 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \ |
1142 | {dl6amain.c} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c JW |
1143 | [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \ |
1144 | "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \ | |
1145 | {dl6amain.c} "dl6a3" "dl6b.out" ] \ | |
1146 | [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \ | |
1147 | "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \ | |
1148 | {dl6amain.c} "dl6a4" "dl6a.out" ] \ | |
1149 | [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \ | |
6b737370 L |
1150 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \ |
1151 | {dl6amain.c} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c | 1152 | [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \ |
6b737370 L |
1153 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \ |
1154 | {dl6amain.c} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c | 1155 | [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \ |
6b737370 L |
1156 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \ |
1157 | {dl6amain.c} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c JW |
1158 | [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \ |
1159 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1160 | {dl6bmain.c} "dl6b1" "dl6a.out" ] \ | |
1161 | [list "Run dl6b2 with dlopen on libdl6b.so" \ | |
1162 | "-Wl,--no-as-needed $extralibs" "" \ | |
1163 | {dl6bmain.c} "dl6b2" "dl6b.out" ] \ | |
1164 | [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \ | |
1165 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1166 | {dl6cmain.c} "dl6c1" "dl6b.out" ] \ | |
1167 | [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \ | |
1168 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
bb68f22c | 1169 | {dl6dmain.c} "dl6d1" "dl6a.out" ] \ |
487b6440 | 1170 | [list "Run pr21964-2" \ |
8dfb7cbf L |
1171 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \ |
1172 | {pr21964-2c.c} "pr21964-2" "pass.out" ] \ | |
bf3077a6 MM |
1173 | [list "Run pr21964-5" \ |
1174 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \ | |
1175 | {pr21964-5.c} "pr21964-5" "pass.out" ] \ | |
fd121c5c JW |
1176 | ] |
1177 | ||
1178 | # Only run them when libdl is available. | |
1179 | if [check_libdl_available] { | |
1180 | # XFAIL on NetBSD ELF systems as they do not currently support the .*_array | |
1181 | # sections. | |
42afa120 L |
1182 | # Disable all sanitizers. |
1183 | set old_CFLAGS "$CFLAGS" | |
e062fcc8 | 1184 | append CFLAGS " $NOSANITIZE_CFLAGS" |
fd121c5c | 1185 | run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*" |
42afa120 | 1186 | set CFLAGS "$old_CFLAGS" |
fd121c5c JW |
1187 | } |
1188 | ||
63406f0a L |
1189 | # Check --no-add-needed and --no-copy-dt-needed-entries |
1190 | set testname "--no-add-needed" | |
f1d7f4a6 | 1191 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 1192 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
1193 | pass $testname |
1194 | } { | |
1195 | fail $testname | |
1196 | } | |
1197 | set testname "--no-copy-dt-needed-entries" | |
f1d7f4a6 | 1198 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 1199 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
1200 | pass $testname |
1201 | } { | |
1202 | fail $testname | |
1203 | } | |
8fbb09e8 | 1204 | set testname "--no-add-needed -shared" |
f1d7f4a6 | 1205 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 1206 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
1207 | pass $testname |
1208 | } { | |
1209 | fail $testname | |
1210 | } | |
1211 | set testname "--no-copy-dt-needed-entries -shared" | |
f1d7f4a6 | 1212 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 1213 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
1214 | pass $testname |
1215 | } { | |
1216 | fail $testname | |
1217 | } | |
63406f0a | 1218 | |
dd98f8d2 | 1219 | # Check to see if the C++ compiler works |
55255dae L |
1220 | if { [which $CXX] == 0 } { |
1221 | return | |
1222 | } | |
1223 | ||
1224 | set build_cxx_tests { | |
1225 | {"Build libdl3a.so with --dynamic-list=dl3.list" | |
1226 | "-shared -Wl,--dynamic-list=dl3.list" "-fPIC" | |
1227 | {dl3.cc} {} "libdl3a.so" "c++"} | |
1228 | {"Build libdl3b.so with -Bsymbolic" | |
1229 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
1230 | {dl3.cc} {} "libdl3b.so" "c++"} | |
1231 | {"Build libdl3a.so with --dynamic-list-cpp-typeinfo" | |
1232 | "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC" | |
1233 | {dl3.cc} {} "libdl3c.so" "c++"} | |
1234 | } | |
1235 | ||
05fd99cc L |
1236 | run_cc_link_tests [list \ |
1237 | [list \ | |
1238 | "Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" \ | |
e062fcc8 L |
1239 | "-shared $NOSANITIZE_CFLAGS -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" \ |
1240 | "-fPIC -ansi $NOSANITIZE_CFLAGS" \ | |
05fd99cc L |
1241 | {del.cc new.cc} \ |
1242 | {} \ | |
1243 | "libnew1a.so" \ | |
1244 | "c++" \ | |
1245 | ] \ | |
1246 | [list \ | |
1247 | "Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" \ | |
e062fcc8 L |
1248 | "-shared $NOSANITIZE_CFLAGS -Wl,--dynamic-list-data,--dynamic-list-cpp-new" \ |
1249 | "-fPIC -ansi $NOSANITIZE_CFLAGS" \ | |
05fd99cc L |
1250 | {del.cc new.cc} \ |
1251 | {} \ | |
1252 | "libnew1b.so" \ | |
1253 | "c++" \ | |
1254 | ] \ | |
1255 | ] | |
1256 | ||
b37470e4 L |
1257 | # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer. |
1258 | # {"Run with libdl3b.so" | |
1259 | # "tmpdir/libdl3b.so" "" | |
1260 | # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"} | |
cb5ab6c8 L |
1261 | set run_cxx_tests { |
1262 | {"Run with libdl3a.so" | |
1263 | "-Wl,--no-as-needed tmpdir/libdl3a.so" "" | |
1264 | {dl3main.cc} "dl3a" "dl3a.out" "" "c++"} | |
55255dae | 1265 | {"Run with libdl3c.so" |
5cb49709 | 1266 | "-Wl,--no-as-needed tmpdir/libdl3c.so" "" |
55255dae L |
1267 | {dl3main.cc} "dl3c" "dl3a.out" "" "c++"} |
1268 | } | |
1269 | ||
05fd99cc L |
1270 | run_ld_link_exec_tests [list \ |
1271 | [list \ | |
1272 | "Run with libnew1a.so" \ | |
e062fcc8 | 1273 | "-Wl,--no-as-needed tmpdir/libnew1a.so $NOSANITIZE_CFLAGS" \ |
05fd99cc L |
1274 | "" \ |
1275 | {dl5.cc} \ | |
1276 | "dl5a" \ | |
1277 | "dl5.out" \ | |
e062fcc8 | 1278 | "-ansi $NOSANITIZE_CFLAGS" \ |
05fd99cc L |
1279 | "c++" \ |
1280 | ] \ | |
1281 | [list \ | |
1282 | "Run with libnew1b.so" \ | |
e062fcc8 | 1283 | "-Wl,--no-as-needed tmpdir/libnew1b.so $NOSANITIZE_CFLAGS" \ |
05fd99cc L |
1284 | "" \ |
1285 | {dl5.cc} \ | |
1286 | "dl5b" \ | |
1287 | "dl5.out" \ | |
e062fcc8 | 1288 | "-ansi $NOSANITIZE_CFLAGS" \ |
05fd99cc L |
1289 | "c++" \ |
1290 | ] \ | |
1291 | ] | |
1292 | ||
55255dae | 1293 | run_cc_link_tests $build_cxx_tests |
982c6f26 | 1294 | run_ld_link_exec_tests $run_cxx_tests |
22ef172a L |
1295 | |
1296 | if { [istarget *-*-linux*] | |
1297 | || [istarget *-*-nacl*] | |
1298 | || [istarget *-*-gnu*] } { | |
1299 | run_cc_link_tests [list \ | |
1300 | [list \ | |
1301 | "Build libpr2404b.a with PIE" \ | |
1302 | "" \ | |
e062fcc8 | 1303 | "-fPIE $NOSANITIZE_CFLAGS" \ |
22ef172a L |
1304 | { pr2404b.c } \ |
1305 | {} \ | |
1306 | "libpr2404b.a" \ | |
1307 | ] \ | |
07492f66 L |
1308 | [list \ |
1309 | "Build pr19579a.o" \ | |
d2dbcb18 | 1310 | "" "-fPIE -fcommon" \ |
07492f66 L |
1311 | {pr19579a.c} \ |
1312 | {} \ | |
1313 | "libpr19579a.a" \ | |
1314 | ] \ | |
1315 | [list \ | |
1316 | "Build libpr19579.so" \ | |
1317 | "-shared" \ | |
d2dbcb18 | 1318 | "-fPIC -fcommon" \ |
07492f66 L |
1319 | {pr19579b.c} \ |
1320 | {} \ | |
1321 | "libpr19579.so" \ | |
1322 | ] \ | |
d6f48aed L |
1323 | [list \ |
1324 | "Build libpr19579now.so" \ | |
1325 | "-shared -Wl,-z,now" \ | |
d2dbcb18 | 1326 | "-fPIC -fcommon" \ |
d6f48aed L |
1327 | {pr19579b.c} \ |
1328 | {} \ | |
1329 | "libpr19579.so" \ | |
1330 | ] \ | |
d346bb27 L |
1331 | [list \ |
1332 | "Build pr22393-2a.so" \ | |
1333 | "-shared -Wl,-z,separate-code" \ | |
1334 | "-fPIC" \ | |
1335 | {pr22393-2a.c} \ | |
1336 | {{readelf -lW pr22393-2a.rd} \ | |
1337 | {readelf -lW pr22393-2b.rd}} \ | |
1338 | "pr22393-2a.so" \ | |
1339 | ] \ | |
1340 | [list \ | |
1341 | "Build pr22393-2a-now.so" \ | |
1342 | "-shared -Wl,-z,separate-code,-z,now" \ | |
1343 | "-fPIC" \ | |
1344 | {pr22393-2a.c} \ | |
1345 | {{readelf -lW pr22393-2a.rd} \ | |
1346 | {readelf -lW pr22393-2b.rd}} \ | |
1347 | "pr22393-2a-now.so" \ | |
1348 | ] \ | |
1349 | [list \ | |
1350 | "Build pr22393-2" \ | |
1351 | "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \ | |
1352 | "$NOPIE_CFLAGS" \ | |
1353 | {pr22393-2b.c} \ | |
1354 | {{readelf -lW pr22393-2a.rd} \ | |
1355 | {readelf -lW pr22393-2b.rd}} \ | |
1356 | "pr22393-2" \ | |
1357 | ] \ | |
1358 | [list \ | |
1359 | "Build pr22393-2 (PIE)" \ | |
1360 | "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \ | |
1361 | "-fPIE" \ | |
1362 | {pr22393-2b.c} \ | |
1363 | {{readelf -lW pr22393-2a.rd} \ | |
1364 | {readelf -lW pr22393-2b.rd}} \ | |
1365 | "pr22393-2-pie" \ | |
1366 | ] \ | |
1367 | [list \ | |
1368 | "Build pr22393-2 (static)" \ | |
1369 | "-static -Wl,-z,separate-code" \ | |
1370 | "" \ | |
1371 | {pr22393-2a.c pr22393-2b.c} \ | |
1372 | {{readelf -lW pr22393-2a.rd} \ | |
1373 | {readelf -lW pr22393-2b.rd}} \ | |
1374 | "pr22393-2-static" \ | |
1375 | ] \ | |
22ef172a | 1376 | ] |
982c6f26 | 1377 | run_ld_link_exec_tests [list \ |
d6f48aed L |
1378 | [list \ |
1379 | "Run pr18458 with PIE" \ | |
1380 | "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \ | |
1381 | "" \ | |
1382 | {pr18458c.c} \ | |
1383 | "pr18458p" \ | |
1384 | "pass.out" \ | |
1385 | "-fPIE" \ | |
1386 | ] \ | |
22ef172a L |
1387 | [list \ |
1388 | "Run pr2404 with PIE" \ | |
e062fcc8 | 1389 | "-pie $NOSANITIZE_CFLAGS -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ |
22ef172a L |
1390 | "" \ |
1391 | { dummy.c } \ | |
1392 | "pr2404pie" \ | |
1393 | "pr2404.out" \ | |
e062fcc8 | 1394 | "-fPIE $NOSANITIZE_CFLAGS" \ |
22ef172a | 1395 | ] \ |
d6f48aed L |
1396 | [list \ |
1397 | "Run pr2404 with PIE (-z now)" \ | |
e062fcc8 | 1398 | "-pie $NOSANITIZE_CFLAGS -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \ |
d6f48aed L |
1399 | "" \ |
1400 | { dummy.c } \ | |
1401 | "pr2404pien" \ | |
1402 | "pr2404.out" \ | |
e062fcc8 | 1403 | "-fPIE $NOSANITIZE_CFLAGS" \ |
d6f48aed | 1404 | ] \ |
1659f720 L |
1405 | [list \ |
1406 | "Run pr18718" \ | |
1407 | "" \ | |
1408 | "" \ | |
c45bd4fd | 1409 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1410 | "pr18718" \ |
1411 | "pass.out" \ | |
edcab5e8 | 1412 | "-O2 -I../bfd" \ |
1659f720 | 1413 | ] \ |
d6f48aed L |
1414 | [list \ |
1415 | "Run pr18718 (-z now)" \ | |
1416 | "-Wl,-z,now" \ | |
1417 | "" \ | |
1418 | { pr18718.c check-ptr-eq.c } \ | |
1419 | "pr18718" \ | |
1420 | "pass.out" \ | |
1421 | "-O2 -I../bfd" \ | |
1422 | ] \ | |
1659f720 L |
1423 | [list \ |
1424 | "Run pr18718 with PIE (1)" \ | |
1425 | "-pie" \ | |
1426 | "" \ | |
c45bd4fd | 1427 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1428 | "pr18718pie1" \ |
1429 | "pass.out" \ | |
edcab5e8 | 1430 | "-O2 -fPIE -I../bfd" \ |
1659f720 L |
1431 | ] \ |
1432 | [list \ | |
1433 | "Run pr18718 with PIE (2)" \ | |
1434 | "" \ | |
1435 | "" \ | |
c45bd4fd | 1436 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1437 | "pr18718pie2" \ |
1438 | "pass.out" \ | |
edcab5e8 | 1439 | "-O2 -fPIE -I../bfd" \ |
1659f720 | 1440 | ] \ |
d6f48aed L |
1441 | [list \ |
1442 | "Run pr18718 with PIE (3)" \ | |
1443 | "-pie -Wl,-z,now" \ | |
1444 | "" \ | |
1445 | { pr18718.c check-ptr-eq.c } \ | |
1446 | "pr18718pie3" \ | |
1447 | "pass.out" \ | |
1448 | "-O2 -fPIE -I../bfd" \ | |
1449 | ] \ | |
1450 | [list \ | |
1451 | "Run pr18718 with PIE (4)" \ | |
1452 | "-Wl,-z,now" \ | |
1453 | "" \ | |
1454 | { pr18718.c check-ptr-eq.c } \ | |
1455 | "pr18718pie4" \ | |
1456 | "pass.out" \ | |
1457 | "-O2 -fPIE -I../bfd" \ | |
1458 | ] \ | |
1659f720 L |
1459 | [list \ |
1460 | "Run pr18718 with PIC (1)" \ | |
1461 | "" \ | |
1462 | "" \ | |
c45bd4fd | 1463 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1464 | "pr18718pic1" \ |
1465 | "pass.out" \ | |
edcab5e8 | 1466 | "-O2 -fPIC -I../bfd" \ |
1659f720 L |
1467 | ] \ |
1468 | [list \ | |
1469 | "Run pr18718 with PIC (2)" \ | |
1470 | "-pie" \ | |
1471 | "" \ | |
c45bd4fd | 1472 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1473 | "pr18718pic2" \ |
1474 | "pass.out" \ | |
edcab5e8 | 1475 | "-O2 -fPIC -I../bfd" \ |
1659f720 | 1476 | ] \ |
d6f48aed L |
1477 | [list \ |
1478 | "Run pr18718 with PIC (3)" \ | |
1479 | "-Wl,-z,now" \ | |
1480 | "" \ | |
1481 | { pr18718.c check-ptr-eq.c } \ | |
1482 | "pr18718pic3" \ | |
1483 | "pass.out" \ | |
1484 | "-O2 -fPIC -I../bfd" \ | |
1485 | ] \ | |
1486 | [list \ | |
1487 | "Run pr18718 with PIC (4)" \ | |
1488 | "-pie -Wl,-z,now" \ | |
1489 | "" \ | |
1490 | { pr18718.c check-ptr-eq.c } \ | |
1491 | "pr18718pic4" \ | |
1492 | "pass.out" \ | |
1493 | "-O2 -fPIC -I../bfd" \ | |
1494 | ] \ | |
07492f66 L |
1495 | [list \ |
1496 | "Run pr19579" \ | |
d9816402 | 1497 | "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ |
07492f66 L |
1498 | "" \ |
1499 | {dummy.c} \ | |
1500 | "pr19579" \ | |
1501 | "pass.out" \ | |
1502 | "-fPIE" \ | |
1503 | ] \ | |
d6f48aed L |
1504 | [list \ |
1505 | "Run pr19579 (-z now)" \ | |
1506 | "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ | |
1507 | "" \ | |
1508 | {dummy.c} \ | |
1509 | "pr19579n" \ | |
1510 | "pass.out" \ | |
1511 | "-fPIE" \ | |
1512 | ] \ | |
d346bb27 L |
1513 | [list \ |
1514 | "Run pr22393-2" \ | |
1515 | "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \ | |
1516 | "" \ | |
1517 | {pr22393-2b.c} \ | |
1518 | "pr22393-2" \ | |
1519 | "pass.out" \ | |
1520 | "$NOPIE_CFLAGS" \ | |
1521 | ] \ | |
1522 | [list \ | |
1523 | "Run pr22393-2 (PIE)" \ | |
1524 | "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \ | |
1525 | "" \ | |
1526 | {pr22393-2b.c} \ | |
1527 | "pr22393-2-pie" \ | |
1528 | "pass.out" \ | |
1529 | "-fPIE" \ | |
1530 | ] \ | |
1531 | [list \ | |
1532 | "Run pr22393-2 (static)" \ | |
1533 | "-static -Wl,-z,separate-code" \ | |
1534 | "" \ | |
1535 | {pr22393-2a.c pr22393-2b.c} \ | |
1536 | "pr22393-2-static" \ | |
1537 | "pass.out" \ | |
1538 | ] \ | |
823143c6 L |
1539 | [list \ |
1540 | "Run pr21964-4" \ | |
1541 | "" \ | |
1542 | "" \ | |
1543 | {pr21964-4.c} \ | |
1544 | "pr21964-4" \ | |
1545 | "pass.out" \ | |
1546 | "" \ | |
1547 | "" \ | |
1548 | "" \ | |
1549 | "-ldl" \ | |
1550 | ] \ | |
22ef172a L |
1551 | ] |
1552 | } | |
aec6b87e | 1553 | |
f1b2ca70 | 1554 | proc mix_pic_and_non_pic {xfails cflags ldflags exe} { |
aec6b87e L |
1555 | run_cc_link_tests [list \ |
1556 | [list \ | |
1557 | "Build libpr19719a.so" \ | |
1558 | "-shared -Wl,-soname,libpr19719.so" \ | |
1559 | "-fPIC" \ | |
1560 | { pr19719d.c } \ | |
1561 | {} \ | |
1562 | "libpr19719a.so" \ | |
1563 | ] \ | |
1564 | [list \ | |
1565 | "Build libpr19719b.so" \ | |
1566 | "-shared -Wl,-soname,libpr19719.so" \ | |
1567 | "-fPIC" \ | |
1568 | { dummy.c } \ | |
1569 | {} \ | |
1570 | "libpr19719b.so" \ | |
1571 | ] \ | |
1572 | [list \ | |
f1b2ca70 | 1573 | "Build libpr19719b.o" \ |
aec6b87e L |
1574 | "-r -nostdlib" \ |
1575 | "-fPIC" \ | |
1576 | { pr19719b.c } \ | |
1577 | {} \ | |
1578 | "libpr19719b.o" \ | |
1579 | ] \ | |
1580 | ] | |
1581 | ||
f1b2ca70 | 1582 | send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n" |
aec6b87e L |
1583 | exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so |
1584 | ||
982c6f26 | 1585 | run_ld_link_exec_tests [list \ |
aec6b87e | 1586 | [list \ |
f1b2ca70 | 1587 | "Run $exe fun defined" \ |
d9816402 | 1588 | "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \ |
aec6b87e L |
1589 | "" \ |
1590 | { pr19719a.c pr19719c.c } \ | |
f1b2ca70 | 1591 | $exe \ |
aec6b87e L |
1592 | "pass.out" \ |
1593 | "$cflags" \ | |
1594 | ] \ | |
1595 | ] | |
1596 | ||
f1b2ca70 | 1597 | send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n" |
aec6b87e L |
1598 | exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so |
1599 | ||
7494161b L |
1600 | foreach targ $xfails { |
1601 | setup_xfail $targ | |
1602 | } | |
1603 | ||
d9816402 AM |
1604 | if ![isnative] { |
1605 | unsupported "Run $exe fun undefined" | |
1606 | return | |
1607 | } | |
1608 | ||
f1b2ca70 | 1609 | set exec_output [run_host_cmd "tmpdir/$exe" ""] |
aec6b87e | 1610 | if {![string match "PASS" $exec_output]} { |
f1b2ca70 | 1611 | fail "Run $exe fun undefined" |
aec6b87e | 1612 | } else { |
f1b2ca70 | 1613 | pass "Run $exe fun undefined" |
aec6b87e L |
1614 | } |
1615 | } | |
1616 | ||
f1b2ca70 AM |
1617 | mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719" |
1618 | mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie" | |
9bc935ef | 1619 | |
7f923b7f AM |
1620 | set AFLAGS_PIE "" |
1621 | if { [istarget "i?86-*-*"] | |
1622 | || [istarget "x86_64-*-*"] } { | |
1623 | set AFLAGS_PIE "-mrelax-relocations=yes" | |
1624 | } | |
be7628ca MP |
1625 | if [istarget "sparc*-*-*"] { |
1626 | set AFLAGS_PIE "-Av9" | |
1627 | } | |
7f923b7f AM |
1628 | |
1629 | if { ([istarget "*-*-linux*"] | |
1630 | || [istarget "*-*-nacl*"] | |
1631 | || [istarget "*-*-gnu*"]) | |
1632 | && ![istarget "mips*-*-*"] } { | |
9bc935ef L |
1633 | run_ld_link_tests [list \ |
1634 | [list \ | |
1635 | "Build libpr23162a.so" \ | |
1636 | "-shared" \ | |
1637 | "" \ | |
1638 | "$AFLAGS_PIC" \ | |
1639 | { pr23162a.c } \ | |
1640 | "" \ | |
1641 | "libpr23162a.so" \ | |
e062fcc8 | 1642 | "-fPIC -O2 $NOSANITIZE_CFLAGS" \ |
9bc935ef L |
1643 | ] \ |
1644 | [list \ | |
1645 | "Build pr23162a" \ | |
1646 | "-pie --no-as-needed tmpdir/libpr23162a.so" \ | |
1647 | "" \ | |
7f923b7f | 1648 | $AFLAGS_PIE \ |
9bc935ef | 1649 | { pr23162b.c } \ |
7f923b7f | 1650 | {{readelf {-rW} pr23162.rd}} \ |
9bc935ef | 1651 | "pr23162a" \ |
e062fcc8 | 1652 | "-fPIC -O0 $NOSANITIZE_CFLAGS" \ |
9bc935ef L |
1653 | ] \ |
1654 | [list \ | |
1655 | "Build libpr23162b.so" \ | |
1656 | "-shared --version-script=pr23162.map" \ | |
1657 | "" \ | |
1658 | "$AFLAGS_PIC" \ | |
1659 | { pr23162a.c } \ | |
1660 | "" \ | |
1661 | "libpr23162b.so" \ | |
e062fcc8 | 1662 | "-fPIC -O2 $NOSANITIZE_CFLAGS" \ |
9bc935ef L |
1663 | ] \ |
1664 | [list \ | |
1665 | "Build pr23162b" \ | |
1666 | "-pie --no-as-needed tmpdir/libpr23162b.so" \ | |
1667 | "" \ | |
7f923b7f | 1668 | $AFLAGS_PIE \ |
9bc935ef | 1669 | { pr23162b.c } \ |
7f923b7f | 1670 | {{readelf {-rW} pr23162.rd}} \ |
9bc935ef | 1671 | "pr23162b" \ |
e062fcc8 | 1672 | "-fPIC -O0 $NOSANITIZE_CFLAGS" \ |
9bc935ef | 1673 | ] \ |
fd161d86 AM |
1674 | [list \ |
1675 | "Build libpr23161a.so" \ | |
1676 | "-shared" \ | |
1677 | "" \ | |
1678 | "$AFLAGS_PIC" \ | |
1679 | { pr23161a.c } \ | |
1680 | {{readelf {--dyn-syms -rW} pr23161a.rd}} \ | |
1681 | "libpr23161a.so" \ | |
e062fcc8 | 1682 | "-fPIC -O2 $NOSANITIZE_CFLAGS" \ |
fd161d86 AM |
1683 | ] \ |
1684 | [list \ | |
1685 | "Build pr23161a" \ | |
1686 | "-pie --no-as-needed tmpdir/libpr23161a.so" \ | |
1687 | "" \ | |
7f923b7f | 1688 | $AFLAGS_PIE \ |
fd161d86 AM |
1689 | { pr23161b.c } \ |
1690 | {{readelf {--dyn-syms -rW} pr23161b.rd}} \ | |
1691 | "pr23161a" \ | |
e062fcc8 | 1692 | "-fPIC -O0 $NOSANITIZE_CFLAGS" \ |
fd161d86 AM |
1693 | ] \ |
1694 | [list \ | |
1695 | "Build libpr23161b.so" \ | |
1696 | "-shared --version-script=pr23161.map" \ | |
1697 | "" \ | |
1698 | "$AFLAGS_PIC" \ | |
1699 | { pr23161a.c } \ | |
1700 | {{readelf {--dyn-syms -rW} pr23161a.rd}} \ | |
1701 | "libpr23161b.so" \ | |
e062fcc8 | 1702 | "-fPIC -O2 $NOSANITIZE_CFLAGS" \ |
fd161d86 AM |
1703 | ] \ |
1704 | [list \ | |
1705 | "Build pr23161b" \ | |
1706 | "-pie --no-as-needed tmpdir/libpr23161b.so" \ | |
1707 | "" \ | |
7f923b7f | 1708 | $AFLAGS_PIE \ |
fd161d86 AM |
1709 | { pr23161b.c } \ |
1710 | {{readelf {--dyn-syms -rW} pr23161b.rd}} \ | |
1711 | "pr23161b" \ | |
e062fcc8 | 1712 | "-fPIC -O0 $NOSANITIZE_CFLAGS" \ |
fd161d86 | 1713 | ] \ |
7f923b7f AM |
1714 | ] |
1715 | } | |
1716 | ||
1717 | if { [istarget "i?86-*-*"] | |
1718 | || [istarget "x86_64-*-*"] } { | |
1719 | run_ld_link_tests [list \ | |
fd161d86 AM |
1720 | [list \ |
1721 | "Build libpr23161c.so" \ | |
1722 | "-shared" \ | |
1723 | "" \ | |
1724 | "$AFLAGS_PIC" \ | |
1725 | { pr23161c.c } \ | |
1726 | {{readelf {--dyn-syms -rW} pr23161c.rd}} \ | |
1727 | "libpr23161c.so" \ | |
e062fcc8 | 1728 | "-fPIC -O2 $NOSANITIZE_CFLAGS" \ |
fd161d86 AM |
1729 | ] \ |
1730 | [list \ | |
1731 | "Build pr23161c" \ | |
1732 | "-pie --no-as-needed tmpdir/libpr23161c.so" \ | |
1733 | "" \ | |
7f923b7f | 1734 | $AFLAGS_PIE \ |
fd161d86 AM |
1735 | { pr23161b.c } \ |
1736 | {{readelf {--dyn-syms -rW} pr23161d.rd}} \ | |
1737 | "pr23161c" \ | |
e062fcc8 | 1738 | "-fPIC -O0 $NOSANITIZE_CFLAGS" \ |
fd161d86 | 1739 | ] \ |
9bc935ef L |
1740 | ] |
1741 | } | |
fb9bbfd7 L |
1742 | |
1743 | run_ld_link_tests [list \ | |
1744 | [list "Build pr23658.so" \ | |
1745 | "-shared" "" "$AFLAGS_PIC" \ | |
1746 | {pr23658-1a.s} {} "pr23658.so"] \ | |
1747 | [list \ | |
1748 | "Build pr23658-2" \ | |
1749 | "--dynamic-linker tmpdir/pr23658.so --no-as-needed tmpdir/pr23658.so" \ | |
1750 | "" \ | |
1751 | $AFLAGS_NOTE \ | |
1752 | { pr23658-1a.s pr23658-1b.s pr23658-1c.s pr23658-1d.s start.s } \ | |
1753 | {{readelf {-lW} pr23658-2.rd}} \ | |
1754 | "pr23658-2" \ | |
1755 | ] \ | |
1756 | ] |