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