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