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