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