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