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