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