]>
Commit | Line | Data |
---|---|---|
d2dee3b2 | 1 | # Expect script for various ELF tests. |
219d1afa | 2 | # Copyright (C) 2006-2018 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 "" | |
42 | if [istarget "tic6x-*-*"] { | |
43 | append AFLAGS_PIC " -mpic -mpid=near" | |
44 | } | |
185cdb8c EB |
45 | if [istarget "sparc*-*-*"] { |
46 | append AFLAGS_PIC " -K PIC" | |
47 | } | |
48 | ||
81ff47b3 MR |
49 | # This target requires a non-default emulation for successful shared |
50 | # library/executable builds. | |
51 | set LFLAGS "" | |
52 | if [istarget "tic6x-*-*"] { | |
53 | append LFLAGS " -melf32_tic6x_le" | |
54 | } | |
f3a9baf1 MR |
55 | # HPUX targets use a different .comm syntax. |
56 | set hpux "" | |
57 | if [istarget "*-*-hpux*"] { | |
58 | set hpux "--defsym HPUX=1" | |
59 | } | |
8988502d MR |
60 | # These targets do not default to linking with shared libraries. |
61 | if { [istarget "mips*vr4100*-*-elf*"] \ | |
62 | || [istarget "mips*vr4300*-*-elf*"] \ | |
63 | || [istarget "mips*vr5000*-*-elf*"] } { | |
64 | append LFLAGS " -call_shared" | |
65 | } | |
81ff47b3 | 66 | |
08f650e6 L |
67 | if [is_underscore_target] { |
68 | set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1" | |
69 | } | |
70 | ||
71 | run_ld_link_tests [list \ | |
72 | [list \ | |
73 | "Build pr22471a.so" \ | |
74 | "$LFLAGS -shared" \ | |
75 | "" \ | |
76 | "$AFLAGS_PIC" \ | |
77 | {pr22471a.s} \ | |
78 | {} \ | |
79 | "pr22471a.so" \ | |
80 | ] \ | |
81 | [list \ | |
82 | "Build pr22471b.so" \ | |
83 | "$LFLAGS -shared --version-script pr22471.t" \ | |
84 | "tmpdir/pr22471a.so" \ | |
85 | "$AFLAGS_PIC" \ | |
86 | {pr22471a.s} \ | |
87 | {} \ | |
88 | "pr22471b.so" \ | |
89 | ] \ | |
90 | [list \ | |
91 | "Build pr22471" \ | |
92 | "$LFLAGS -rpath-link ." \ | |
93 | "tmpdir/pr22471b.so" \ | |
94 | "" \ | |
95 | {pr22471b.s} \ | |
96 | {} \ | |
97 | "pr22471" \ | |
98 | ] \ | |
d664fd41 L |
99 | [list \ |
100 | "Build pr22649-1.so" \ | |
101 | "$LFLAGS -shared" \ | |
102 | "" \ | |
103 | "$AFLAGS_PIC" \ | |
104 | {pr22649-1.s} \ | |
105 | {} \ | |
106 | "pr22649-1.so" \ | |
107 | ] \ | |
08f650e6 L |
108 | ] |
109 | ||
87e79a65 | 110 | if { [check_gc_sections_available] } { |
af667f22 MR |
111 | if [istarget mips*-*-*] { |
112 | set actions {{ld pr22649-2ab-mips.msg}} | |
113 | } else { | |
114 | set actions {{ld pr22649.msg}} | |
115 | } | |
87e79a65 AM |
116 | run_ld_link_tests [list \ |
117 | [list \ | |
118 | "Build pr22649-2a.so" \ | |
119 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
120 | "" \ | |
121 | "$AFLAGS_PIC" \ | |
122 | {pr22649-2a.s} \ | |
af667f22 | 123 | $actions \ |
87e79a65 AM |
124 | "pr22649-2a.so" \ |
125 | ] \ | |
126 | [list \ | |
127 | "Build pr22649-2b.so" \ | |
128 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
129 | "tmpdir/pr22649-1.so" \ | |
130 | "$AFLAGS_PIC" \ | |
131 | {pr22649-2a.s} \ | |
af667f22 | 132 | $actions \ |
87e79a65 AM |
133 | "pr22649-2b.so" \ |
134 | ] \ | |
af667f22 MR |
135 | ] |
136 | if { [istarget mips*-*-*] && ![istarget *-*-elf*] } { | |
137 | set actions {{ld pr22649-2cd-mips.msg}} | |
138 | } else { | |
139 | set actions {} | |
140 | } | |
141 | run_ld_link_tests [list \ | |
87e79a65 AM |
142 | [list \ |
143 | "Build pr22649-2c.so" \ | |
144 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
145 | "" \ | |
146 | "$AFLAGS_PIC" \ | |
147 | {pr22649-2b.s} \ | |
af667f22 | 148 | $actions \ |
87e79a65 AM |
149 | "pr22649-2b.so" \ |
150 | ] \ | |
151 | [list \ | |
152 | "Build pr22649-2d.so" \ | |
153 | "$LFLAGS -shared -gc-sections -print-gc-sections" \ | |
154 | "tmpdir/pr22649-1.so" \ | |
155 | "$AFLAGS_PIC" \ | |
156 | {pr22649-2b.s} \ | |
af667f22 | 157 | $actions \ |
87e79a65 AM |
158 | "pr22649-2b.so" \ |
159 | ] \ | |
160 | ] | |
161 | } | |
162 | ||
63c1f59d AM |
163 | run_ld_link_tests [list \ |
164 | [list \ | |
165 | "DT_TEXTREL in shared lib" \ | |
166 | "$LFLAGS -shared --warn-shared-textrel" \ | |
167 | "" \ | |
168 | "$AFLAGS_PIC" \ | |
169 | {textrel.s} \ | |
170 | {{ld textrel.warn} \ | |
171 | {readelf {-d --wide} textrel.rd}} \ | |
172 | "textrel.so" \ | |
173 | ] \ | |
174 | ] "xtensa-*-*" | |
175 | ||
176 | run_ld_link_tests [list \ | |
177 | [list \ | |
178 | "DT_TEXTREL map file warning" \ | |
179 | "$LFLAGS -shared -M" \ | |
180 | "" \ | |
181 | "$AFLAGS_PIC" \ | |
182 | {textrel.s} \ | |
183 | {{ld textrel.map}} \ | |
184 | "textrel.so" \ | |
185 | ] \ | |
186 | ] "cris*-*-*" | |
187 | ||
81ff47b3 MR |
188 | # PR ld/20828 check for correct dynamic symbol table entries where: |
189 | # - symbols have been defined with a linker script, | |
190 | # - the same symbols have been seen in shared library used in the link, | |
191 | # - the shared library symbols have been swept in section garbage collection. | |
192 | # Verify that the symbols are global rather than local and that a version | |
193 | # script adjusts them accordingly. | |
902e9fc7 MR |
194 | # Also verify that a version definition supplied by an object rather than |
195 | # a version script and forcibly exported is unaffected by section GC. | |
81ff47b3 MR |
196 | if { [check_gc_sections_available] } { |
197 | run_ld_link_tests [list \ | |
198 | [list \ | |
199 | "PR ld/20828 dynamic symbols with section GC\ | |
15a00b13 MR |
200 | (auxiliary shared library)" \ |
201 | "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \ | |
202 | {pr20828.s} \ | |
203 | {{readelf --dyn-syms pr20828-a.sd} \ | |
204 | {readelf --dyn-syms pr20828-b.sd}} \ | |
205 | "libpr20828.so"] \ | |
81ff47b3 MR |
206 | [list \ |
207 | "PR ld/20828 dynamic symbols with section GC (plain)" \ | |
15a00b13 MR |
208 | "$LFLAGS -shared --gc-sections -T pr20828.ld" \ |
209 | "tmpdir/libpr20828.so" "$AFLAGS_PIC" \ | |
210 | {pr20828.s} \ | |
211 | {{readelf --dyn-syms pr20828-a.sd} \ | |
212 | {readelf --dyn-syms pr20828-b.sd}} \ | |
213 | "pr20828-1.so"] \ | |
81ff47b3 MR |
214 | [list \ |
215 | "PR ld/20828 dynamic symbols with section GC (version script)" \ | |
15a00b13 MR |
216 | "$LFLAGS -shared --gc-sections -T pr20828.ld\ |
217 | --version-script=pr20828.ver" \ | |
218 | "tmpdir/libpr20828.so" \ | |
219 | "$AFLAGS_PIC" \ | |
220 | {pr20828.s} \ | |
221 | {{readelf --dyn-syms pr20828-b.sd} \ | |
222 | {readelf --dyn-syms pr20828-c.sd}} \ | |
902e9fc7 MR |
223 | "pr20828-2.so"] \ |
224 | [list \ | |
225 | "PR ld/20828 dynamic symbols with section GC\ | |
226 | (versioned shared library)" \ | |
227 | "$LFLAGS -shared --gc-sections -T pr20828.ld\ | |
228 | --version-script=pr20828-v.ver" \ | |
229 | "" "$AFLAGS_PIC" \ | |
230 | {pr20828.s} \ | |
231 | {{readelf --dyn-syms pr20828-c.sd} \ | |
232 | {readelf --dyn-syms pr20828-d.sd} \ | |
233 | {readelf --dyn-syms pr20828-e.sd}} \ | |
234 | "libpr20828-v.so"] \ | |
235 | [list \ | |
236 | "PR ld/20828 dynamic symbols with section GC (versioned)" \ | |
237 | "$LFLAGS -shared --gc-sections -T pr20828.ld\ | |
238 | --version-script=pr20828-v.ver" \ | |
239 | "tmpdir/libpr20828-v.so" \ | |
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 | "pr20828-v.so"] \ | |
246 | [list \ | |
247 | "PR ld/20828 forcibly exported symbol version without section GC" \ | |
3c5fce9b | 248 | "$LFLAGS --no-dynamic-linker -e foo -E -T pr20828-v.ld" "" "" \ |
902e9fc7 MR |
249 | {pr20828-v.s} \ |
250 | {{objdump -p pr20828-v.od}} \ | |
251 | "pr20828-v-1"] \ | |
252 | [list \ | |
253 | "PR ld/20828 forcibly exported symbol version with section GC" \ | |
3c5fce9b | 254 | "$LFLAGS --no-dynamic-linker -e foo --gc-sections -E -T pr20828-v.ld" "" "" \ |
902e9fc7 MR |
255 | {pr20828-v.s} \ |
256 | {{objdump -p pr20828-v.od}} \ | |
257 | "pr20828-v-2"]] | |
81ff47b3 | 258 | } |
80070c0d MR |
259 | # PR ld/21233 check for correct dynamic symbol table entries where: |
260 | # - a symbol has been defined in a shared library used in the link, | |
261 | # - the symbol has been referenced from a section swept in garbage collection, | |
262 | # - the symbol has also been forced to be entered in the output file as an | |
263 | # undefined symbol, either with a command-line option or a linker script | |
264 | # command. | |
265 | # Verify that the undefined symbol is global rather than local. | |
266 | if { [check_gc_sections_available] } { | |
267 | run_ld_link_tests [list \ | |
268 | [list \ | |
269 | "PR ld/21233 dynamic symbols with section GC\ | |
270 | (auxiliary shared library)" \ | |
271 | "$LFLAGS -shared -T pr21233.ld" "" "$AFLAGS_PIC" \ | |
272 | {pr21233-l.s} \ | |
273 | {{readelf --dyn-syms pr21233-l.sd}} \ | |
4d5efb85 | 274 | "libpr21233.so"]] |
6ca30fa5 | 275 | |
4d5efb85 | 276 | run_ld_link_tests [list \ |
80070c0d MR |
277 | [list \ |
278 | "PR ld/21233 dynamic symbols with section GC (--undefined)" \ | |
279 | "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld" \ | |
280 | "tmpdir/libpr21233.so" "" \ | |
281 | {pr21233.s} \ | |
282 | {{readelf --dyn-syms pr21233.sd}} \ | |
6ca30fa5 HPN |
283 | "pr21233-1"]] |
284 | ||
6ca30fa5 | 285 | run_ld_link_tests [list \ |
80070c0d MR |
286 | [list \ |
287 | "PR ld/21233 dynamic symbols with section GC (--require-defined)" \ | |
288 | "$LFLAGS --gc-sections -e foo --require-defined=bar\ | |
289 | -T pr21233.ld" \ | |
290 | "tmpdir/libpr21233.so" "" \ | |
291 | {pr21233.s} \ | |
292 | {{readelf --dyn-syms pr21233.sd}} \ | |
6ca30fa5 HPN |
293 | "pr21233-2"]] |
294 | ||
6ca30fa5 | 295 | run_ld_link_tests [list \ |
80070c0d MR |
296 | [list \ |
297 | "PR ld/21233 dynamic symbols with section GC (EXTERN)" \ | |
298 | "$LFLAGS --gc-sections -e foo -T pr21233-e.ld" \ | |
299 | "tmpdir/libpr21233.so" "" \ | |
300 | {pr21233.s} \ | |
301 | {{readelf --dyn-syms pr21233.sd}} \ | |
6ca30fa5 | 302 | "pr21233-3"]] |
80070c0d | 303 | } |
81ff47b3 | 304 | |
be2b629f L |
305 | if { [check_gc_sections_available] } { |
306 | run_ld_link_tests [list \ | |
307 | [list \ | |
308 | "Build pr22150.so" \ | |
309 | "$LFLAGS -shared --version-script pr22150.ver" \ | |
310 | "" \ | |
311 | "$AFLAGS_PIC" \ | |
312 | {pr22150a.s} \ | |
313 | {} \ | |
314 | "pr22150.so" \ | |
315 | ] \ | |
316 | [list \ | |
317 | "Build pr22150" \ | |
318 | "$LFLAGS -e _start --gc-sections" \ | |
319 | "tmpdir/pr22150.so" \ | |
320 | "" \ | |
321 | {pr22150b.s} \ | |
322 | {{readelf -V pr22150.vd}} \ | |
323 | "pr22150" \ | |
324 | ] \ | |
325 | ] | |
326 | } | |
327 | ||
66824765 AM |
328 | set ASFLAGS $old_ASFLAGS |
329 | ||
f3a9baf1 MR |
330 | run_ld_link_tests { |
331 | {"Build pr14170a.o" "" "" "" {pr14170a.s} {} "pr14170.a" } | |
332 | } | |
333 | run_ld_link_tests { | |
334 | {"Build shared library for pr14170" | |
335 | "-shared" "" "" "pr14170b.s" {} "pr14170.so" } | |
336 | } "tic6x-*-*" | |
337 | ||
338 | # bfin does not currently support copy relocs. | |
339 | run_ld_link_tests [list \ | |
340 | [list "PR ld/14170" \ | |
8988502d MR |
341 | "$LFLAGS --no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" \ |
342 | $hpux \ | |
f3a9baf1 MR |
343 | {pr14170c.s} { } "pr14170" ] \ |
344 | ] "bfin-*-*" | |
345 | ||
346 | # Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests | |
347 | # Not will tic6x with PIC/PID warning, or hppa64 with dot-symbols | |
348 | run_ld_link_tests { | |
349 | {"PR ld/21703 shared" | |
350 | "-shared --allow-multiple-definition --version-script pr21703.ver tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "" \ | |
351 | {pr21703-3.s pr21703-4.s} {{readelf {--dyn-syms} pr21703-shared.sd}} "pr21703.so" } | |
352 | } "d30v-*-*" "dlx-*-*" "pj-*-*" "tic6x-*-*" "hppa64-*-*" | |
353 | ||
354 | # This target requires extra GAS options when building non-PIC code | |
355 | # for linking with shared libraries. | |
356 | set AFLAGS_NONPIC "" | |
357 | if [istarget "mips*-*-*"] { | |
358 | append AFLAGS_NONPIC " -call_nonpic" | |
359 | } | |
360 | ||
361 | # Run a test to check linking a shared library with a broken linker | |
362 | # script that accidentally marks dynamic sections as notes. The | |
363 | # resulting executable is not expected to work, but the linker | |
364 | # should not seg-fault whilst creating the binary. | |
365 | # Note: setup_xfail before run_ld_link_tests xfails only the first test. | |
366 | setup_xfail "tic6x-*-*" | |
367 | run_ld_link_tests { | |
368 | {"Build shared library for broken linker scrip test" | |
369 | "-shared --hash-style=sysv" "" "" "note-3.s" {} "note-3.so" } | |
370 | {"Link using broken linker script" | |
8988502d | 371 | "$LFLAGS --script note-3.t tmpdir/note-3.so" "" "" "" |
f3a9baf1 MR |
372 | { { ld "note-3.l" } } |
373 | "a.out" } | |
374 | } | |
375 | ||
376 | setup_xfail "tic6x-*-*" | |
377 | run_ld_link_tests { | |
378 | {"Build pr17068.so" | |
379 | "-shared" "" "" | |
380 | {pr17068d.s} {} "pr17068.so"} | |
381 | {"Build pr17068a.a" | |
382 | "" "" "" | |
383 | {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"} | |
384 | {"Build pr17068b.a" | |
385 | "" "" "" | |
386 | {pr17068b.s pr17068e.s} {} "pr17068b.a"} | |
387 | } | |
388 | ||
389 | # bfin does not currently support copy relocs. | |
390 | run_ld_link_tests { | |
391 | {"pr17068 link --as-needed lib in group" | |
8988502d MR |
392 | "$LFLAGS --as-needed --no-dynamic-linker" |
393 | "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a\ | |
394 | --end-group" "" | |
f3a9baf1 MR |
395 | {start.s pr17068.s} {} "pr17068"} |
396 | } "bfin-*-*" | |
397 | ||
398 | # xfail on tic6x due to non-PIC/non-PID warnings | |
399 | # Fails on MIPS because ABI trickery means that a NULL reloc is emitted. | |
400 | # Fails on bfin because relocations are not created. | |
401 | run_ld_link_tests { | |
402 | {"-Bsymbolic-functions" | |
403 | "-shared -Bsymbolic-functions" "" "" | |
404 | {symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}} | |
405 | "symbolic-func.so"} | |
406 | } "tic6x-*-*" "mips*-*-*" "bfin-*-*" | |
407 | ||
408 | # xfail on tic6x due to non-PIC/non-PID warnings | |
409 | run_ld_link_tests { | |
410 | {"Build pr20995.so" | |
411 | "-shared" "" "" | |
412 | {pr20995b.s} {} "pr20995.so"} | |
413 | } "tic6x-*-*" | |
414 | ||
415 | # xfail on arm*-*-eabi*. The list can be enlarged to those targets that | |
416 | # don't support GNU_RELRO. For more details, please see discussions at: | |
417 | # https://sourceware.org/ml/binutils/2017-01/msg00441.html | |
418 | run_ld_link_tests { | |
419 | {"Build pr20995-2.so" | |
420 | "-shared -z relro" "" "" | |
421 | {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"} | |
422 | } "tic6x-*-*" "arm*-*-eabi*" "hppa*64*-*-hpux*" | |
423 | ||
424 | # These targets don't copy dynamic variables into .bss. | |
425 | setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" | |
426 | # or don't have .data.rel.ro | |
427 | setup_xfail "hppa*64*-*-hpux*" | |
428 | run_ld_link_tests [list \ | |
429 | [list \ | |
430 | "pr20995" \ | |
8988502d | 431 | "$LFLAGS" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \ |
f3a9baf1 MR |
432 | {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]] |
433 | ||
434 | # xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO. | |
435 | # Please see the link above for details. | |
436 | setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*" | |
437 | setup_xfail "hppa*64*-*-hpux*" | |
438 | run_ld_link_tests [list \ | |
439 | [list \ | |
440 | "pr20995-2" \ | |
8988502d | 441 | "$LFLAGS" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \ |
f3a9baf1 MR |
442 | {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]] |
443 | ||
444 | setup_xfail "tic6x-*-*" | |
445 | run_ld_link_tests { | |
446 | {"Build pr22374 shared library" | |
447 | "-shared" "" "" "pr22374b.s" {} "pr22374.so" } | |
448 | } | |
449 | if { ![istarget "alpha-*-*"] | |
450 | && ![istarget "frv-*-*"] | |
451 | && ![istarget "hppa*-*-*"] | |
452 | && ![istarget "i?86-*-*"] | |
453 | && ![istarget "ia64-*-*"] | |
454 | && ![istarget "microblaze-*-*"] | |
455 | && ![istarget "powerpc*-*-*"] | |
456 | && ![istarget "x86_64-*-*"] | |
457 | && ![istarget "xtensa-*-*"] } { | |
458 | # The next test checks that copy relocs are not used unnecessarily, | |
459 | # but that is just an optimization so don't complain loudly. | |
460 | setup_xfail "*-*-*" | |
461 | } | |
462 | run_ld_link_tests { | |
463 | {"pr22374 function pointer initialization" | |
464 | "" "tmpdir/pr22374.so" "" "pr22374a.s" | |
465 | { {readelf {--wide -r --dyn-syms} "pr22374-1.r"} | |
466 | {readelf {--wide -r} "pr22374-2.r"} } | |
467 | "pr22374" } | |
468 | } | |
469 | ||
470 | if { [istarget *-*-linux*] | |
471 | || [istarget *-*-nacl*] | |
472 | || [istarget *-*-gnu*] } { | |
473 | run_ld_link_tests { | |
474 | {"Weak symbols in dynamic objects 1 (support)" | |
475 | "-shared" "" "" {weak-dyn-1a.s} | |
476 | {} | |
477 | "libweakdyn1a.so"} | |
478 | {"Weak symbols in dynamic objects 1 (main test)" | |
479 | "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s} | |
480 | {{readelf {--relocs --wide} weak-dyn-1.rd}} | |
481 | "libweakdyn1b.so"} | |
482 | } | |
483 | } | |
484 | ||
dd98f8d2 | 485 | # Check to see if the C compiler works |
d2dee3b2 L |
486 | if { [which $CC] == 0 } { |
487 | return | |
488 | } | |
489 | ||
fb2c6e43 | 490 | # Add -ldl to extralibs if needed |
d9816402 | 491 | set extralibs "" |
fb2c6e43 AT |
492 | if { ![istarget *-*-freebsd*]} { |
493 | set extralibs "-ldl" | |
494 | } | |
495 | ||
d2dee3b2 L |
496 | set build_tests { |
497 | {"Build libfoo.so" | |
498 | "-shared" "-fPIC" | |
499 | {foo.c} {} "libfoo.so"} | |
500 | {"Build versioned libfoo.so" | |
501 | "-shared -Wl,--version-script=foo.map" "-fPIC" | |
55255dae | 502 | {foo.c} {} "libfoov.so"} |
d2dee3b2 L |
503 | {"Build libbar.so" |
504 | "-shared" "-fPIC" | |
505 | {begin.c end.c} {} "libbar.so"} | |
fab4a87f L |
506 | {"Build warn libbar.so" |
507 | "-shared" "-fPIC" | |
2bd7f877 AB |
508 | {beginwarn.c end.c} |
509 | {{readelf {-S --wide} libbarw.rd} | |
3239a423 | 510 | {warning "^.*beginwarn.c:7: warning: function foo is deprecated$"}} |
2bd7f877 | 511 | "libbarw.so" "c"} |
d2dee3b2 L |
512 | {"Build hidden libbar.so" |
513 | "-shared" "-fPIC" | |
514 | {begin.c endhidden.c} {} "libbarh.so"} | |
515 | {"Build protected libbar.so" | |
516 | "-shared" "-fPIC" | |
517 | {begin.c endprotected.c} {} "libbarp.so"} | |
518 | {"Build libbar.so with libfoo.so" | |
519 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
520 | {end.c} {} "libbarfoo.so"} | |
521 | {"Build libar.so with versioned libfoo.so" | |
522 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
523 | {end.c} {} "libbarfoov.so"} | |
524 | {"Build hidden libbar.so with libfoo.so" | |
525 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
526 | {endhidden.c} {} "libbarhfoo.so"} | |
527 | {"Build hidden libar.so with versioned libfoo.so" | |
528 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
529 | {endhidden.c} {} "libbarhfoov.so"} | |
530 | {"Build protected libbar.so with libfoo.so" | |
531 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
532 | {endprotected.c} {} "libbarpfoo.so"} | |
533 | {"Build protected libbar.so with versioned libfoo.so" | |
534 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
535 | {endprotected.c} {} "libbarpfoov.so"} | |
55255dae L |
536 | {"Build libdl1.so" |
537 | "-shared" "-fPIC" | |
538 | {dl1.c} {} "libdl1.so"} | |
539 | {"Build libdl2a.so with --dynamic-list=dl2.list" | |
540 | "-shared -Wl,--dynamic-list=dl2.list" "-fPIC" | |
541 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
b7b7fe3f AS |
542 | {"Build libdl2a.so with --dynamic-list=dl2a.list" |
543 | "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC" | |
544 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
40b36307 L |
545 | {"Build libdl2a.so with --dynamic-list-data" |
546 | "-shared -Wl,--dynamic-list-data" "-fPIC" | |
547 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
55255dae L |
548 | {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list" |
549 | "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC" | |
550 | {dl2.c dl2xxx.c} {} "libdl2b.so"} | |
d8cf8b51 | 551 | {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list" |
40b36307 | 552 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC" |
d8cf8b51 | 553 | {dl2.c dl2xxx.c} {} "libdl2c.so"} |
c555238b L |
554 | {"Build libdl4a.so with --dynamic-list=dl4.list" |
555 | "-shared -Wl,--dynamic-list=dl4.list" "-fPIC" | |
556 | {dl4.c dl4xxx.c} {} "libdl4a.so"} | |
d8cf8b51 | 557 | {"Build libdl4b.so with --dynamic-list-data" |
40b36307 | 558 | "-shared -Wl,--dynamic-list-data" "-fPIC" |
c555238b | 559 | {dl4.c dl4xxx.c} {} "libdl4b.so"} |
d8cf8b51 L |
560 | {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list" |
561 | "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC" | |
562 | {dl4.c dl4xxx.c} {} "libdl4c.so"} | |
563 | {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list" | |
40b36307 | 564 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC" |
d8cf8b51 L |
565 | {dl4.c dl4xxx.c} {} "libdl4d.so"} |
566 | {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new" | |
567 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" | |
568 | {dl4.c dl4xxx.c} {} "libdl4e.so"} | |
569 | {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions" | |
570 | "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC" | |
571 | {dl4.c dl4xxx.c} {} "libdl4f.so"} | |
572 | {"Build libdl6a.so" | |
573 | "-shared" "-fPIC" | |
574 | {dl6.c} {} "libdl6a.so"} | |
575 | {"Build libdl6b.so with -Bsymbolic --dynamic-list-data" | |
576 | "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC" | |
577 | {dl6.c} {} "libdl6b.so"} | |
578 | {"Build libdl6c.so with -Bsymbolic" | |
579 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
580 | {dl6.c} {} "libdl6c.so"} | |
581 | {"Build libdl6d.so with --dynamic-list-data -Bsymbolic" | |
582 | "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC" | |
583 | {dl6.c} {} "libdl6d.so"} | |
43edfb7f L |
584 | {"Build libdata1.so" |
585 | "-shared" "-fPIC" | |
586 | {data1.c} {} "libdata1.so"} | |
a47edf27 L |
587 | {"Build libdata2.so" |
588 | "-shared" "-fPIC" | |
589 | {data2.c} {} "libdata2.so"} | |
0a36a439 L |
590 | {"Build libcomm1.o" |
591 | "-r -nostdlib" "" | |
592 | {comm1.c} {} "libcomm1.o"} | |
593 | {"Build libfunc1.so" | |
594 | "-shared" "-fPIC" | |
595 | {func1.c} {} "libfunc1.so"} | |
d8880531 L |
596 | {"Build libpr9676-1.a" |
597 | "" "-fPIC" | |
598 | {pr9676-1.c} {} "libpr9676-1.a"} | |
599 | {"Build libpr9676-2.a" | |
600 | "" "-fPIC" | |
601 | {pr9676-2.c} {} "libpr9676-2.a"} | |
602 | {"Build libpr9676-3.so" | |
603 | "-shared" "-fPIC" | |
604 | {pr9676-3.c} {} "libpr9676-3.so"} | |
605 | {"Build libpr9676-4.so" | |
606 | "-shared" "-fPIC" | |
607 | {pr9676-4.c} {} "libpr9676-4.so"} | |
608 | {"Build libpr9676-4a.so" | |
609 | "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group" | |
610 | "-fPIC" | |
611 | {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"} | |
54ac0771 L |
612 | {"Build libpr9679.so" |
613 | "-shared" "-fPIC -O0" | |
614 | {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"} | |
d023c380 L |
615 | {"Build libpr11138-1.so" |
616 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
617 | {pr11138-1.c} {} "libpr11138-1.so"} | |
618 | {"Build libpr11138-2.o" | |
619 | "-r -nostdlib" "" | |
620 | {pr11138-2.c} {} "libpr11138-2.o"} | |
3e0882af L |
621 | {"Build pr13250-1.so" |
622 | "-shared" "-fPIC" | |
623 | {pr13250-1.c} {} "libpr13250-1.so"} | |
624 | {"Build pr13250-2.so with libpr13250-1.so" | |
5cb49709 | 625 | "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC" |
3e0882af L |
626 | {pr13250-2.c} {} "libpr13250-2.so"} |
627 | {"Build libpr13250-3.o" | |
628 | "-r -nostdlib" "" | |
629 | {pr13250-3.c} {} "libpr13250-3.o"} | |
bc9ad2e4 L |
630 | {"Build libpr14323-2.so" |
631 | "-shared" "-fPIC" | |
632 | {pr14323-2.c} {} "libpr14323-2.so"} | |
dda8ddc5 L |
633 | {"Build pr14862-1.o" |
634 | "-r -nostdlib" "" | |
635 | {pr14862-1.c} {} "libpr14862-1.o"} | |
636 | {"Build libpr14862.so" | |
637 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
638 | {pr14862-2.c} {} "libpr14862.so"} | |
63406f0a L |
639 | {"Build libneeded1b.so" |
640 | "-shared" "-fPIC" | |
641 | {needed1b.c} {} "libneeded1b.so"} | |
642 | {"Build libneeded1a.so" | |
2eb64a9f | 643 | "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC" |
63406f0a L |
644 | {needed1a.c} {} "libneeded1a.so"} |
645 | {"Build libneeded1c.o" | |
646 | "-r -nostdlib" "" | |
647 | {needed1c.c} {} "libneeded1c.o"} | |
8fbb09e8 L |
648 | {"Build libneeded1pic.o" |
649 | "-r -nostdlib" "-fPIC" | |
650 | {needed1c.c} {} "libneeded1pic.o"} | |
651 | {"Build needed1a.so with --add-needed" | |
8cfc7cf8 | 652 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
653 | {dummy.c} {} "needed1a.so"} |
654 | {"Build needed1b.so with --copy-dt-needed-entries" | |
8cfc7cf8 | 655 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
656 | {dummy.c} {} "needed1b.so"} |
657 | {"Build needed1a.so with --no-add-needed" | |
8cfc7cf8 | 658 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
659 | {dummy.c} {} "needed1c.so"} |
660 | {"Build needed1b.so with --no-copy-dt-needed-entries" | |
8cfc7cf8 | 661 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" "" |
8fbb09e8 | 662 | {dummy.c} {} "needed1d.so"} |
8877b5e5 AM |
663 | {"Build librel.so" |
664 | "-shared" "-fPIC" | |
665 | {rel.c} {} "librel.so"} | |
5e319dd3 L |
666 | {"Build libneeded2a.so" |
667 | "-shared" "-fPIC" | |
668 | {needed2a.c} {} "libneeded2a.so"} | |
669 | {"Build libneeded2b.so" | |
670 | "-shared -Wl,--version-script,needed2.ver" "-fPIC" | |
671 | {needed2b.c} {} "libneeded2b.so"} | |
672 | {"Build libneeded2c.o" | |
673 | "-r -nostdlib" "" | |
674 | {needed2c.c} {} "libneeded2c.o"} | |
675 | {"Build needed2" | |
676 | "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" "" | |
677 | {dummy.c} {} "needed2"} | |
1240be6b AM |
678 | {"Build libneeded3a.so" |
679 | "-shared -Wl,--no-add-needed" "-fPIC" | |
680 | {needed1a.c} {} "libneeded3a.so"} | |
681 | {"Build libneeded3b.so" | |
682 | "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC" | |
683 | {dummy.c} {} "libneeded3b.so"} | |
684 | {"Build needed3.o" | |
685 | "-r -nostdlib" "" | |
686 | {needed3.c} {} "libneeded3.so"} | |
687 | {"Build needed3" | |
688 | "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" "" | |
689 | {dummy.c} {} "needed3"} | |
cec2c50d L |
690 | {"Build libpr2404a.so" |
691 | "-shared" "-fPIC" | |
692 | {pr2404a.c} {} "libpr2404a.so"} | |
d6f48aed L |
693 | {"Build libpr2404n.so" |
694 | "-shared -Wl,-z,now" "-fPIC" | |
695 | {pr2404a.c} {} "libpr2404n.so"} | |
cec2c50d L |
696 | {"Build libpr2404b.a" |
697 | "" "" | |
698 | {pr2404b.c} {} "libpr2404b.a"} | |
50a53d3f | 699 | {"Build rdynamic-1" |
8569cfa7 | 700 | "-Wl,--no-dynamic-linker,-export-dynamic,--gc-sections" "-ffunction-sections" |
50a53d3f | 701 | {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"} |
d6f6f455 | 702 | {"Build dynamic-1" |
8569cfa7 | 703 | "-Wl,--no-dynamic-linker,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections" |
d6f6f455 | 704 | {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"} |
bb4d2ac2 L |
705 | {"Build libpr16496a.so" |
706 | "-shared -Wl,--version-script=pr16496a.map" "-fPIC" | |
707 | {pr16496a.c} {} "libpr16496a.so"} | |
708 | {"Build libpr16496b.a" | |
709 | "" "-fPIC" | |
710 | {pr16496b.c} {} "libpr16496b.a"} | |
711 | {"Build libpr16496b.so" | |
8cfc7cf8 | 712 | "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" "" |
bb4d2ac2 | 713 | {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"} |
fb389763 L |
714 | {"Build libpr16452a.so" |
715 | "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC" | |
716 | {pr16452a.c} {} "libpr16452a.so"} | |
717 | {"Build libpr16452b.so" | |
718 | "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC" | |
719 | {dummy.c} {} "libpr16452b.so"} | |
720 | {"Build pr16452" | |
8cfc7cf8 | 721 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 L |
722 | {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"} |
723 | {"Build pr16457" | |
8cfc7cf8 | 724 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 | 725 | {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"} |
8ded2ddc L |
726 | {"Build libpr18458a.so" |
727 | "-shared -Wl,-z,now" "-fPIC" | |
728 | {pr18458a.c} {} "libpr18458a.so"} | |
729 | {"Build libpr18458b.so" | |
730 | "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC" | |
731 | {pr18458b.c} {} "libpr18458b.so"} | |
4373f8af L |
732 | {"Build pr19073a.o" |
733 | "-r -nostdlib" "" | |
734 | {pr19073.s} {} "pr19073a.o"} | |
735 | {"Build libpr19073.so" | |
736 | "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC" | |
737 | {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"} | |
8dfb7cbf | 738 | {"Build pr21964-1a.so" |
487b6440 | 739 | "-shared" "-fPIC" |
8dfb7cbf L |
740 | {pr21964-1a.c} {} "pr21964-1a.so"} |
741 | {"Build pr21964-1b.so" | |
487b6440 | 742 | "-shared" "-fPIC" |
8dfb7cbf L |
743 | {pr21964-1b.c} {} "pr21964-1b.so"} |
744 | {"Build pr21964-2a.so" | |
745 | "-shared" "-fPIC" | |
746 | {pr21964-2a.c} {} "pr21964-2a.so"} | |
747 | {"Build pr21964-2b.so" | |
748 | "-shared" "-fPIC" | |
749 | {pr21964-2b.c} {} "pr21964-2b.so"} | |
36b8fda5 AM |
750 | {"Build pr21964-3a.so" |
751 | "-shared" "-fPIC" | |
752 | {pr21964-3a.c} {} "pr21964-3a.so"} | |
2715765b L |
753 | {"Dump pr21978.so" |
754 | "-shared" "-fPIC -g -O2" | |
755 | {pr21978a.c pr21978b.c} {{objdump {-Sl} pr21978.od}} "pr21978.so"} | |
d2dee3b2 L |
756 | } |
757 | ||
dd98f8d2 NC |
758 | run_cc_link_tests $build_tests |
759 | ||
f3012016 L |
760 | run_ld_link_tests [list \ |
761 | [list \ | |
762 | "Build pr22269-1" \ | |
763 | "-pie -e _start --no-dynamic-linker -z text" \ | |
764 | "" \ | |
185cdb8c | 765 | "$AFLAGS_PIC" \ |
f3012016 L |
766 | { pr22269-1.c } \ |
767 | {{readelf -rW pr22269-1.rd}} \ | |
768 | "pr22269-1" \ | |
769 | "-fPIE -O2" \ | |
770 | ] \ | |
771 | ] | |
772 | ||
d9816402 AM |
773 | set run_tests [list \ |
774 | [list "Run normal with libfoo.so" \ | |
775 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \ | |
776 | {main.c} "normal" "normal.out" ] \ | |
777 | [list "Run protected with libfoo.so" \ | |
778 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \ | |
779 | {main.c} "protected" "normal.out" ] \ | |
780 | [list "Run hidden with libfoo.so" \ | |
781 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \ | |
782 | {main.c} "hidden" "hidden.out" ] \ | |
783 | [list "Run normal with versioned libfoo.so" \ | |
784 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \ | |
785 | {main.c} "normalv" "normal.out" ] \ | |
786 | [list "Run warn with versioned libfoo.so" \ | |
787 | "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \ | |
788 | {main.c} "warn" "warn.out" \ | |
3239a423 | 789 | "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated$} ] \ |
d9816402 AM |
790 | [list "Run protected with versioned libfoo.so" \ |
791 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \ | |
792 | {main.c} "protected" "normal.out" ] \ | |
793 | [list "Run hidden with versioned libfoo.so" \ | |
794 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \ | |
795 | {main.c} "hiddenv" "hidden.out" ] \ | |
796 | [list "Run normal libbar.so with libfoo.so" \ | |
797 | "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \ | |
798 | {main.c} "normal" "normal.out" ] \ | |
799 | [list "Run protected libbar.so with libfoo.so" \ | |
800 | "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \ | |
801 | {main.c} "protected" "normal.out" ] \ | |
802 | [list "Run hidden libbar.so with libfoo.so" \ | |
803 | "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \ | |
804 | {main.c} "hidden" "hidden.out" ] \ | |
805 | [list "Run normal libbar.so with versioned libfoo.so" \ | |
806 | "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \ | |
807 | {main.c} "normal" "normal.out" ] \ | |
808 | [list "Run protected libbar.so with versioned libfoo.so" \ | |
809 | "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \ | |
810 | {main.c} "protected" "normal.out" ] \ | |
811 | [list "Run hidden libbar.so with versioned libfoo.so" \ | |
812 | "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \ | |
813 | {main.c} "hidden" "hidden.out" ] \ | |
d9816402 AM |
814 | [list "Run with libdl2a.so" \ |
815 | "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \ | |
816 | {dl2main.c} "dl2a" "dl2a.out" ] \ | |
817 | [list "Run with libdl2b.so" \ | |
818 | "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \ | |
819 | {dl2main.c} "dl2b" "dl2b.out" ] \ | |
820 | [list "Run with libdl2c.so" \ | |
821 | "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \ | |
822 | {dl2main.c} "dl2c" "dl2b.out" ] \ | |
823 | [list "Run with libdl4a.so" \ | |
824 | "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \ | |
825 | {dl4main.c} "dl4a" "dl4a.out" ] \ | |
826 | [list "Run with libdl4b.so" \ | |
827 | "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \ | |
828 | {dl4main.c} "dl4b" "dl4a.out" ] \ | |
829 | [list "Run with libdl4c.so" \ | |
830 | "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \ | |
831 | {dl4main.c} "dl4c" "dl4b.out" ] \ | |
832 | [list "Run with libdl4d.so" \ | |
833 | "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \ | |
834 | {dl4main.c} "dl4d" "dl4b.out" ] \ | |
835 | [list "Run with libdl4e.so" \ | |
836 | "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \ | |
837 | {dl4main.c} "dl4e" "dl4a.out" ] \ | |
838 | [list "Run with libdl4f.so" \ | |
839 | "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \ | |
840 | {dl4main.c} "dl4f" "dl4a.out" ] \ | |
d9816402 AM |
841 | [list "Run with libdata1.so" \ |
842 | "-Wl,--no-as-needed tmpdir/libdata1.so" "" \ | |
843 | {dynbss1.c} "dynbss1" "pass.out" ] \ | |
844 | [list "Run with libdata2.so" \ | |
845 | "-Wl,--no-as-needed tmpdir/libdata2.so" "" \ | |
846 | {weakdef1.c} "weakdef1" "pass.out" ] \ | |
847 | [list "Run with libfunc1.so comm1.o" \ | |
848 | "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \ | |
849 | {dummy.c} "comm1" "pass.out" ] \ | |
850 | [list "Run with comm1.o libfunc1.so" \ | |
851 | "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \ | |
852 | {dummy.c} "comm1" "pass.out" ] \ | |
853 | [list "Run with pr11138-2.c libpr11138-1.so" \ | |
854 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \ | |
855 | {dummy.c} "pr11138a" "pr11138.out" ] \ | |
856 | [list "Run with libpr11138-1.so pr11138-2.c" \ | |
857 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \ | |
858 | {dummy.c} "pr11138b" "pr11138.out" ] \ | |
859 | [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \ | |
860 | "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" \ | |
861 | {dummy.c} "pr13250" "pass.out" ] \ | |
862 | [list "Run with pr14323-1.c pr14323-2.so" \ | |
863 | "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \ | |
864 | {pr14323-1.c} "pr14323" "pass.out" ] \ | |
865 | [list "Run with pr14862-1.c libpr14862.so" \ | |
866 | "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \ | |
867 | {dummy.c} "pr14862" "pr14862.out" ] \ | |
868 | [list "Link with --add-needed" \ | |
8cfc7cf8 | 869 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
870 | {dummy.c} "needed1a" "needed1.out" ] \ |
871 | [list "Link with --copy-dt-needed-entries" \ | |
8cfc7cf8 | 872 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
873 | {dummy.c} "needed1b" "needed1.out" ] \ |
874 | [list "Run relmain" \ | |
875 | "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \ | |
876 | {relmain.c} "relmain" "relmain.out" ] \ | |
877 | [list "Run pr2404" \ | |
878 | "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \ | |
879 | {dummy.c} "pr2404" "pr2404.out" ] \ | |
d6f48aed L |
880 | [list "Run pr2404n" \ |
881 | "-Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" "" \ | |
882 | {dummy.c} "pr2404n" "pr2404.out" ] \ | |
d9816402 AM |
883 | [list "Run pr18458" \ |
884 | "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \ | |
885 | {pr18458c.c} "pr18458" "pass.out" ] \ | |
487b6440 | 886 | [list "Run pr21964-1" \ |
8dfb7cbf L |
887 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so" "" \ |
888 | {pr21964-1c.c} "pr21964-1" "pass.out" ] \ | |
36b8fda5 AM |
889 | [list "Run pr21964-3" \ |
890 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so tmpdir/pr21964-1b.so tmpdir/pr21964-3a.so" "" \ | |
891 | {pr21964-3c.c} "pr21964-3" "pass.out" ] \ | |
d9816402 | 892 | ] |
d2dee3b2 | 893 | |
d2dee3b2 | 894 | # NetBSD ELF systems do not currently support the .*_array sections. |
982c6f26 | 895 | run_ld_link_exec_tests $run_tests "*-*-netbsdelf*" |
55255dae | 896 | |
fd121c5c JW |
897 | # These tests require dlopen support. |
898 | set dlopen_run_tests [list \ | |
899 | [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \ | |
900 | "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \ | |
901 | {dl1main.c} "dl1a" "dl1.out" ] \ | |
902 | [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \ | |
903 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
904 | {dl1main.c} "dl1b" "dl1.out" ] \ | |
905 | [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \ | |
906 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
907 | {dl6amain.c} "dl6a1" "dl6a.out" ] \ | |
908 | [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \ | |
6b737370 L |
909 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \ |
910 | {dl6amain.c} "dl6a2" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c JW |
911 | [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \ |
912 | "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \ | |
913 | {dl6amain.c} "dl6a3" "dl6b.out" ] \ | |
914 | [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \ | |
915 | "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \ | |
916 | {dl6amain.c} "dl6a4" "dl6a.out" ] \ | |
917 | [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \ | |
6b737370 L |
918 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \ |
919 | {dl6amain.c} "dl6a5" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c | 920 | [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \ |
6b737370 L |
921 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \ |
922 | {dl6amain.c} "dl6a6" "dl6b.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c | 923 | [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \ |
6b737370 L |
924 | "$NOPIE_LDFLAGS -Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \ |
925 | {dl6amain.c} "dl6a7" "dl6a.out" "$NOPIE_CFLAGS" ] \ | |
fd121c5c JW |
926 | [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \ |
927 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
928 | {dl6bmain.c} "dl6b1" "dl6a.out" ] \ | |
929 | [list "Run dl6b2 with dlopen on libdl6b.so" \ | |
930 | "-Wl,--no-as-needed $extralibs" "" \ | |
931 | {dl6bmain.c} "dl6b2" "dl6b.out" ] \ | |
932 | [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \ | |
933 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
934 | {dl6cmain.c} "dl6c1" "dl6b.out" ] \ | |
935 | [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \ | |
936 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
937 | {dl6dmain.c} "dl6d1" "dl6b.out" ] \ | |
487b6440 | 938 | [list "Run pr21964-2" \ |
8dfb7cbf L |
939 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-2a.so $extralibs" "" \ |
940 | {pr21964-2c.c} "pr21964-2" "pass.out" ] \ | |
bf3077a6 MM |
941 | [list "Run pr21964-5" \ |
942 | "-Wl,--no-as-needed,-rpath,tmpdir tmpdir/pr21964-1a.so $extralibs" "" \ | |
943 | {pr21964-5.c} "pr21964-5" "pass.out" ] \ | |
fd121c5c JW |
944 | ] |
945 | ||
946 | # Only run them when libdl is available. | |
947 | if [check_libdl_available] { | |
948 | # XFAIL on NetBSD ELF systems as they do not currently support the .*_array | |
949 | # sections. | |
950 | run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*" | |
951 | } | |
952 | ||
63406f0a L |
953 | # Check --no-add-needed and --no-copy-dt-needed-entries |
954 | set testname "--no-add-needed" | |
f1d7f4a6 | 955 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 956 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
957 | pass $testname |
958 | } { | |
959 | fail $testname | |
960 | } | |
961 | set testname "--no-copy-dt-needed-entries" | |
f1d7f4a6 | 962 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 963 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
964 | pass $testname |
965 | } { | |
966 | fail $testname | |
967 | } | |
8fbb09e8 | 968 | set testname "--no-add-needed -shared" |
f1d7f4a6 | 969 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 970 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
971 | pass $testname |
972 | } { | |
973 | fail $testname | |
974 | } | |
975 | set testname "--no-copy-dt-needed-entries -shared" | |
f1d7f4a6 | 976 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 977 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
978 | pass $testname |
979 | } { | |
980 | fail $testname | |
981 | } | |
63406f0a | 982 | |
dd98f8d2 | 983 | # Check to see if the C++ compiler works |
55255dae L |
984 | if { [which $CXX] == 0 } { |
985 | return | |
986 | } | |
987 | ||
988 | set build_cxx_tests { | |
989 | {"Build libdl3a.so with --dynamic-list=dl3.list" | |
990 | "-shared -Wl,--dynamic-list=dl3.list" "-fPIC" | |
991 | {dl3.cc} {} "libdl3a.so" "c++"} | |
992 | {"Build libdl3b.so with -Bsymbolic" | |
993 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
994 | {dl3.cc} {} "libdl3b.so" "c++"} | |
995 | {"Build libdl3a.so with --dynamic-list-cpp-typeinfo" | |
996 | "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC" | |
997 | {dl3.cc} {} "libdl3c.so" "c++"} | |
d8cf8b51 | 998 | {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" |
199add01 | 999 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi" |
d8cf8b51 L |
1000 | {del.cc new.cc} {} "libnew1a.so" "c++"} |
1001 | {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" | |
199add01 | 1002 | "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi" |
d8cf8b51 | 1003 | {del.cc new.cc} {} "libnew1b.so" "c++"} |
55255dae L |
1004 | } |
1005 | ||
b37470e4 L |
1006 | # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer. |
1007 | # {"Run with libdl3b.so" | |
1008 | # "tmpdir/libdl3b.so" "" | |
1009 | # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"} | |
cb5ab6c8 L |
1010 | set run_cxx_tests { |
1011 | {"Run with libdl3a.so" | |
1012 | "-Wl,--no-as-needed tmpdir/libdl3a.so" "" | |
1013 | {dl3main.cc} "dl3a" "dl3a.out" "" "c++"} | |
55255dae | 1014 | {"Run with libdl3c.so" |
5cb49709 | 1015 | "-Wl,--no-as-needed tmpdir/libdl3c.so" "" |
55255dae | 1016 | {dl3main.cc} "dl3c" "dl3a.out" "" "c++"} |
d8cf8b51 | 1017 | {"Run with libnew1a.so" |
d9816402 | 1018 | "-Wl,--no-as-needed tmpdir/libnew1a.so" "" |
199add01 | 1019 | {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"} |
d8cf8b51 | 1020 | {"Run with libnew1b.so" |
d9816402 | 1021 | "-Wl,--no-as-needed tmpdir/libnew1b.so" "" |
199add01 | 1022 | {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"} |
55255dae L |
1023 | } |
1024 | ||
1025 | run_cc_link_tests $build_cxx_tests | |
982c6f26 | 1026 | run_ld_link_exec_tests $run_cxx_tests |
22ef172a L |
1027 | |
1028 | if { [istarget *-*-linux*] | |
1029 | || [istarget *-*-nacl*] | |
1030 | || [istarget *-*-gnu*] } { | |
1031 | run_cc_link_tests [list \ | |
1032 | [list \ | |
1033 | "Build libpr2404b.a with PIE" \ | |
1034 | "" \ | |
1035 | "-fPIE" \ | |
1036 | { pr2404b.c } \ | |
1037 | {} \ | |
1038 | "libpr2404b.a" \ | |
1039 | ] \ | |
07492f66 L |
1040 | [list \ |
1041 | "Build pr19579a.o" \ | |
1042 | "" "-fPIE" \ | |
1043 | {pr19579a.c} \ | |
1044 | {} \ | |
1045 | "libpr19579a.a" \ | |
1046 | ] \ | |
1047 | [list \ | |
1048 | "Build libpr19579.so" \ | |
1049 | "-shared" \ | |
1050 | "-fPIC" \ | |
1051 | {pr19579b.c} \ | |
1052 | {} \ | |
1053 | "libpr19579.so" \ | |
1054 | ] \ | |
d6f48aed L |
1055 | [list \ |
1056 | "Build libpr19579now.so" \ | |
1057 | "-shared -Wl,-z,now" \ | |
1058 | "-fPIC" \ | |
1059 | {pr19579b.c} \ | |
1060 | {} \ | |
1061 | "libpr19579.so" \ | |
1062 | ] \ | |
d346bb27 L |
1063 | [list \ |
1064 | "Build pr22393-2a.so" \ | |
1065 | "-shared -Wl,-z,separate-code" \ | |
1066 | "-fPIC" \ | |
1067 | {pr22393-2a.c} \ | |
1068 | {{readelf -lW pr22393-2a.rd} \ | |
1069 | {readelf -lW pr22393-2b.rd}} \ | |
1070 | "pr22393-2a.so" \ | |
1071 | ] \ | |
1072 | [list \ | |
1073 | "Build pr22393-2a-now.so" \ | |
1074 | "-shared -Wl,-z,separate-code,-z,now" \ | |
1075 | "-fPIC" \ | |
1076 | {pr22393-2a.c} \ | |
1077 | {{readelf -lW pr22393-2a.rd} \ | |
1078 | {readelf -lW pr22393-2b.rd}} \ | |
1079 | "pr22393-2a-now.so" \ | |
1080 | ] \ | |
1081 | [list \ | |
1082 | "Build pr22393-2" \ | |
1083 | "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \ | |
1084 | "$NOPIE_CFLAGS" \ | |
1085 | {pr22393-2b.c} \ | |
1086 | {{readelf -lW pr22393-2a.rd} \ | |
1087 | {readelf -lW pr22393-2b.rd}} \ | |
1088 | "pr22393-2" \ | |
1089 | ] \ | |
1090 | [list \ | |
1091 | "Build pr22393-2 (PIE)" \ | |
1092 | "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \ | |
1093 | "-fPIE" \ | |
1094 | {pr22393-2b.c} \ | |
1095 | {{readelf -lW pr22393-2a.rd} \ | |
1096 | {readelf -lW pr22393-2b.rd}} \ | |
1097 | "pr22393-2-pie" \ | |
1098 | ] \ | |
1099 | [list \ | |
1100 | "Build pr22393-2 (static)" \ | |
1101 | "-static -Wl,-z,separate-code" \ | |
1102 | "" \ | |
1103 | {pr22393-2a.c pr22393-2b.c} \ | |
1104 | {{readelf -lW pr22393-2a.rd} \ | |
1105 | {readelf -lW pr22393-2b.rd}} \ | |
1106 | "pr22393-2-static" \ | |
1107 | ] \ | |
22ef172a | 1108 | ] |
982c6f26 | 1109 | run_ld_link_exec_tests [list \ |
d6f48aed L |
1110 | [list \ |
1111 | "Run pr18458 with PIE" \ | |
1112 | "-pie -Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" \ | |
1113 | "" \ | |
1114 | {pr18458c.c} \ | |
1115 | "pr18458p" \ | |
1116 | "pass.out" \ | |
1117 | "-fPIE" \ | |
1118 | ] \ | |
22ef172a L |
1119 | [list \ |
1120 | "Run pr2404 with PIE" \ | |
d9816402 | 1121 | "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ |
22ef172a L |
1122 | "" \ |
1123 | { dummy.c } \ | |
1124 | "pr2404pie" \ | |
1125 | "pr2404.out" \ | |
1126 | "-fPIE" \ | |
1127 | ] \ | |
d6f48aed L |
1128 | [list \ |
1129 | "Run pr2404 with PIE (-z now)" \ | |
1130 | "-pie -Wl,-z,now -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404n.so" \ | |
1131 | "" \ | |
1132 | { dummy.c } \ | |
1133 | "pr2404pien" \ | |
1134 | "pr2404.out" \ | |
1135 | "-fPIE" \ | |
1136 | ] \ | |
1659f720 L |
1137 | [list \ |
1138 | "Run pr18718" \ | |
1139 | "" \ | |
1140 | "" \ | |
c45bd4fd | 1141 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1142 | "pr18718" \ |
1143 | "pass.out" \ | |
edcab5e8 | 1144 | "-O2 -I../bfd" \ |
1659f720 | 1145 | ] \ |
d6f48aed L |
1146 | [list \ |
1147 | "Run pr18718 (-z now)" \ | |
1148 | "-Wl,-z,now" \ | |
1149 | "" \ | |
1150 | { pr18718.c check-ptr-eq.c } \ | |
1151 | "pr18718" \ | |
1152 | "pass.out" \ | |
1153 | "-O2 -I../bfd" \ | |
1154 | ] \ | |
1659f720 L |
1155 | [list \ |
1156 | "Run pr18718 with PIE (1)" \ | |
1157 | "-pie" \ | |
1158 | "" \ | |
c45bd4fd | 1159 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1160 | "pr18718pie1" \ |
1161 | "pass.out" \ | |
edcab5e8 | 1162 | "-O2 -fPIE -I../bfd" \ |
1659f720 L |
1163 | ] \ |
1164 | [list \ | |
1165 | "Run pr18718 with PIE (2)" \ | |
1166 | "" \ | |
1167 | "" \ | |
c45bd4fd | 1168 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1169 | "pr18718pie2" \ |
1170 | "pass.out" \ | |
edcab5e8 | 1171 | "-O2 -fPIE -I../bfd" \ |
1659f720 | 1172 | ] \ |
d6f48aed L |
1173 | [list \ |
1174 | "Run pr18718 with PIE (3)" \ | |
1175 | "-pie -Wl,-z,now" \ | |
1176 | "" \ | |
1177 | { pr18718.c check-ptr-eq.c } \ | |
1178 | "pr18718pie3" \ | |
1179 | "pass.out" \ | |
1180 | "-O2 -fPIE -I../bfd" \ | |
1181 | ] \ | |
1182 | [list \ | |
1183 | "Run pr18718 with PIE (4)" \ | |
1184 | "-Wl,-z,now" \ | |
1185 | "" \ | |
1186 | { pr18718.c check-ptr-eq.c } \ | |
1187 | "pr18718pie4" \ | |
1188 | "pass.out" \ | |
1189 | "-O2 -fPIE -I../bfd" \ | |
1190 | ] \ | |
1659f720 L |
1191 | [list \ |
1192 | "Run pr18718 with PIC (1)" \ | |
1193 | "" \ | |
1194 | "" \ | |
c45bd4fd | 1195 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1196 | "pr18718pic1" \ |
1197 | "pass.out" \ | |
edcab5e8 | 1198 | "-O2 -fPIC -I../bfd" \ |
1659f720 L |
1199 | ] \ |
1200 | [list \ | |
1201 | "Run pr18718 with PIC (2)" \ | |
1202 | "-pie" \ | |
1203 | "" \ | |
c45bd4fd | 1204 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
1205 | "pr18718pic2" \ |
1206 | "pass.out" \ | |
edcab5e8 | 1207 | "-O2 -fPIC -I../bfd" \ |
1659f720 | 1208 | ] \ |
d6f48aed L |
1209 | [list \ |
1210 | "Run pr18718 with PIC (3)" \ | |
1211 | "-Wl,-z,now" \ | |
1212 | "" \ | |
1213 | { pr18718.c check-ptr-eq.c } \ | |
1214 | "pr18718pic3" \ | |
1215 | "pass.out" \ | |
1216 | "-O2 -fPIC -I../bfd" \ | |
1217 | ] \ | |
1218 | [list \ | |
1219 | "Run pr18718 with PIC (4)" \ | |
1220 | "-pie -Wl,-z,now" \ | |
1221 | "" \ | |
1222 | { pr18718.c check-ptr-eq.c } \ | |
1223 | "pr18718pic4" \ | |
1224 | "pass.out" \ | |
1225 | "-O2 -fPIC -I../bfd" \ | |
1226 | ] \ | |
07492f66 L |
1227 | [list \ |
1228 | "Run pr19579" \ | |
d9816402 | 1229 | "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ |
07492f66 L |
1230 | "" \ |
1231 | {dummy.c} \ | |
1232 | "pr19579" \ | |
1233 | "pass.out" \ | |
1234 | "-fPIE" \ | |
1235 | ] \ | |
d6f48aed L |
1236 | [list \ |
1237 | "Run pr19579 (-z now)" \ | |
1238 | "-pie -Wl,-z,now -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ | |
1239 | "" \ | |
1240 | {dummy.c} \ | |
1241 | "pr19579n" \ | |
1242 | "pass.out" \ | |
1243 | "-fPIE" \ | |
1244 | ] \ | |
d346bb27 L |
1245 | [list \ |
1246 | "Run pr22393-2" \ | |
1247 | "$NOPIE_LDFLAGS -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a.so" \ | |
1248 | "" \ | |
1249 | {pr22393-2b.c} \ | |
1250 | "pr22393-2" \ | |
1251 | "pass.out" \ | |
1252 | "$NOPIE_CFLAGS" \ | |
1253 | ] \ | |
1254 | [list \ | |
1255 | "Run pr22393-2 (PIE)" \ | |
1256 | "-pie -Wl,-z,separate-code,--no-as-needed tmpdir/pr22393-2a-now.so" \ | |
1257 | "" \ | |
1258 | {pr22393-2b.c} \ | |
1259 | "pr22393-2-pie" \ | |
1260 | "pass.out" \ | |
1261 | "-fPIE" \ | |
1262 | ] \ | |
1263 | [list \ | |
1264 | "Run pr22393-2 (static)" \ | |
1265 | "-static -Wl,-z,separate-code" \ | |
1266 | "" \ | |
1267 | {pr22393-2a.c pr22393-2b.c} \ | |
1268 | "pr22393-2-static" \ | |
1269 | "pass.out" \ | |
1270 | ] \ | |
823143c6 L |
1271 | [list \ |
1272 | "Run pr21964-4" \ | |
1273 | "" \ | |
1274 | "" \ | |
1275 | {pr21964-4.c} \ | |
1276 | "pr21964-4" \ | |
1277 | "pass.out" \ | |
1278 | "" \ | |
1279 | "" \ | |
1280 | "" \ | |
1281 | "-ldl" \ | |
1282 | ] \ | |
22ef172a L |
1283 | ] |
1284 | } | |
aec6b87e | 1285 | |
f1b2ca70 | 1286 | proc mix_pic_and_non_pic {xfails cflags ldflags exe} { |
aec6b87e L |
1287 | run_cc_link_tests [list \ |
1288 | [list \ | |
1289 | "Build libpr19719a.so" \ | |
1290 | "-shared -Wl,-soname,libpr19719.so" \ | |
1291 | "-fPIC" \ | |
1292 | { pr19719d.c } \ | |
1293 | {} \ | |
1294 | "libpr19719a.so" \ | |
1295 | ] \ | |
1296 | [list \ | |
1297 | "Build libpr19719b.so" \ | |
1298 | "-shared -Wl,-soname,libpr19719.so" \ | |
1299 | "-fPIC" \ | |
1300 | { dummy.c } \ | |
1301 | {} \ | |
1302 | "libpr19719b.so" \ | |
1303 | ] \ | |
1304 | [list \ | |
f1b2ca70 | 1305 | "Build libpr19719b.o" \ |
aec6b87e L |
1306 | "-r -nostdlib" \ |
1307 | "-fPIC" \ | |
1308 | { pr19719b.c } \ | |
1309 | {} \ | |
1310 | "libpr19719b.o" \ | |
1311 | ] \ | |
1312 | ] | |
1313 | ||
f1b2ca70 | 1314 | send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n" |
aec6b87e L |
1315 | exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so |
1316 | ||
982c6f26 | 1317 | run_ld_link_exec_tests [list \ |
aec6b87e | 1318 | [list \ |
f1b2ca70 | 1319 | "Run $exe fun defined" \ |
d9816402 | 1320 | "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \ |
aec6b87e L |
1321 | "" \ |
1322 | { pr19719a.c pr19719c.c } \ | |
f1b2ca70 | 1323 | $exe \ |
aec6b87e L |
1324 | "pass.out" \ |
1325 | "$cflags" \ | |
1326 | ] \ | |
1327 | ] | |
1328 | ||
f1b2ca70 | 1329 | send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n" |
aec6b87e L |
1330 | exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so |
1331 | ||
7494161b L |
1332 | foreach targ $xfails { |
1333 | setup_xfail $targ | |
1334 | } | |
1335 | ||
d9816402 AM |
1336 | if ![isnative] { |
1337 | unsupported "Run $exe fun undefined" | |
1338 | return | |
1339 | } | |
1340 | ||
f1b2ca70 | 1341 | set exec_output [run_host_cmd "tmpdir/$exe" ""] |
aec6b87e | 1342 | if {![string match "PASS" $exec_output]} { |
f1b2ca70 | 1343 | fail "Run $exe fun undefined" |
aec6b87e | 1344 | } else { |
f1b2ca70 | 1345 | pass "Run $exe fun undefined" |
aec6b87e L |
1346 | } |
1347 | } | |
1348 | ||
f1b2ca70 AM |
1349 | mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719" |
1350 | mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie" |