Commit | Line | Data |
---|---|---|
d2dee3b2 | 1 | # Expect script for various ELF tests. |
b3adc24a | 2 | # Copyright (C) 2006-2020 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 | ||
6b737370 L |
34 | # Add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if non-PIE is required. |
35 | global NOPIE_CFLAGS NOPIE_LDFLAGS | |
36 | ||
66824765 AM |
37 | set old_ASFLAGS $ASFLAGS |
38 | ||
81ff47b3 MR |
39 | # This target requires extra GAS options when building code for shared |
40 | # libraries. | |
41 | set AFLAGS_PIC "" | |
18e404c4 AM |
42 | if [istarget "nds32*-*"] { |
43 | append AFLAGS_PIC " -mpic" | |
44 | } | |
81ff47b3 MR |
45 | if [istarget "tic6x-*-*"] { |
46 | append AFLAGS_PIC " -mpic -mpid=near" | |
47 | } | |
185cdb8c | 48 | if [istarget "sparc*-*-*"] { |
ae4b1d73 | 49 | append AFLAGS_PIC " -K PIC -Av9" |
185cdb8c EB |
50 | } |
51 | ||
fb9bbfd7 L |
52 | # GAS options to disable program property note. |
53 | set AFLAGS_NOTE "" | |
54 | if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } { | |
55 | append AFLAGS_NOTE "-mx86-used-note=no" | |
56 | } | |
57 | ||
81ff47b3 MR |
58 | # This target requires a non-default emulation for successful shared |
59 | # library/executable builds. | |
60 | set LFLAGS "" | |
61 | if [istarget "tic6x-*-*"] { | |
62 | append LFLAGS " -melf32_tic6x_le" | |
63 | } | |
f3a9baf1 MR |
64 | # HPUX targets use a different .comm syntax. |
65 | set hpux "" | |
66 | if [istarget "*-*-hpux*"] { | |
67 | set hpux "--defsym HPUX=1" | |
68 | } | |
8988502d MR |
69 | # These targets do not default to linking with shared libraries. |
70 | if { [istarget "mips*vr4100*-*-elf*"] \ | |
71 | || [istarget "mips*vr4300*-*-elf*"] \ | |
72 | || [istarget "mips*vr5000*-*-elf*"] } { | |
73 | append LFLAGS " -call_shared" | |
74 | } | |
81ff47b3 | 75 | |
08f650e6 L |
76 | if [is_underscore_target] { |
77 | set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1" | |
78 | } | |
79 | ||
80 | run_ld_link_tests [list \ | |
81 | [list \ | |
82 | "Build pr22471a.so" \ | |
83 | "$LFLAGS -shared" \ | |
84 | "" \ | |
85 | "$AFLAGS_PIC" \ | |
86 | {pr22471a.s} \ | |
87 | {} \ | |
88 | "pr22471a.so" \ | |
89 | ] \ | |
90 | [list \ | |
91 | "Build pr22471b.so" \ | |
92 | "$LFLAGS -shared --version-script pr22471.t" \ | |
93 | "tmpdir/pr22471a.so" \ | |
94 | "$AFLAGS_PIC" \ | |
95 | {pr22471a.s} \ | |
96 | {} \ | |
97 | "pr22471b.so" \ | |
98 | ] \ | |
99 | [list \ | |
100 | "Build pr22471" \ | |
101 | "$LFLAGS -rpath-link ." \ | |
102 | "tmpdir/pr22471b.so" \ | |
103 | "" \ | |
104 | {pr22471b.s} \ | |
105 | {} \ | |
106 | "pr22471" \ | |
107 | ] \ | |
d664fd41 L |
108 | [list \ |
109 | "Build pr22649-1.so" \ | |
110 | "$LFLAGS -shared" \ | |
111 | "" \ | |
112 | "$AFLAGS_PIC" \ | |
113 | {pr22649-1.s} \ | |
114 | {} \ | |
115 | "pr22649-1.so" \ | |
116 | ] \ | |
08f650e6 L |
117 | ] |
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 | ] \ | |
183 | ] "xtensa-*-*" | |
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 | ] \ | |
a4eb6927 | 200 | ] "cris*-*-*" "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. | |
385 | run_ld_link_tests [list \ | |
386 | [list "PR ld/14170" \ | |
8988502d MR |
387 | "$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \ |
388 | $hpux \ | |
f3a9baf1 MR |
389 | {pr14170c.s} { } "pr14170" ] \ |
390 | ] "bfin-*-*" | |
391 | ||
392 | # Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests | |
1336939d | 393 | # Nor will hppa64 with dot-symbols. |
e54d3c94 MR |
394 | run_ld_link_tests [list \ |
395 | [list "PR ld/21703 shared" \ | |
396 | "-shared --allow-multiple-definition --version-script pr21703.ver\ | |
397 | tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "$AFLAGS_PIC" \ | |
398 | {pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} \ | |
399 | "pr21703.so" ] \ | |
1336939d | 400 | ] \[is_generic\] hppa64-*-* |
f3a9baf1 MR |
401 | |
402 | # This target requires extra GAS options when building non-PIC code | |
403 | # for linking with shared libraries. | |
404 | set AFLAGS_NONPIC "" | |
405 | if [istarget "mips*-*-*"] { | |
406 | append AFLAGS_NONPIC " -call_nonpic" | |
407 | } | |
408 | ||
409 | # Run a test to check linking a shared library with a broken linker | |
410 | # script that accidentally marks dynamic sections as notes. The | |
411 | # resulting executable is not expected to work, but the linker | |
412 | # should not seg-fault whilst creating the binary. | |
e54d3c94 MR |
413 | run_ld_link_tests [list \ |
414 | [list "Build shared library for broken linker script test" \ | |
415 | "-shared --hash-style=sysv" "" "$AFLAGS_PIC" "note-3.s" \ | |
416 | {} \ | |
417 | "note-3.so" ] \ | |
418 | [list "Link using broken linker script" \ | |
419 | "$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" "" \ | |
420 | { { ld "note-3.l" } } \ | |
421 | "a.out" ] \ | |
422 | ] | |
f3a9baf1 | 423 | |
e54d3c94 MR |
424 | run_ld_link_tests [list \ |
425 | [list "Build pr17068.so" \ | |
426 | "-shared" "" "$AFLAGS_PIC" \ | |
427 | {pr17068d.s} {} "pr17068.so"] \ | |
428 | [list "Build pr17068a.a" \ | |
429 | "" "" "" \ | |
430 | {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"] \ | |
431 | [list "Build pr17068b.a" \ | |
432 | "" "" "" \ | |
433 | {pr17068b.s pr17068e.s} {} "pr17068b.a"] \ | |
434 | ] | |
f3a9baf1 MR |
435 | |
436 | # bfin does not currently support copy relocs. | |
437 | run_ld_link_tests { | |
438 | {"pr17068 link --as-needed lib in group" | |
8988502d MR |
439 | "$LFLAGS --as-needed --no-dynamic-linker" |
440 | "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\ | |
441 | --end-group" "" | |
f3a9baf1 MR |
442 | {start.s pr17068.s} {} "pr17068"} |
443 | } "bfin-*-*" | |
444 | ||
f3a9baf1 MR |
445 | # Fails on MIPS because ABI trickery means that a NULL reloc is emitted. |
446 | # Fails on bfin because relocations are not created. | |
e54d3c94 MR |
447 | run_ld_link_tests [list \ |
448 | [list "-Bsymbolic-functions" \ | |
449 | "-shared -Bsymbolic-functions" "" "$AFLAGS_PIC" \ | |
450 | {symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}} \ | |
451 | "symbolic-func.so"] \ | |
452 | ] "mips*-*-*" "bfin-*-*" | |
f3a9baf1 | 453 | |
e54d3c94 MR |
454 | run_ld_link_tests [list \ |
455 | [list "Build pr20995.so" \ | |
456 | "-shared" "" "$AFLAGS_PIC" \ | |
457 | {pr20995b.s} {} "pr20995.so"] \ | |
458 | ] | |
f3a9baf1 MR |
459 | |
460 | # xfail on arm*-*-eabi*. The list can be enlarged to those targets that | |
461 | # don't support GNU_RELRO. For more details, please see discussions at: | |
462 | # https://sourceware.org/ml/binutils/2017-01/msg00441.html | |
e54d3c94 MR |
463 | run_ld_link_tests [list \ |
464 | [list "Build pr20995-2.so" \ | |
465 | "-shared -z relro" "" "$AFLAGS_PIC" \ | |
466 | {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"] \ | |
c93c0e7f | 467 | ] "tic6x-*-*" "arm*-*-eabi*" "hppa*64*-*-hpux*" "aarch64*-*-elf*" \ |
767be9d9 | 468 | "*-*-lynxos*" "arm*-*-nto*" "i?86-*-nto*" "sh*-*-nto*" |
f3a9baf1 MR |
469 | |
470 | # These targets don't copy dynamic variables into .bss. | |
471 | setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" | |
472 | # or don't have .data.rel.ro | |
473 | setup_xfail "hppa*64*-*-hpux*" | |
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 | ||
480 | # xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO. | |
481 | # Please see the link above for details. | |
482 | setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*" | |
cbac2231 | 483 | setup_xfail "hppa*64*-*-hpux*" "aarch64*-*-elf*" |
f3a9baf1 MR |
484 | run_ld_link_tests [list \ |
485 | [list \ | |
486 | "pr20995-2" \ | |
8988502d | 487 | "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \ |
c93c0e7f | 488 | {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"] |
767be9d9 | 489 | ] "*-*-lynxos*" "arm*-*-nto*" "i?86-*-nto*" "sh*-*-nto*" |
f3a9baf1 | 490 | |
e54d3c94 MR |
491 | run_ld_link_tests [list \ |
492 | [list "Build pr22374 shared library" \ | |
493 | "-shared" "" "$AFLAGS_PIC" "pr22374b.s" {} "pr22374.so" ] \ | |
494 | ] | |
f3a9baf1 | 495 | if { ![istarget "alpha-*-*"] |
28a66f07 | 496 | && ![istarget "csky-*-*"] |
f3a9baf1 MR |
497 | && ![istarget "frv-*-*"] |
498 | && ![istarget "hppa*-*-*"] | |
499 | && ![istarget "i?86-*-*"] | |
500 | && ![istarget "ia64-*-*"] | |
501 | && ![istarget "microblaze-*-*"] | |
502 | && ![istarget "powerpc*-*-*"] | |
503 | && ![istarget "x86_64-*-*"] | |
504 | && ![istarget "xtensa-*-*"] } { | |
505 | # The next test checks that copy relocs are not used unnecessarily, | |
506 | # but that is just an optimization so don't complain loudly. | |
507 | setup_xfail "*-*-*" | |
508 | } | |
509 | run_ld_link_tests { | |
510 | {"pr22374 function pointer initialization" | |
511 | "" "tmpdir/pr22374.so" "" "pr22374a.s" | |
512 | { {readelf {--wide -r --dyn-syms} "pr22374-1.r"} | |
513 | {readelf {--wide -r} "pr22374-2.r"} } | |
514 | "pr22374" } | |
515 | } | |
516 | ||
517 | if { [istarget *-*-linux*] | |
518 | || [istarget *-*-nacl*] | |
519 | || [istarget *-*-gnu*] } { | |
520 | run_ld_link_tests { | |
521 | {"Weak symbols in dynamic objects 1 (support)" | |
522 | "-shared" "" "" {weak-dyn-1a.s} | |
523 | {} | |
524 | "libweakdyn1a.so"} | |
525 | {"Weak symbols in dynamic objects 1 (main test)" | |
526 | "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s} | |
527 | {{readelf {--relocs --wide} weak-dyn-1.rd}} | |
528 | "libweakdyn1b.so"} | |
529 | } | |
530 | } | |
531 | ||
dd98f8d2 | 532 | # Check to see if the C compiler works |
44ed8092 | 533 | if { ![check_compiler_available] } { |
d2dee3b2 L |
534 | return |
535 | } | |
536 | ||
fb2c6e43 | 537 | # Add -ldl to extralibs if needed |
d9816402 | 538 | set extralibs "" |
fb2c6e43 AT |
539 | if { ![istarget *-*-freebsd*]} { |
540 | set extralibs "-ldl" | |
541 | } | |
542 | ||
d2dee3b2 L |
543 | set build_tests { |
544 | {"Build libfoo.so" | |
545 | "-shared" "-fPIC" | |
546 | {foo.c} {} "libfoo.so"} | |
547 | {"Build versioned libfoo.so" | |
548 | "-shared -Wl,--version-script=foo.map" "-fPIC" | |
55255dae | 549 | {foo.c} {} "libfoov.so"} |
d2dee3b2 L |
550 | {"Build libbar.so" |
551 | "-shared" "-fPIC" | |
552 | {begin.c end.c} {} "libbar.so"} | |
fab4a87f L |
553 | {"Build warn libbar.so" |
554 | "-shared" "-fPIC" | |
2bd7f877 AB |
555 | {beginwarn.c end.c} |
556 | {{readelf {-S --wide} libbarw.rd} | |
7dd36a6f | 557 | {warning "^.*beginwarn.c:7: warning: function foo is deprecated\n?$"}} |
2bd7f877 | 558 | "libbarw.so" "c"} |
d2dee3b2 L |
559 | {"Build hidden libbar.so" |
560 | "-shared" "-fPIC" | |
561 | {begin.c endhidden.c} {} "libbarh.so"} | |
562 | {"Build protected libbar.so" | |
563 | "-shared" "-fPIC" | |
564 | {begin.c endprotected.c} {} "libbarp.so"} | |
565 | {"Build libbar.so with libfoo.so" | |
566 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
567 | {end.c} {} "libbarfoo.so"} | |
568 | {"Build libar.so with versioned libfoo.so" | |
569 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
570 | {end.c} {} "libbarfoov.so"} | |
571 | {"Build hidden libbar.so with libfoo.so" | |
572 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
573 | {endhidden.c} {} "libbarhfoo.so"} | |
574 | {"Build hidden libar.so with versioned libfoo.so" | |
575 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
576 | {endhidden.c} {} "libbarhfoov.so"} | |
577 | {"Build protected libbar.so with libfoo.so" | |
578 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
579 | {endprotected.c} {} "libbarpfoo.so"} | |
580 | {"Build protected libbar.so with versioned libfoo.so" | |
581 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
582 | {endprotected.c} {} "libbarpfoov.so"} | |
55255dae L |
583 | {"Build libdl1.so" |
584 | "-shared" "-fPIC" | |
585 | {dl1.c} {} "libdl1.so"} | |
586 | {"Build libdl2a.so with --dynamic-list=dl2.list" | |
587 | "-shared -Wl,--dynamic-list=dl2.list" "-fPIC" | |
588 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
b7b7fe3f AS |
589 | {"Build libdl2a.so with --dynamic-list=dl2a.list" |
590 | "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC" | |
591 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
40b36307 L |
592 | {"Build libdl2a.so with --dynamic-list-data" |
593 | "-shared -Wl,--dynamic-list-data" "-fPIC" | |
594 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
55255dae L |
595 | {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list" |
596 | "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC" | |
597 | {dl2.c dl2xxx.c} {} "libdl2b.so"} | |
d8cf8b51 | 598 | {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list" |
40b36307 | 599 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC" |
d8cf8b51 | 600 | {dl2.c dl2xxx.c} {} "libdl2c.so"} |
bb68f22c FS |
601 | {"Build libdl2d.so with --dynamic-list-data -Bsymbolic" |
602 | "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC" | |
603 | {dl2.c dl2xxx.c} {} "libdl2d.so"} | |
37a141bf FS |
604 | {"Build libdl2e.so with --export-dynamic-symbol=foo" |
605 | "-shared -Wl,--export-dynamic-symbol=foo" "-fPIC" | |
606 | {dl2.c dl2xxx.c} {} "libdl2e.so"} | |
607 | {"Build libdl2f.so with --dynamic-list=dlempty.list and --export-dynamic-symbol=foo" | |
608 | "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol=foo" "-fPIC" | |
609 | {dl2.c dl2xxx.c} {} "libdl2f.so"} | |
610 | {"Build libdl2g.so with --export-dynamic-symbol-list=dl2.list" | |
611 | "-shared -Wl,--export-dynamic-symbol-list=dl2.list" "-fPIC" | |
612 | {dl2.c dl2xxx.c} {} "libdl2g.so"} | |
613 | {"Build libdl2h.so with --dynamic-list=dlempty.list and --export-dynamic-symbol-list=dl2.list" | |
614 | "-shared -Wl,--dynamic-list=dlempty.list,--export-dynamic-symbol-list=dl2.list" "-fPIC" | |
615 | {dl2.c dl2xxx.c} {} "libdl2h.so"} | |
616 | {"Build libdl2i.so with -Bsymbolic and --export-dynamic-symbol=foo" | |
617 | "-shared -Wl,-Bsymbolic,--export-dynamic-symbol=foo" "-fPIC" | |
618 | {dl2.c dl2xxx.c} {} "libdl2i.so"} | |
619 | {"Build libdl2j.so with -Bsymbolic and --export-dynamic-symbol-list=dl2.list" | |
620 | "-shared -Wl,-Bsymbolic,--export-dynamic-symbol-list=dl2.list" "-fPIC" | |
621 | {dl2.c dl2xxx.c} {} "libdl2j.so"} | |
622 | {"Build libdl2k.so with --export-dynamic-symbol-list=dl2.list and -Bsymbolic" | |
623 | "-shared -Wl,--export-dynamic-symbol-list=dl2.list,-Bsymbolic" "-fPIC" | |
624 | {dl2.c dl2xxx.c} {} "libdl2k.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"} | |
cec2c50d L |
761 | {"Build libpr2404a.so" |
762 | "-shared" "-fPIC" | |
763 | {pr2404a.c} {} "libpr2404a.so"} | |
d6f48aed L |
764 | {"Build libpr2404n.so" |
765 | "-shared -Wl,-z,now" "-fPIC" | |
766 | {pr2404a.c} {} "libpr2404n.so"} | |
cec2c50d L |
767 | {"Build libpr2404b.a" |
768 | "" "" | |
769 | {pr2404b.c} {} "libpr2404b.a"} | |
50a53d3f | 770 | {"Build rdynamic-1" |
8569cfa7 | 771 | "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections" |
50a53d3f | 772 | {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"} |
d6f6f455 | 773 | {"Build dynamic-1" |
8569cfa7 | 774 | "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections" |
d6f6f455 | 775 | {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"} |
bb4d2ac2 L |
776 | {"Build libpr16496a.so" |
777 | "-shared -Wl,--version-script=pr16496a.map" "-fPIC" | |
778 | {pr16496a.c} {} "libpr16496a.so"} | |
779 | {"Build libpr16496b.a" | |
780 | "" "-fPIC" | |
781 | {pr16496b.c} {} "libpr16496b.a"} | |
782 | {"Build libpr16496b.so" | |
8cfc7cf8 | 783 | "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" "" |
bb4d2ac2 | 784 | {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"} |
fb389763 L |
785 | {"Build libpr16452a.so" |
786 | "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC" | |
787 | {pr16452a.c} {} "libpr16452a.so"} | |
788 | {"Build libpr16452b.so" | |
789 | "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC" | |
790 | {dummy.c} {} "libpr16452b.so"} | |
791 | {"Build pr16452" | |
8cfc7cf8 | 792 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 L |
793 | {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"} |
794 | {"Build pr16457" | |
8cfc7cf8 | 795 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 | 796 | {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"} |
8ded2ddc L |
797 | {"Build libpr18458a.so" |
798 | "-shared -Wl,-z,now" "-fPIC" | |
799 | {pr18458a.c} {} "libpr18458a.so"} | |
800 | {"Build libpr18458b.so" | |
801 | "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC" | |
802 | {pr18458b.c} {} "libpr18458b.so"} | |
8e3152af AM |
803 | } |
804 | # pr19073.s uses .set, which has a different meaning on alpha. | |
805 | if { ![istarget alpha-*-*] } { | |
806 | append build_tests { | |
807 | {"Build pr19073a.o" | |
808 | "-r -nostdlib" "" | |
809 | {pr19073.s} {} "pr19073a.o"} | |
810 | {"Build libpr19073.so" | |
811 | "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC" | |
812 | {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"} | |
813 | } | |
814 | } | |
815 | append build_tests { | |
8dfb7cbf | 816 | {"Build pr21964-1a.so" |
487b6440 | 817 | "-shared" "-fPIC" |
8dfb7cbf L |
818 | {pr21964-1a.c} {} "pr21964-1a.so"} |
819 | {"Build pr21964-1b.so" | |
487b6440 | 820 | "-shared" "-fPIC" |
8dfb7cbf L |
821 | {pr21964-1b.c} {} "pr21964-1b.so"} |
822 | {"Build pr21964-2a.so" | |
823 | "-shared" "-fPIC" | |
824 | {pr21964-2a.c} {} "pr21964-2a.so"} | |
825 | {"Build pr21964-2b.so" | |
826 | "-shared" "-fPIC" | |
827 | {pr21964-2b.c} {} "pr21964-2b.so"} | |
36b8fda5 AM |
828 | {"Build pr21964-3a.so" |
829 | "-shared" "-fPIC" | |
830 | {pr21964-3a.c} {} "pr21964-3a.so"} | |
2715765b L |
831 | {"Dump pr21978.so" |
832 | "-shared" "-fPIC -g -O2" | |
833 | {pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"} | |
d2dee3b2 L |
834 | } |
835 | ||
dd98f8d2 NC |
836 | run_cc_link_tests $build_tests |
837 | ||
f3012016 L |
838 | run_ld_link_tests [list \ |
839 | [list \ | |
ef0cc92e AM |
840 | "pr22269-1 (static pie undefined weak)" \ |
841 | "-pie -e _start --no-dynamic-linker -z text -z nocombreloc " \ | |
f3012016 | 842 | "" \ |
185cdb8c | 843 | "$AFLAGS_PIC" \ |
f3012016 L |
844 | { pr22269-1.c } \ |
845 | {{readelf -rW pr22269-1.rd}} \ | |
846 | "pr22269-1" \ | |
847 | "-fPIE -O2" \ | |
848 | ] \ | |
849 | ] | |
850 | ||
d9816402 AM |
851 | set run_tests [list \ |
852 | [list "Run normal with libfoo.so" \ | |
853 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \ | |
854 | {main.c} "normal" "normal.out" ] \ | |
855 | [list "Run protected with libfoo.so" \ | |
856 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \ | |
857 | {main.c} "protected" "normal.out" ] \ | |
858 | [list "Run hidden with libfoo.so" \ | |
859 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \ | |
860 | {main.c} "hidden" "hidden.out" ] \ | |
861 | [list "Run normal with versioned libfoo.so" \ | |
862 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \ | |
863 | {main.c} "normalv" "normal.out" ] \ | |
864 | [list "Run warn with versioned libfoo.so" \ | |
865 | "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \ | |
866 | {main.c} "warn" "warn.out" \ | |
7dd36a6f | 867 | "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated\n?$} ] \ |
d9816402 AM |
868 | [list "Run protected with versioned libfoo.so" \ |
869 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \ | |
870 | {main.c} "protected" "normal.out" ] \ | |
871 | [list "Run hidden with versioned libfoo.so" \ | |
872 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \ | |
873 | {main.c} "hiddenv" "hidden.out" ] \ | |
874 | [list "Run normal libbar.so with libfoo.so" \ | |
875 | "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \ | |
876 | {main.c} "normal" "normal.out" ] \ | |
877 | [list "Run protected libbar.so with libfoo.so" \ | |
878 | "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \ | |
879 | {main.c} "protected" "normal.out" ] \ | |
880 | [list "Run hidden libbar.so with libfoo.so" \ | |
881 | "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \ | |
882 | {main.c} "hidden" "hidden.out" ] \ | |
883 | [list "Run normal libbar.so with versioned libfoo.so" \ | |
884 | "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \ | |
885 | {main.c} "normal" "normal.out" ] \ | |
886 | [list "Run protected libbar.so with versioned libfoo.so" \ | |
887 | "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \ | |
888 | {main.c} "protected" "normal.out" ] \ | |
889 | [list "Run hidden libbar.so with versioned libfoo.so" \ | |
890 | "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \ | |
891 | {main.c} "hidden" "hidden.out" ] \ | |
d9816402 AM |
892 | [list "Run with libdl2a.so" \ |
893 | "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \ | |
894 | {dl2main.c} "dl2a" "dl2a.out" ] \ | |
895 | [list "Run with libdl2b.so" \ | |
896 | "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \ | |
897 | {dl2main.c} "dl2b" "dl2b.out" ] \ | |
898 | [list "Run with libdl2c.so" \ | |
899 | "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \ | |
900 | {dl2main.c} "dl2c" "dl2b.out" ] \ | |
bb68f22c FS |
901 | [list "Run with libdl2d.so" \ |
902 | "-Wl,--no-as-needed tmpdir/libdl2d.so" "" \ | |
903 | {dl2main.c} "dl2d" "dl2a.out" ] \ | |
37a141bf FS |
904 | [list "Run with libdl2e.so" \ |
905 | "-Wl,--no-as-needed tmpdir/libdl2e.so" "" \ | |
906 | {dl2main.c} "dl2e" "dl2b.out" ] \ | |
907 | [list "Run with libdl2f.so" \ | |
908 | "-Wl,--no-as-needed tmpdir/libdl2f.so" "" \ | |
909 | {dl2main.c} "dl2f" "dl2a.out" ] \ | |
910 | [list "Run with libdl2g.so" \ | |
911 | "-Wl,--no-as-needed tmpdir/libdl2g.so" "" \ | |
912 | {dl2main.c} "dl2g" "dl2b.out" ] \ | |
913 | [list "Run with libdl2h.so" \ | |
914 | "-Wl,--no-as-needed tmpdir/libdl2h.so" "" \ | |
915 | {dl2main.c} "dl2h" "dl2a.out" ] \ | |
916 | [list "Run with libdl2i.so" \ | |
917 | "-Wl,--no-as-needed tmpdir/libdl2i.so" "" \ | |
918 | {dl2main.c} "dl2i" "dl2a.out" ] \ | |
919 | [list "Run with libdl2j.so" \ | |
920 | "-Wl,--no-as-needed tmpdir/libdl2j.so" "" \ | |
921 | {dl2main.c} "dl2j" "dl2a.out" ] \ | |
922 | [list "Run with libdl2k.so" \ | |
923 | "-Wl,--no-as-needed tmpdir/libdl2k.so" "" \ | |
924 | {dl2main.c} "dl2k" "dl2a.out" ] \ | |
d9816402 AM |
925 | [list "Run with libdl4a.so" \ |
926 | "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \ | |
927 | {dl4main.c} "dl4a" "dl4a.out" ] \ | |
928 | [list "Run with libdl4b.so" \ | |
929 | "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \ | |
930 | {dl4main.c} "dl4b" "dl4a.out" ] \ | |
931 | [list "Run with libdl4c.so" \ | |
932 | "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \ | |
933 | {dl4main.c} "dl4c" "dl4b.out" ] \ | |
934 | [list "Run with libdl4d.so" \ | |
935 | "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \ | |
936 | {dl4main.c} "dl4d" "dl4b.out" ] \ | |
937 | [list "Run with libdl4e.so" \ | |
938 | "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \ | |
bb68f22c | 939 | {dl4main.c} "dl4e" "dl4e.out" ] \ |
d9816402 AM |
940 | [list "Run with libdl4f.so" \ |
941 | "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \ | |
bb68f22c | 942 | {dl4main.c} "dl4f" "dl4e.out" ] \ |
d9816402 AM |
943 | [list "Run with libdata1.so" \ |
944 | "-Wl,--no-as-needed tmpdir/libdata1.so" "" \ | |
945 | {dynbss1.c} "dynbss1" "pass.out" ] \ | |
946 | [list "Run with libdata2.so" \ | |
947 | "-Wl,--no-as-needed tmpdir/libdata2.so" "" \ | |
948 | {weakdef1.c} "weakdef1" "pass.out" ] \ | |
949 | [list "Run with libfunc1.so comm1.o" \ | |
950 | "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \ | |
951 | {dummy.c} "comm1" "pass.out" ] \ | |
952 | [list "Run with comm1.o libfunc1.so" \ | |
953 | "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \ | |
954 | {dummy.c} "comm1" "pass.out" ] \ | |
955 | [list "Run with pr11138-2.c libpr11138-1.so" \ | |
956 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \ | |
957 | {dummy.c} "pr11138a" "pr11138.out" ] \ | |
958 | [list "Run with libpr11138-1.so pr11138-2.c" \ | |
959 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \ | |
960 | {dummy.c} "pr11138b" "pr11138.out" ] \ | |
961 | [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \ | |
0e1f1593 | 962 | "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "-fcommon" \ |
d9816402 AM |
963 | {dummy.c} "pr13250" "pass.out" ] \ |
964 | [list "Run with pr14323-1.c pr14323-2.so" \ | |
965 | "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \ | |
966 | {pr14323-1.c} "pr14323" "pass.out" ] \ | |
967 | [list "Run with pr14862-1.c libpr14862.so" \ | |
968 | "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \ | |
969 | {dummy.c} "pr14862" "pr14862.out" ] \ | |
970 | [list "Link with --add-needed" \ | |
8cfc7cf8 | 971 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
972 | {dummy.c} "needed1a" "needed1.out" ] \ |
973 | [list "Link with --copy-dt-needed-entries" \ | |
8cfc7cf8 | 974 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
975 | {dummy.c} "needed1b" "needed1.out" ] \ |
976 | [list "Run relmain" \ | |
977 | "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \ | |
978 | {relmain.c} "relmain" "relmain.out" ] \ | |
979 | [list "Run pr2404" \ | |
980 | "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \ | |
981 | {dummy.c} "pr2404" "pr2404.out" ] \ | |
d6f48aed L |
982 | [list "Run pr2404n" \ |
983 | "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \ | |
984 | {dummy.c} "pr2404n" "pr2404.out" ] \ | |
d9816402 AM |
985 | [list "Run pr18458" \ |
986 | "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \ | |
987 | {pr18458c.c} "pr18458" "pass.out" ] \ | |
487b6440 | 988 | [list "Run pr21964-1" \ |
8dfb7cbf L |
989 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \ |
990 | {pr21964-1c.c} "pr21964-1" "pass.out" ] \ | |
36b8fda5 AM |
991 | [list "Run pr21964-3" \ |
992 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \ | |
993 | {pr21964-3c.c} "pr21964-3" "pass.out" ] \ | |
d9816402 | 994 | ] |
d2dee3b2 | 995 | |
d2dee3b2 | 996 | # NetBSD ELF systems do not currently support the .*_array sections. |
982c6f26 | 997 | run_ld_link_exec_tests $run_tests "*-*-netbsdelf*" |
55255dae | 998 | |
fd121c5c JW |
999 | # These tests require dlopen support. |
1000 | set dlopen_run_tests [list \ | |
1001 | [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \ | |
1002 | "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \ | |
1003 | {dl1main.c} "dl1a" "dl1.out" ] \ | |
1004 | [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \ | |
1005 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1006 | {dl1main.c} "dl1b" "dl1.out" ] \ | |
1007 | [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \ | |
1008 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1009 | {dl6amain.c} "dl6a1" "dl6a.out" ] \ | |
1010 | [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \ | |
6b737370 L |
1011 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \ |
1012 | {dl6amain.c} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c JW |
1013 | [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \ |
1014 | "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \ | |
1015 | {dl6amain.c} "dl6a3" "dl6b.out" ] \ | |
1016 | [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \ | |
1017 | "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \ | |
1018 | {dl6amain.c} "dl6a4" "dl6a.out" ] \ | |
1019 | [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \ | |
6b737370 L |
1020 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \ |
1021 | {dl6amain.c} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c | 1022 | [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \ |
6b737370 L |
1023 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \ |
1024 | {dl6amain.c} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c | 1025 | [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \ |
6b737370 L |
1026 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \ |
1027 | {dl6amain.c} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c JW |
1028 | [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \ |
1029 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1030 | {dl6bmain.c} "dl6b1" "dl6a.out" ] \ | |
1031 | [list "Run dl6b2 with dlopen on libdl6b.so" \ | |
1032 | "-Wl,--no-as-needed $extralibs" "" \ | |
1033 | {dl6bmain.c} "dl6b2" "dl6b.out" ] \ | |
1034 | [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \ | |
1035 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
1036 | {dl6cmain.c} "dl6c1" "dl6b.out" ] \ | |
1037 | [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \ | |
1038 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
bb68f22c | 1039 | {dl6dmain.c} "dl6d1" "dl6a.out" ] \ |
487b6440 | 1040 | [list "Run pr21964-2" \ |
8dfb7cbf L |
1041 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \ |
1042 | {pr21964-2c.c} "pr21964-2" "pass.out" ] \ | |
bf3077a6 MM |
1043 | [list "Run pr21964-5" \ |
1044 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \ | |
1045 | {pr21964-5.c} "pr21964-5" "pass.out" ] \ | |
fd121c5c JW |
1046 | ] |
1047 | ||
1048 | # Only run them when libdl is available. | |
1049 | if [check_libdl_available] { | |
1050 | # XFAIL on NetBSD ELF systems as they do not currently support the .*_array | |
1051 | # sections. | |
1052 | run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*" | |
1053 | } | |
1054 | ||
63406f0a L |
1055 | # Check --no-add-needed and --no-copy-dt-needed-entries |
1056 | set testname "--no-add-needed" | |
f1d7f4a6 | 1057 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 1058 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
1059 | pass $testname |
1060 | } { | |
1061 | fail $testname | |
1062 | } | |
1063 | set testname "--no-copy-dt-needed-entries" | |
f1d7f4a6 | 1064 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 1065 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
1066 | pass $testname |
1067 | } { | |
1068 | fail $testname | |
1069 | } | |
8fbb09e8 | 1070 | set testname "--no-add-needed -shared" |
f1d7f4a6 | 1071 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 1072 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
1073 | pass $testname |
1074 | } { | |
1075 | fail $testname | |
1076 | } | |
1077 | set testname "--no-copy-dt-needed-entries -shared" | |
f1d7f4a6 | 1078 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 1079 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
1080 | pass $testname |
1081 | } { | |
1082 | fail $testname | |
1083 | } | |
63406f0a | 1084 | |
dd98f8d2 | 1085 | # Check to see if the C++ compiler works |
55255dae L |
1086 | if { [which $CXX] == 0 } { |
1087 | return | |
1088 | } | |
1089 | ||
1090 | set build_cxx_tests { | |
1091 | {"Build libdl3a.so with --dynamic-list=dl3.list" | |
1092 | "-shared -Wl,--dynamic-list=dl3.list" "-fPIC" | |
1093 | {dl3.cc} {} "libdl3a.so" "c++"} | |
1094 | {"Build libdl3b.so with -Bsymbolic" | |
1095 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
1096 | {dl3.cc} {} "libdl3b.so" "c++"} | |
1097 | {"Build libdl3a.so with --dynamic-list-cpp-typeinfo" | |
1098 | "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC" | |
1099 | {dl3.cc} {} "libdl3c.so" "c++"} | |
d8cf8b51 | 1100 | {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" |
199add01 | 1101 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi" |
d8cf8b51 L |
1102 | {del.cc new.cc} {} "libnew1a.so" "c++"} |
1103 | {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" | |
199add01 | 1104 | "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi" |
d8cf8b51 | 1105 | {del.cc new.cc} {} "libnew1b.so" "c++"} |
55255dae L |
1106 | } |
1107 | ||
b37470e4 L |
1108 | # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer. |
1109 | # {"Run with libdl3b.so" | |
1110 | # "tmpdir/libdl3b.so" "" | |
1111 | # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"} | |
cb5ab6c8 L |
1112 | set run_cxx_tests { |
1113 | {"Run with libdl3a.so" | |
1114 | "-Wl,--no-as-needed tmpdir/libdl3a.so" "" | |
1115 | {dl3main.cc} "dl3a" "dl3a.out" "" "c++"} | |
55255dae | 1116 | {"Run with libdl3c.so" |
5cb49709 | 1117 | "-Wl,--no-as-needed tmpdir/libdl3c.so" "" |
55255dae | 1118 | {dl3main.cc} "dl3c" "dl3a.out" "" "c++"} |
d8cf8b51 | 1119 | {"Run with libnew1a.so" |
d9816402 | 1120 | "-Wl,--no-as-needed tmpdir/libnew1a.so" "" |
199add01 | 1121 | {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"} |
d8cf8b51 | 1122 | {"Run with libnew1b.so" |
d9816402 | 1123 | "-Wl,--no-as-needed tmpdir/libnew1b.so" "" |
199add01 | 1124 | {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"} |
55255dae L |
1125 | } |
1126 | ||
1127 | run_cc_link_tests $build_cxx_tests | |
982c6f26 | 1128 | run_ld_link_exec_tests $run_cxx_tests |
22ef172a L |
1129 | |
1130 | if { [istarget *-*-linux*] | |
1131 | || [istarget *-*-nacl*] | |
1132 | || [istarget *-*-gnu*] } { | |
1133 | run_cc_link_tests [list \ | |
1134 | [list \ | |
1135 | "Build libpr2404b.a with PIE" \ | |
1136 | "" \ | |
1137 | "-fPIE" \ | |
1138 | { pr2404b.c } \ | |
1139 | {} \ | |
1140 | "libpr2404b.a" \ | |
1141 | ] \ | |
07492f66 L |
1142 | [list \ |
1143 | "Build pr19579a.o" \ | |
d2dbcb18 | 1144 | "" "-fPIE -fcommon" \ |
07492f66 L |
1145 | {pr19579a.c} \ |
1146 | {} \ | |
1147 | "libpr19579a.a" \ | |
1148 | ] \ | |
1149 | [list \ | |
1150 | "Build libpr19579.so" \ | |
1151 | "-shared" \ | |
d2dbcb18 | 1152 | "-fPIC -fcommon" \ |
07492f66 L |
1153 | {pr19579b.c} \ |
1154 | {} \ | |
1155 | "libpr19579.so" \ | |
1156 | ] \ | |
d6f48aed L |
1157 | [list \ |
1158 | "Build libpr19579now.so" \ | |
1159 | "-shared -Wl,-z,now" \ | |
d2dbcb18 | 1160 | "-fPIC -fcommon" \ |
d6f48aed L |
1161 | {pr19579b.c} \ |
1162 | {} \ | |
1163 | "libpr19579.so" \ | |
1164 | ] \ | |
d346bb27 L |
1165 | [list \ |
1166 | "Build pr22393-2a.so" \ | |
1167 | "-shared -Wl,-z,separate-code" \ | |
1168 | "-fPIC" \ | |
1169 | {pr22393-2a.c} \ | |
1170 | {{readelf -lW pr22393-2a.rd} \ | |
1171 | {readelf -lW pr22393-2b.rd}} \ | |
1172 | "pr22393-2a.so" \ | |
1173 | ] \ | |
1174 | [list \ | |
1175 | "Build pr22393-2a-now.so" \ | |
1176 | "-shared -Wl,-z,separate-code,-z,now" \ | |
1177 | "-fPIC" \ | |
1178 | {pr22393-2a.c} \ | |
1179 | {{readelf -lW pr22393-2a.rd} \ | |
1180 | {readelf -lW pr22393-2b.rd}} \ | |
1181 | "pr22393-2a-now.so" \ | |
1182 | ] \ | |
1183 | [list \ | |
1184 | "Build pr22393-2" \ | |
1185 | "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \ | |
1186 | "$NOPIE_CFLAGS" \ | |
1187 | {pr22393-2b.c} \ | |
1188 | {{readelf -lW pr22393-2a.rd} \ | |
1189 | {readelf -lW pr22393-2b.rd}} \ | |
1190 | "pr22393-2" \ | |
1191 | ] \ | |
1192 | [list \ | |
1193 | "Build pr22393-2 (PIE)" \ | |
1194 | "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \ | |
1195 | "-fPIE" \ | |
1196 | {pr22393-2b.c} \ | |
1197 | {{readelf -lW pr22393-2a.rd} \ | |
1198 | {readelf -lW pr22393-2b.rd}} \ | |
1199 | "pr22393-2-pie" \ | |
1200 | ] \ | |
1201 | [list \ | |
1202 | "Build pr22393-2 (static)" \ | |
1203 | "-static -Wl,-z,separate-code" \ | |
1204 | "" \ | |
1205 | {pr22393-2a.c pr22393-2b.c} \ | |
1206 | {{readelf -lW pr22393-2a.rd} \ | |
1207 | {readelf -lW pr22393-2b.rd}} \ | |
1208 | "pr22393-2-static" \ | |
1209 | ] \ | |
22ef172a | 1210 | ] |
982c6f26 | 1211 | run_ld_link_exec_tests [list \ |
d6f48aed L |
1212 | [list \ |
1213 | "Run pr18458 with PIE" \ | |
1214 | "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \ | |
1215 | "" \ | |
1216 | {pr18458c.c} \ | |
1217 | "pr18458p" \ | |
1218 | "pass.out" \ | |
1219 | "-fPIE" \ | |
1220 | ] \ | |
22ef172a L |
1221 | [list \ |
1222 | "Run pr2404 with PIE" \ | |
d9816402 | 1223 | "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ |
22ef172a L |
1224 | "" \ |
1225 | { dummy.c } \ | |
1226 | "pr2404pie" \ | |
1227 | "pr2404.out" \ | |
1228 | "-fPIE" \ | |
1229 | ] \ | |
d6f48aed L |
1230 | [list \ |
1231 | "Run pr2404 with PIE (-z now)" \ | |
1232 | "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \ | |
1233 | "" \ | |
1234 | { dummy.c } \ | |
1235 | "pr2404pien" \ | |
1236 | "pr2404.out" \ | |
1237 | "-fPIE" \ | |
1238 | ] \ | |
1659f720 L |
1239 | [list \ |
1240 | "Run pr18718" \ | |
1241 | "" \ | |
1242 | "" \ | |
c45bd4fd | 1243 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1244 | "pr18718" \ |
1245 | "pass.out" \ | |
edcab5e8 | 1246 | "-O2 -I../bfd" \ |
1659f720 | 1247 | ] \ |
d6f48aed L |
1248 | [list \ |
1249 | "Run pr18718 (-z now)" \ | |
1250 | "-Wl,-z,now" \ | |
1251 | "" \ | |
1252 | { pr18718.c check-ptr-eq.c } \ | |
1253 | "pr18718" \ | |
1254 | "pass.out" \ | |
1255 | "-O2 -I../bfd" \ | |
1256 | ] \ | |
1659f720 L |
1257 | [list \ |
1258 | "Run pr18718 with PIE (1)" \ | |
1259 | "-pie" \ | |
1260 | "" \ | |
c45bd4fd | 1261 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1262 | "pr18718pie1" \ |
1263 | "pass.out" \ | |
edcab5e8 | 1264 | "-O2 -fPIE -I../bfd" \ |
1659f720 L |
1265 | ] \ |
1266 | [list \ | |
1267 | "Run pr18718 with PIE (2)" \ | |
1268 | "" \ | |
1269 | "" \ | |
c45bd4fd | 1270 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1271 | "pr18718pie2" \ |
1272 | "pass.out" \ | |
edcab5e8 | 1273 | "-O2 -fPIE -I../bfd" \ |
1659f720 | 1274 | ] \ |
d6f48aed L |
1275 | [list \ |
1276 | "Run pr18718 with PIE (3)" \ | |
1277 | "-pie -Wl,-z,now" \ | |
1278 | "" \ | |
1279 | { pr18718.c check-ptr-eq.c } \ | |
1280 | "pr18718pie3" \ | |
1281 | "pass.out" \ | |
1282 | "-O2 -fPIE -I../bfd" \ | |
1283 | ] \ | |
1284 | [list \ | |
1285 | "Run pr18718 with PIE (4)" \ | |
1286 | "-Wl,-z,now" \ | |
1287 | "" \ | |
1288 | { pr18718.c check-ptr-eq.c } \ | |
1289 | "pr18718pie4" \ | |
1290 | "pass.out" \ | |
1291 | "-O2 -fPIE -I../bfd" \ | |
1292 | ] \ | |
1659f720 L |
1293 | [list \ |
1294 | "Run pr18718 with PIC (1)" \ | |
1295 | "" \ | |
1296 | "" \ | |
c45bd4fd | 1297 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1298 | "pr18718pic1" \ |
1299 | "pass.out" \ | |
edcab5e8 | 1300 | "-O2 -fPIC -I../bfd" \ |
1659f720 L |
1301 | ] \ |
1302 | [list \ | |
1303 | "Run pr18718 with PIC (2)" \ | |
1304 | "-pie" \ | |
1305 | "" \ | |
c45bd4fd | 1306 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1307 | "pr18718pic2" \ |
1308 | "pass.out" \ | |
edcab5e8 | 1309 | "-O2 -fPIC -I../bfd" \ |
1659f720 | 1310 | ] \ |
d6f48aed L |
1311 | [list \ |
1312 | "Run pr18718 with PIC (3)" \ | |
1313 | "-Wl,-z,now" \ | |
1314 | "" \ | |
1315 | { pr18718.c check-ptr-eq.c } \ | |
1316 | "pr18718pic3" \ | |
1317 | "pass.out" \ | |
1318 | "-O2 -fPIC -I../bfd" \ | |
1319 | ] \ | |
1320 | [list \ | |
1321 | "Run pr18718 with PIC (4)" \ | |
1322 | "-pie -Wl,-z,now" \ | |
1323 | "" \ | |
1324 | { pr18718.c check-ptr-eq.c } \ | |
1325 | "pr18718pic4" \ | |
1326 | "pass.out" \ | |
1327 | "-O2 -fPIC -I../bfd" \ | |
1328 | ] \ | |
07492f66 L |
1329 | [list \ |
1330 | "Run pr19579" \ | |
d9816402 | 1331 | "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ |
07492f66 L |
1332 | "" \ |
1333 | {dummy.c} \ | |
1334 | "pr19579" \ | |
1335 | "pass.out" \ | |
1336 | "-fPIE" \ | |
1337 | ] \ | |
d6f48aed L |
1338 | [list \ |
1339 | "Run pr19579 (-z now)" \ | |
1340 | "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ | |
1341 | "" \ | |
1342 | {dummy.c} \ | |
1343 | "pr19579n" \ | |
1344 | "pass.out" \ | |
1345 | "-fPIE" \ | |
1346 | ] \ | |
d346bb27 L |
1347 | [list \ |
1348 | "Run pr22393-2" \ | |
1349 | "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \ | |
1350 | "" \ | |
1351 | {pr22393-2b.c} \ | |
1352 | "pr22393-2" \ | |
1353 | "pass.out" \ | |
1354 | "$NOPIE_CFLAGS" \ | |
1355 | ] \ | |
1356 | [list \ | |
1357 | "Run pr22393-2 (PIE)" \ | |
1358 | "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \ | |
1359 | "" \ | |
1360 | {pr22393-2b.c} \ | |
1361 | "pr22393-2-pie" \ | |
1362 | "pass.out" \ | |
1363 | "-fPIE" \ | |
1364 | ] \ | |
1365 | [list \ | |
1366 | "Run pr22393-2 (static)" \ | |
1367 | "-static -Wl,-z,separate-code" \ | |
1368 | "" \ | |
1369 | {pr22393-2a.c pr22393-2b.c} \ | |
1370 | "pr22393-2-static" \ | |
1371 | "pass.out" \ | |
1372 | ] \ | |
823143c6 L |
1373 | [list \ |
1374 | "Run pr21964-4" \ | |
1375 | "" \ | |
1376 | "" \ | |
1377 | {pr21964-4.c} \ | |
1378 | "pr21964-4" \ | |
1379 | "pass.out" \ | |
1380 | "" \ | |
1381 | "" \ | |
1382 | "" \ | |
1383 | "-ldl" \ | |
1384 | ] \ | |
22ef172a L |
1385 | ] |
1386 | } | |
aec6b87e | 1387 | |
f1b2ca70 | 1388 | proc mix_pic_and_non_pic {xfails cflags ldflags exe} { |
aec6b87e L |
1389 | run_cc_link_tests [list \ |
1390 | [list \ | |
1391 | "Build libpr19719a.so" \ | |
1392 | "-shared -Wl,-soname,libpr19719.so" \ | |
1393 | "-fPIC" \ | |
1394 | { pr19719d.c } \ | |
1395 | {} \ | |
1396 | "libpr19719a.so" \ | |
1397 | ] \ | |
1398 | [list \ | |
1399 | "Build libpr19719b.so" \ | |
1400 | "-shared -Wl,-soname,libpr19719.so" \ | |
1401 | "-fPIC" \ | |
1402 | { dummy.c } \ | |
1403 | {} \ | |
1404 | "libpr19719b.so" \ | |
1405 | ] \ | |
1406 | [list \ | |
f1b2ca70 | 1407 | "Build libpr19719b.o" \ |
aec6b87e L |
1408 | "-r -nostdlib" \ |
1409 | "-fPIC" \ | |
1410 | { pr19719b.c } \ | |
1411 | {} \ | |
1412 | "libpr19719b.o" \ | |
1413 | ] \ | |
1414 | ] | |
1415 | ||
f1b2ca70 | 1416 | send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n" |
aec6b87e L |
1417 | exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so |
1418 | ||
982c6f26 | 1419 | run_ld_link_exec_tests [list \ |
aec6b87e | 1420 | [list \ |
f1b2ca70 | 1421 | "Run $exe fun defined" \ |
d9816402 | 1422 | "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \ |
aec6b87e L |
1423 | "" \ |
1424 | { pr19719a.c pr19719c.c } \ | |
f1b2ca70 | 1425 | $exe \ |
aec6b87e L |
1426 | "pass.out" \ |
1427 | "$cflags" \ | |
1428 | ] \ | |
1429 | ] | |
1430 | ||
f1b2ca70 | 1431 | send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n" |
aec6b87e L |
1432 | exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so |
1433 | ||
7494161b L |
1434 | foreach targ $xfails { |
1435 | setup_xfail $targ | |
1436 | } | |
1437 | ||
d9816402 AM |
1438 | if ![isnative] { |
1439 | unsupported "Run $exe fun undefined" | |
1440 | return | |
1441 | } | |
1442 | ||
f1b2ca70 | 1443 | set exec_output [run_host_cmd "tmpdir/$exe" ""] |
aec6b87e | 1444 | if {![string match "PASS" $exec_output]} { |
f1b2ca70 | 1445 | fail "Run $exe fun undefined" |
aec6b87e | 1446 | } else { |
f1b2ca70 | 1447 | pass "Run $exe fun undefined" |
aec6b87e L |
1448 | } |
1449 | } | |
1450 | ||
f1b2ca70 AM |
1451 | mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719" |
1452 | mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie" | |
9bc935ef | 1453 | |
7f923b7f AM |
1454 | set AFLAGS_PIE "" |
1455 | if { [istarget "i?86-*-*"] | |
1456 | || [istarget "x86_64-*-*"] } { | |
1457 | set AFLAGS_PIE "-mrelax-relocations=yes" | |
1458 | } | |
1459 | ||
1460 | if { ([istarget "*-*-linux*"] | |
1461 | || [istarget "*-*-nacl*"] | |
1462 | || [istarget "*-*-gnu*"]) | |
1463 | && ![istarget "mips*-*-*"] } { | |
9bc935ef L |
1464 | run_ld_link_tests [list \ |
1465 | [list \ | |
1466 | "Build libpr23162a.so" \ | |
1467 | "-shared" \ | |
1468 | "" \ | |
1469 | "$AFLAGS_PIC" \ | |
1470 | { pr23162a.c } \ | |
1471 | "" \ | |
1472 | "libpr23162a.so" \ | |
1473 | "-fPIC -O2" \ | |
1474 | ] \ | |
1475 | [list \ | |
1476 | "Build pr23162a" \ | |
1477 | "-pie --no-as-needed tmpdir/libpr23162a.so" \ | |
1478 | "" \ | |
7f923b7f | 1479 | $AFLAGS_PIE \ |
9bc935ef | 1480 | { pr23162b.c } \ |
7f923b7f | 1481 | {{readelf {-rW} pr23162.rd}} \ |
9bc935ef L |
1482 | "pr23162a" \ |
1483 | "-fPIC -O0" \ | |
1484 | ] \ | |
1485 | [list \ | |
1486 | "Build libpr23162b.so" \ | |
1487 | "-shared --version-script=pr23162.map" \ | |
1488 | "" \ | |
1489 | "$AFLAGS_PIC" \ | |
1490 | { pr23162a.c } \ | |
1491 | "" \ | |
1492 | "libpr23162b.so" \ | |
1493 | "-fPIC -O2" \ | |
1494 | ] \ | |
1495 | [list \ | |
1496 | "Build pr23162b" \ | |
1497 | "-pie --no-as-needed tmpdir/libpr23162b.so" \ | |
1498 | "" \ | |
7f923b7f | 1499 | $AFLAGS_PIE \ |
9bc935ef | 1500 | { pr23162b.c } \ |
7f923b7f | 1501 | {{readelf {-rW} pr23162.rd}} \ |
9bc935ef L |
1502 | "pr23162b" \ |
1503 | "-fPIC -O0" \ | |
1504 | ] \ | |
fd161d86 AM |
1505 | [list \ |
1506 | "Build libpr23161a.so" \ | |
1507 | "-shared" \ | |
1508 | "" \ | |
1509 | "$AFLAGS_PIC" \ | |
1510 | { pr23161a.c } \ | |
1511 | {{readelf {--dyn-syms -rW} pr23161a.rd}} \ | |
1512 | "libpr23161a.so" \ | |
1513 | "-fPIC -O2" \ | |
1514 | ] \ | |
1515 | [list \ | |
1516 | "Build pr23161a" \ | |
1517 | "-pie --no-as-needed tmpdir/libpr23161a.so" \ | |
1518 | "" \ | |
7f923b7f | 1519 | $AFLAGS_PIE \ |
fd161d86 AM |
1520 | { pr23161b.c } \ |
1521 | {{readelf {--dyn-syms -rW} pr23161b.rd}} \ | |
1522 | "pr23161a" \ | |
1523 | "-fPIC -O0" \ | |
1524 | ] \ | |
1525 | [list \ | |
1526 | "Build libpr23161b.so" \ | |
1527 | "-shared --version-script=pr23161.map" \ | |
1528 | "" \ | |
1529 | "$AFLAGS_PIC" \ | |
1530 | { pr23161a.c } \ | |
1531 | {{readelf {--dyn-syms -rW} pr23161a.rd}} \ | |
1532 | "libpr23161b.so" \ | |
1533 | "-fPIC -O2" \ | |
1534 | ] \ | |
1535 | [list \ | |
1536 | "Build pr23161b" \ | |
1537 | "-pie --no-as-needed tmpdir/libpr23161b.so" \ | |
1538 | "" \ | |
7f923b7f | 1539 | $AFLAGS_PIE \ |
fd161d86 AM |
1540 | { pr23161b.c } \ |
1541 | {{readelf {--dyn-syms -rW} pr23161b.rd}} \ | |
1542 | "pr23161b" \ | |
1543 | "-fPIC -O0" \ | |
1544 | ] \ | |
7f923b7f AM |
1545 | ] |
1546 | } | |
1547 | ||
1548 | if { [istarget "i?86-*-*"] | |
1549 | || [istarget "x86_64-*-*"] } { | |
1550 | run_ld_link_tests [list \ | |
fd161d86 AM |
1551 | [list \ |
1552 | "Build libpr23161c.so" \ | |
1553 | "-shared" \ | |
1554 | "" \ | |
1555 | "$AFLAGS_PIC" \ | |
1556 | { pr23161c.c } \ | |
1557 | {{readelf {--dyn-syms -rW} pr23161c.rd}} \ | |
1558 | "libpr23161c.so" \ | |
1559 | "-fPIC -O2" \ | |
1560 | ] \ | |
1561 | [list \ | |
1562 | "Build pr23161c" \ | |
1563 | "-pie --no-as-needed tmpdir/libpr23161c.so" \ | |
1564 | "" \ | |
7f923b7f | 1565 | $AFLAGS_PIE \ |
fd161d86 AM |
1566 | { pr23161b.c } \ |
1567 | {{readelf {--dyn-syms -rW} pr23161d.rd}} \ | |
1568 | "pr23161c" \ | |
1569 | "-fPIC -O0" \ | |
1570 | ] \ | |
9bc935ef L |
1571 | ] |
1572 | } | |
fb9bbfd7 L |
1573 | |
1574 | run_ld_link_tests [list \ | |
1575 | [list "Build pr23658.so" \ | |
1576 | "-shared" "" "$AFLAGS_PIC" \ | |
1577 | {pr23658-1a.s} {} "pr23658.so"] \ | |
1578 | [list \ | |
1579 | "Build pr23658-2" \ | |
1580 | "--dynamic-linker tmpdir/pr23658.so --no-as-needed tmpdir/pr23658.so" \ | |
1581 | "" \ | |
1582 | $AFLAGS_NOTE \ | |
1583 | { pr23658-1a.s pr23658-1b.s pr23658-1c.s pr23658-1d.s start.s } \ | |
1584 | {{readelf {-lW} pr23658-2.rd}} \ | |
1585 | "pr23658-2" \ | |
1586 | ] \ | |
1587 | ] |