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