Commit | Line | Data |
---|---|---|
d2dee3b2 | 1 | # Expect script for various ELF tests. |
2571583a | 2 | # Copyright (C) 2006-2017 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 | ||
81ff47b3 MR |
34 | # This target requires extra GAS options when building code for shared |
35 | # libraries. | |
36 | set AFLAGS_PIC "" | |
37 | if [istarget "tic6x-*-*"] { | |
38 | append AFLAGS_PIC " -mpic -mpid=near" | |
39 | } | |
40 | # This target requires a non-default emulation for successful shared | |
41 | # library/executable builds. | |
42 | set LFLAGS "" | |
43 | if [istarget "tic6x-*-*"] { | |
44 | append LFLAGS " -melf32_tic6x_le" | |
45 | } | |
46 | ||
47 | # PR ld/20828 check for correct dynamic symbol table entries where: | |
48 | # - symbols have been defined with a linker script, | |
49 | # - the same symbols have been seen in shared library used in the link, | |
50 | # - the shared library symbols have been swept in section garbage collection. | |
51 | # Verify that the symbols are global rather than local and that a version | |
52 | # script adjusts them accordingly. | |
902e9fc7 MR |
53 | # Also verify that a version definition supplied by an object rather than |
54 | # a version script and forcibly exported is unaffected by section GC. | |
81ff47b3 MR |
55 | if { [check_gc_sections_available] } { |
56 | run_ld_link_tests [list \ | |
57 | [list \ | |
58 | "PR ld/20828 dynamic symbols with section GC\ | |
15a00b13 MR |
59 | (auxiliary shared library)" \ |
60 | "$LFLAGS -shared --gc-sections -T pr20828.ld" "" "$AFLAGS_PIC" \ | |
61 | {pr20828.s} \ | |
62 | {{readelf --dyn-syms pr20828-a.sd} \ | |
63 | {readelf --dyn-syms pr20828-b.sd}} \ | |
64 | "libpr20828.so"] \ | |
81ff47b3 MR |
65 | [list \ |
66 | "PR ld/20828 dynamic symbols with section GC (plain)" \ | |
15a00b13 MR |
67 | "$LFLAGS -shared --gc-sections -T pr20828.ld" \ |
68 | "tmpdir/libpr20828.so" "$AFLAGS_PIC" \ | |
69 | {pr20828.s} \ | |
70 | {{readelf --dyn-syms pr20828-a.sd} \ | |
71 | {readelf --dyn-syms pr20828-b.sd}} \ | |
72 | "pr20828-1.so"] \ | |
81ff47b3 MR |
73 | [list \ |
74 | "PR ld/20828 dynamic symbols with section GC (version script)" \ | |
15a00b13 MR |
75 | "$LFLAGS -shared --gc-sections -T pr20828.ld\ |
76 | --version-script=pr20828.ver" \ | |
77 | "tmpdir/libpr20828.so" \ | |
78 | "$AFLAGS_PIC" \ | |
79 | {pr20828.s} \ | |
80 | {{readelf --dyn-syms pr20828-b.sd} \ | |
81 | {readelf --dyn-syms pr20828-c.sd}} \ | |
902e9fc7 MR |
82 | "pr20828-2.so"] \ |
83 | [list \ | |
84 | "PR ld/20828 dynamic symbols with section GC\ | |
85 | (versioned shared library)" \ | |
86 | "$LFLAGS -shared --gc-sections -T pr20828.ld\ | |
87 | --version-script=pr20828-v.ver" \ | |
88 | "" "$AFLAGS_PIC" \ | |
89 | {pr20828.s} \ | |
90 | {{readelf --dyn-syms pr20828-c.sd} \ | |
91 | {readelf --dyn-syms pr20828-d.sd} \ | |
92 | {readelf --dyn-syms pr20828-e.sd}} \ | |
93 | "libpr20828-v.so"] \ | |
94 | [list \ | |
95 | "PR ld/20828 dynamic symbols with section GC (versioned)" \ | |
96 | "$LFLAGS -shared --gc-sections -T pr20828.ld\ | |
97 | --version-script=pr20828-v.ver" \ | |
98 | "tmpdir/libpr20828-v.so" \ | |
99 | "$AFLAGS_PIC" \ | |
100 | {pr20828.s} \ | |
101 | {{readelf --dyn-syms pr20828-c.sd} \ | |
102 | {readelf --dyn-syms pr20828-d.sd} \ | |
103 | {readelf --dyn-syms pr20828-e.sd}} \ | |
104 | "pr20828-v.so"] \ | |
105 | [list \ | |
106 | "PR ld/20828 forcibly exported symbol version without section GC" \ | |
107 | "$LFLAGS -e foo -E -T pr20828-v.ld" "" "" \ | |
108 | {pr20828-v.s} \ | |
109 | {{objdump -p pr20828-v.od}} \ | |
110 | "pr20828-v-1"] \ | |
111 | [list \ | |
112 | "PR ld/20828 forcibly exported symbol version with section GC" \ | |
113 | "$LFLAGS -e foo --gc-sections -E -T pr20828-v.ld" "" "" \ | |
114 | {pr20828-v.s} \ | |
115 | {{objdump -p pr20828-v.od}} \ | |
116 | "pr20828-v-2"]] | |
81ff47b3 | 117 | } |
80070c0d MR |
118 | # PR ld/21233 check for correct dynamic symbol table entries where: |
119 | # - a symbol has been defined in a shared library used in the link, | |
120 | # - the symbol has been referenced from a section swept in garbage collection, | |
121 | # - the symbol has also been forced to be entered in the output file as an | |
122 | # undefined symbol, either with a command-line option or a linker script | |
123 | # command. | |
124 | # Verify that the undefined symbol is global rather than local. | |
125 | if { [check_gc_sections_available] } { | |
126 | run_ld_link_tests [list \ | |
127 | [list \ | |
128 | "PR ld/21233 dynamic symbols with section GC\ | |
129 | (auxiliary shared library)" \ | |
130 | "$LFLAGS -shared -T pr21233.ld" "" "$AFLAGS_PIC" \ | |
131 | {pr21233-l.s} \ | |
132 | {{readelf --dyn-syms pr21233-l.sd}} \ | |
4d5efb85 HPN |
133 | "libpr21233.so"]] |
134 | run_ld_link_tests [list \ | |
80070c0d MR |
135 | [list \ |
136 | "PR ld/21233 dynamic symbols with section GC (--undefined)" \ | |
137 | "$LFLAGS --gc-sections -e foo --undefined=bar -T pr21233.ld" \ | |
138 | "tmpdir/libpr21233.so" "" \ | |
139 | {pr21233.s} \ | |
140 | {{readelf --dyn-syms pr21233.sd}} \ | |
141 | "pr21233-1"] \ | |
142 | [list \ | |
143 | "PR ld/21233 dynamic symbols with section GC (--require-defined)" \ | |
144 | "$LFLAGS --gc-sections -e foo --require-defined=bar\ | |
145 | -T pr21233.ld" \ | |
146 | "tmpdir/libpr21233.so" "" \ | |
147 | {pr21233.s} \ | |
148 | {{readelf --dyn-syms pr21233.sd}} \ | |
149 | "pr21233-2"] \ | |
150 | [list \ | |
151 | "PR ld/21233 dynamic symbols with section GC (EXTERN)" \ | |
152 | "$LFLAGS --gc-sections -e foo -T pr21233-e.ld" \ | |
153 | "tmpdir/libpr21233.so" "" \ | |
154 | {pr21233.s} \ | |
155 | {{readelf --dyn-syms pr21233.sd}} \ | |
4d5efb85 | 156 | "pr21233-3"]] "cris*-*-*" |
80070c0d | 157 | } |
81ff47b3 | 158 | |
dd98f8d2 | 159 | # Check to see if the C compiler works |
d2dee3b2 L |
160 | if { [which $CC] == 0 } { |
161 | return | |
162 | } | |
163 | ||
fb2c6e43 | 164 | # Add -ldl to extralibs if needed |
d9816402 | 165 | set extralibs "" |
fb2c6e43 AT |
166 | if { ![istarget *-*-freebsd*]} { |
167 | set extralibs "-ldl" | |
168 | } | |
169 | ||
d2dee3b2 L |
170 | set build_tests { |
171 | {"Build libfoo.so" | |
172 | "-shared" "-fPIC" | |
173 | {foo.c} {} "libfoo.so"} | |
174 | {"Build versioned libfoo.so" | |
175 | "-shared -Wl,--version-script=foo.map" "-fPIC" | |
55255dae | 176 | {foo.c} {} "libfoov.so"} |
d2dee3b2 L |
177 | {"Build libbar.so" |
178 | "-shared" "-fPIC" | |
179 | {begin.c end.c} {} "libbar.so"} | |
fab4a87f L |
180 | {"Build warn libbar.so" |
181 | "-shared" "-fPIC" | |
2bd7f877 AB |
182 | {beginwarn.c end.c} |
183 | {{readelf {-S --wide} libbarw.rd} | |
3239a423 | 184 | {warning "^.*beginwarn.c:7: warning: function foo is deprecated$"}} |
2bd7f877 | 185 | "libbarw.so" "c"} |
d2dee3b2 L |
186 | {"Build hidden libbar.so" |
187 | "-shared" "-fPIC" | |
188 | {begin.c endhidden.c} {} "libbarh.so"} | |
189 | {"Build protected libbar.so" | |
190 | "-shared" "-fPIC" | |
191 | {begin.c endprotected.c} {} "libbarp.so"} | |
192 | {"Build libbar.so with libfoo.so" | |
193 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
194 | {end.c} {} "libbarfoo.so"} | |
195 | {"Build libar.so with versioned libfoo.so" | |
196 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
197 | {end.c} {} "libbarfoov.so"} | |
198 | {"Build hidden libbar.so with libfoo.so" | |
199 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
200 | {endhidden.c} {} "libbarhfoo.so"} | |
201 | {"Build hidden libar.so with versioned libfoo.so" | |
202 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
203 | {endhidden.c} {} "libbarhfoov.so"} | |
204 | {"Build protected libbar.so with libfoo.so" | |
205 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
206 | {endprotected.c} {} "libbarpfoo.so"} | |
207 | {"Build protected libbar.so with versioned libfoo.so" | |
208 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
209 | {endprotected.c} {} "libbarpfoov.so"} | |
55255dae L |
210 | {"Build libdl1.so" |
211 | "-shared" "-fPIC" | |
212 | {dl1.c} {} "libdl1.so"} | |
213 | {"Build libdl2a.so with --dynamic-list=dl2.list" | |
214 | "-shared -Wl,--dynamic-list=dl2.list" "-fPIC" | |
215 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
b7b7fe3f AS |
216 | {"Build libdl2a.so with --dynamic-list=dl2a.list" |
217 | "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC" | |
218 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
40b36307 L |
219 | {"Build libdl2a.so with --dynamic-list-data" |
220 | "-shared -Wl,--dynamic-list-data" "-fPIC" | |
221 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
55255dae L |
222 | {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list" |
223 | "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC" | |
224 | {dl2.c dl2xxx.c} {} "libdl2b.so"} | |
d8cf8b51 | 225 | {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list" |
40b36307 | 226 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC" |
d8cf8b51 | 227 | {dl2.c dl2xxx.c} {} "libdl2c.so"} |
c555238b L |
228 | {"Build libdl4a.so with --dynamic-list=dl4.list" |
229 | "-shared -Wl,--dynamic-list=dl4.list" "-fPIC" | |
230 | {dl4.c dl4xxx.c} {} "libdl4a.so"} | |
d8cf8b51 | 231 | {"Build libdl4b.so with --dynamic-list-data" |
40b36307 | 232 | "-shared -Wl,--dynamic-list-data" "-fPIC" |
c555238b | 233 | {dl4.c dl4xxx.c} {} "libdl4b.so"} |
d8cf8b51 L |
234 | {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list" |
235 | "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC" | |
236 | {dl4.c dl4xxx.c} {} "libdl4c.so"} | |
237 | {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list" | |
40b36307 | 238 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC" |
d8cf8b51 L |
239 | {dl4.c dl4xxx.c} {} "libdl4d.so"} |
240 | {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new" | |
241 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" | |
242 | {dl4.c dl4xxx.c} {} "libdl4e.so"} | |
243 | {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions" | |
244 | "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC" | |
245 | {dl4.c dl4xxx.c} {} "libdl4f.so"} | |
246 | {"Build libdl6a.so" | |
247 | "-shared" "-fPIC" | |
248 | {dl6.c} {} "libdl6a.so"} | |
249 | {"Build libdl6b.so with -Bsymbolic --dynamic-list-data" | |
250 | "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC" | |
251 | {dl6.c} {} "libdl6b.so"} | |
252 | {"Build libdl6c.so with -Bsymbolic" | |
253 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
254 | {dl6.c} {} "libdl6c.so"} | |
255 | {"Build libdl6d.so with --dynamic-list-data -Bsymbolic" | |
256 | "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC" | |
257 | {dl6.c} {} "libdl6d.so"} | |
43edfb7f L |
258 | {"Build libdata1.so" |
259 | "-shared" "-fPIC" | |
260 | {data1.c} {} "libdata1.so"} | |
a47edf27 L |
261 | {"Build libdata2.so" |
262 | "-shared" "-fPIC" | |
263 | {data2.c} {} "libdata2.so"} | |
0a36a439 L |
264 | {"Build libcomm1.o" |
265 | "-r -nostdlib" "" | |
266 | {comm1.c} {} "libcomm1.o"} | |
267 | {"Build libfunc1.so" | |
268 | "-shared" "-fPIC" | |
269 | {func1.c} {} "libfunc1.so"} | |
d8880531 L |
270 | {"Build libpr9676-1.a" |
271 | "" "-fPIC" | |
272 | {pr9676-1.c} {} "libpr9676-1.a"} | |
273 | {"Build libpr9676-2.a" | |
274 | "" "-fPIC" | |
275 | {pr9676-2.c} {} "libpr9676-2.a"} | |
276 | {"Build libpr9676-3.so" | |
277 | "-shared" "-fPIC" | |
278 | {pr9676-3.c} {} "libpr9676-3.so"} | |
279 | {"Build libpr9676-4.so" | |
280 | "-shared" "-fPIC" | |
281 | {pr9676-4.c} {} "libpr9676-4.so"} | |
282 | {"Build libpr9676-4a.so" | |
283 | "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group" | |
284 | "-fPIC" | |
285 | {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"} | |
54ac0771 L |
286 | {"Build libpr9679.so" |
287 | "-shared" "-fPIC -O0" | |
288 | {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"} | |
d023c380 L |
289 | {"Build libpr11138-1.so" |
290 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
291 | {pr11138-1.c} {} "libpr11138-1.so"} | |
292 | {"Build libpr11138-2.o" | |
293 | "-r -nostdlib" "" | |
294 | {pr11138-2.c} {} "libpr11138-2.o"} | |
3e0882af L |
295 | {"Build pr13250-1.so" |
296 | "-shared" "-fPIC" | |
297 | {pr13250-1.c} {} "libpr13250-1.so"} | |
298 | {"Build pr13250-2.so with libpr13250-1.so" | |
5cb49709 | 299 | "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC" |
3e0882af L |
300 | {pr13250-2.c} {} "libpr13250-2.so"} |
301 | {"Build libpr13250-3.o" | |
302 | "-r -nostdlib" "" | |
303 | {pr13250-3.c} {} "libpr13250-3.o"} | |
bc9ad2e4 L |
304 | {"Build libpr14323-2.so" |
305 | "-shared" "-fPIC" | |
306 | {pr14323-2.c} {} "libpr14323-2.so"} | |
dda8ddc5 L |
307 | {"Build pr14862-1.o" |
308 | "-r -nostdlib" "" | |
309 | {pr14862-1.c} {} "libpr14862-1.o"} | |
310 | {"Build libpr14862.so" | |
311 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
312 | {pr14862-2.c} {} "libpr14862.so"} | |
63406f0a L |
313 | {"Build libneeded1b.so" |
314 | "-shared" "-fPIC" | |
315 | {needed1b.c} {} "libneeded1b.so"} | |
316 | {"Build libneeded1a.so" | |
2eb64a9f | 317 | "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC" |
63406f0a L |
318 | {needed1a.c} {} "libneeded1a.so"} |
319 | {"Build libneeded1c.o" | |
320 | "-r -nostdlib" "" | |
321 | {needed1c.c} {} "libneeded1c.o"} | |
8fbb09e8 L |
322 | {"Build libneeded1pic.o" |
323 | "-r -nostdlib" "-fPIC" | |
324 | {needed1c.c} {} "libneeded1pic.o"} | |
325 | {"Build needed1a.so with --add-needed" | |
8cfc7cf8 | 326 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
327 | {dummy.c} {} "needed1a.so"} |
328 | {"Build needed1b.so with --copy-dt-needed-entries" | |
8cfc7cf8 | 329 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
330 | {dummy.c} {} "needed1b.so"} |
331 | {"Build needed1a.so with --no-add-needed" | |
8cfc7cf8 | 332 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-add-needed -Ltmpdir -lneeded1a" "" |
8fbb09e8 L |
333 | {dummy.c} {} "needed1c.so"} |
334 | {"Build needed1b.so with --no-copy-dt-needed-entries" | |
8cfc7cf8 | 335 | "-shared tmpdir/libneeded1pic.o -Wl,--no-as-needed,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" "" |
8fbb09e8 | 336 | {dummy.c} {} "needed1d.so"} |
8877b5e5 AM |
337 | {"Build librel.so" |
338 | "-shared" "-fPIC" | |
339 | {rel.c} {} "librel.so"} | |
5e319dd3 L |
340 | {"Build libneeded2a.so" |
341 | "-shared" "-fPIC" | |
342 | {needed2a.c} {} "libneeded2a.so"} | |
343 | {"Build libneeded2b.so" | |
344 | "-shared -Wl,--version-script,needed2.ver" "-fPIC" | |
345 | {needed2b.c} {} "libneeded2b.so"} | |
346 | {"Build libneeded2c.o" | |
347 | "-r -nostdlib" "" | |
348 | {needed2c.c} {} "libneeded2c.o"} | |
349 | {"Build needed2" | |
350 | "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" "" | |
351 | {dummy.c} {} "needed2"} | |
1240be6b AM |
352 | {"Build libneeded3a.so" |
353 | "-shared -Wl,--no-add-needed" "-fPIC" | |
354 | {needed1a.c} {} "libneeded3a.so"} | |
355 | {"Build libneeded3b.so" | |
356 | "-shared -Wl,--no-as-needed,--add-needed -Ltmpdir -lneeded1b" "-fPIC" | |
357 | {dummy.c} {} "libneeded3b.so"} | |
358 | {"Build needed3.o" | |
359 | "-r -nostdlib" "" | |
360 | {needed3.c} {} "libneeded3.so"} | |
361 | {"Build needed3" | |
362 | "tmpdir/needed3.o -Wl,--as-needed -Ltmpdir -lneeded3a -lneeded3b -lneeded1b" "" | |
363 | {dummy.c} {} "needed3"} | |
cec2c50d L |
364 | {"Build libpr2404a.so" |
365 | "-shared" "-fPIC" | |
366 | {pr2404a.c} {} "libpr2404a.so"} | |
367 | {"Build libpr2404b.a" | |
368 | "" "" | |
369 | {pr2404b.c} {} "libpr2404b.a"} | |
50a53d3f | 370 | {"Build rdynamic-1" |
bb4287c5 | 371 | "-Wl,-export-dynamic,--gc-sections" "-ffunction-sections" |
50a53d3f | 372 | {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"} |
d6f6f455 L |
373 | {"Build dynamic-1" |
374 | "-Wl,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections" | |
375 | {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"} | |
bb4d2ac2 L |
376 | {"Build libpr16496a.so" |
377 | "-shared -Wl,--version-script=pr16496a.map" "-fPIC" | |
378 | {pr16496a.c} {} "libpr16496a.so"} | |
379 | {"Build libpr16496b.a" | |
380 | "" "-fPIC" | |
381 | {pr16496b.c} {} "libpr16496b.a"} | |
382 | {"Build libpr16496b.so" | |
8cfc7cf8 | 383 | "-shared -Wl,--no-as-needed tmpdir/pr16496b.o tmpdir/libpr16496a.so" "" |
bb4d2ac2 | 384 | {dummy.c} {{objdump {-R} pr16496b.od}} "libpr16496b.so"} |
fb389763 L |
385 | {"Build libpr16452a.so" |
386 | "-shared -Wl,-soname,libpr16452a.so,--version-script=pr16452.map" "-fPIC" | |
387 | {pr16452a.c} {} "libpr16452a.so"} | |
388 | {"Build libpr16452b.so" | |
389 | "-shared -Wl,-soname,libpr16452b.so,--no-as-needed tmpdir/libpr16452a.so" "-fPIC" | |
390 | {dummy.c} {} "libpr16452b.so"} | |
391 | {"Build pr16452" | |
8cfc7cf8 | 392 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 L |
393 | {pr16452b.c} {{objdump {-p} pr16452.od}} "pr16452"} |
394 | {"Build pr16457" | |
8cfc7cf8 | 395 | "-Wl,--no-as-needed,-rpath=tmpdir,-rpath-link=tmpdir tmpdir/libpr16452b.so" "" |
fb389763 | 396 | {pr16452b.c} {{objdump {-p} pr16457.od}} "pr16457"} |
8ded2ddc L |
397 | {"Build libpr18458a.so" |
398 | "-shared -Wl,-z,now" "-fPIC" | |
399 | {pr18458a.c} {} "libpr18458a.so"} | |
400 | {"Build libpr18458b.so" | |
401 | "-shared -Wl,-z,now tmpdir/libpr18458a.so" "-fPIC" | |
402 | {pr18458b.c} {} "libpr18458b.so"} | |
4373f8af L |
403 | {"Build pr19073a.o" |
404 | "-r -nostdlib" "" | |
405 | {pr19073.s} {} "pr19073a.o"} | |
406 | {"Build libpr19073.so" | |
407 | "-shared -Wl,--version-script=pr19073.map tmpdir/pr19073a.o" "-fPIC" | |
408 | {dummy.c} {{readelf {--dyn-syms --wide} pr19073.rd}} "libpr19073.so"} | |
d2dee3b2 L |
409 | } |
410 | ||
dd98f8d2 NC |
411 | run_cc_link_tests $build_tests |
412 | ||
d9816402 AM |
413 | set run_tests [list \ |
414 | [list "Run normal with libfoo.so" \ | |
415 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" \ | |
416 | {main.c} "normal" "normal.out" ] \ | |
417 | [list "Run protected with libfoo.so" \ | |
418 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" \ | |
419 | {main.c} "protected" "normal.out" ] \ | |
420 | [list "Run hidden with libfoo.so" \ | |
421 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" \ | |
422 | {main.c} "hidden" "hidden.out" ] \ | |
423 | [list "Run normal with versioned libfoo.so" \ | |
424 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" \ | |
425 | {main.c} "normalv" "normal.out" ] \ | |
426 | [list "Run warn with versioned libfoo.so" \ | |
427 | "-Wl,--no-as-needed tmpdir/beginwarn.o tmpdir/libfoov.so" "" \ | |
428 | {main.c} "warn" "warn.out" \ | |
3239a423 | 429 | "" "c" {^.*beginwarn.c:7: warning: function foo is deprecated$} ] \ |
d9816402 AM |
430 | [list "Run protected with versioned libfoo.so" \ |
431 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" \ | |
432 | {main.c} "protected" "normal.out" ] \ | |
433 | [list "Run hidden with versioned libfoo.so" \ | |
434 | "-Wl,--no-as-needed tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" \ | |
435 | {main.c} "hiddenv" "hidden.out" ] \ | |
436 | [list "Run normal libbar.so with libfoo.so" \ | |
437 | "-Wl,--no-as-needed tmpdir/libbarfoo.so tmpdir/libfoo.so" "" \ | |
438 | {main.c} "normal" "normal.out" ] \ | |
439 | [list "Run protected libbar.so with libfoo.so" \ | |
440 | "-Wl,--no-as-needed tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" \ | |
441 | {main.c} "protected" "normal.out" ] \ | |
442 | [list "Run hidden libbar.so with libfoo.so" \ | |
443 | "-Wl,--no-as-needed tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" \ | |
444 | {main.c} "hidden" "hidden.out" ] \ | |
445 | [list "Run normal libbar.so with versioned libfoo.so" \ | |
446 | "-Wl,--no-as-needed tmpdir/libbarfoov.so tmpdir/libfoov.so" "" \ | |
447 | {main.c} "normal" "normal.out" ] \ | |
448 | [list "Run protected libbar.so with versioned libfoo.so" \ | |
449 | "-Wl,--no-as-needed tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" \ | |
450 | {main.c} "protected" "normal.out" ] \ | |
451 | [list "Run hidden libbar.so with versioned libfoo.so" \ | |
452 | "-Wl,--no-as-needed tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" \ | |
453 | {main.c} "hidden" "hidden.out" ] \ | |
d9816402 AM |
454 | [list "Run with libdl2a.so" \ |
455 | "-Wl,--no-as-needed tmpdir/libdl2a.so" "" \ | |
456 | {dl2main.c} "dl2a" "dl2a.out" ] \ | |
457 | [list "Run with libdl2b.so" \ | |
458 | "-Wl,--no-as-needed tmpdir/libdl2b.so" "" \ | |
459 | {dl2main.c} "dl2b" "dl2b.out" ] \ | |
460 | [list "Run with libdl2c.so" \ | |
461 | "-Wl,--no-as-needed tmpdir/libdl2c.so" "" \ | |
462 | {dl2main.c} "dl2c" "dl2b.out" ] \ | |
463 | [list "Run with libdl4a.so" \ | |
464 | "-Wl,--no-as-needed tmpdir/libdl4a.so" "" \ | |
465 | {dl4main.c} "dl4a" "dl4a.out" ] \ | |
466 | [list "Run with libdl4b.so" \ | |
467 | "-Wl,--no-as-needed tmpdir/libdl4b.so" "" \ | |
468 | {dl4main.c} "dl4b" "dl4a.out" ] \ | |
469 | [list "Run with libdl4c.so" \ | |
470 | "-Wl,--no-as-needed tmpdir/libdl4c.so" "" \ | |
471 | {dl4main.c} "dl4c" "dl4b.out" ] \ | |
472 | [list "Run with libdl4d.so" \ | |
473 | "-Wl,--no-as-needed tmpdir/libdl4d.so" "" \ | |
474 | {dl4main.c} "dl4d" "dl4b.out" ] \ | |
475 | [list "Run with libdl4e.so" \ | |
476 | "-Wl,--no-as-needed tmpdir/libdl4e.so" "" \ | |
477 | {dl4main.c} "dl4e" "dl4a.out" ] \ | |
478 | [list "Run with libdl4f.so" \ | |
479 | "-Wl,--no-as-needed tmpdir/libdl4f.so" "" \ | |
480 | {dl4main.c} "dl4f" "dl4a.out" ] \ | |
d9816402 AM |
481 | [list "Run with libdata1.so" \ |
482 | "-Wl,--no-as-needed tmpdir/libdata1.so" "" \ | |
483 | {dynbss1.c} "dynbss1" "pass.out" ] \ | |
484 | [list "Run with libdata2.so" \ | |
485 | "-Wl,--no-as-needed tmpdir/libdata2.so" "" \ | |
486 | {weakdef1.c} "weakdef1" "pass.out" ] \ | |
487 | [list "Run with libfunc1.so comm1.o" \ | |
488 | "-Wl,--no-as-needed tmpdir/libfunc1.so tmpdir/comm1.o" "" \ | |
489 | {dummy.c} "comm1" "pass.out" ] \ | |
490 | [list "Run with comm1.o libfunc1.so" \ | |
491 | "-Wl,--no-as-needed tmpdir/comm1.o tmpdir/libfunc1.so" "" \ | |
492 | {dummy.c} "comm1" "pass.out" ] \ | |
493 | [list "Run with pr11138-2.c libpr11138-1.so" \ | |
494 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" \ | |
495 | {dummy.c} "pr11138a" "pr11138.out" ] \ | |
496 | [list "Run with libpr11138-1.so pr11138-2.c" \ | |
497 | "-Wl,--no-as-needed,--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" \ | |
498 | {dummy.c} "pr11138b" "pr11138.out" ] \ | |
499 | [list "Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" \ | |
500 | "-Wl,--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" \ | |
501 | {dummy.c} "pr13250" "pass.out" ] \ | |
502 | [list "Run with pr14323-1.c pr14323-2.so" \ | |
503 | "-Wl,--no-as-needed tmpdir/libpr14323-2.so" "" \ | |
504 | {pr14323-1.c} "pr14323" "pass.out" ] \ | |
505 | [list "Run with pr14862-1.c libpr14862.so" \ | |
506 | "-Wl,--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" \ | |
507 | {dummy.c} "pr14862" "pr14862.out" ] \ | |
508 | [list "Link with --add-needed" \ | |
8cfc7cf8 | 509 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--add-needed,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
510 | {dummy.c} "needed1a" "needed1.out" ] \ |
511 | [list "Link with --copy-dt-needed-entries" \ | |
8cfc7cf8 | 512 | "tmpdir/libneeded1c.o -Wl,--no-as-needed,--copy-dt-needed-entries,-rpath=tmpdir,-rpath-link=tmpdir -Ltmpdir -lneeded1a" "" \ |
d9816402 AM |
513 | {dummy.c} "needed1b" "needed1.out" ] \ |
514 | [list "Run relmain" \ | |
515 | "-Wl,--no-as-needed,-rpath=tmpdir -Ltmpdir -lrel" "" \ | |
516 | {relmain.c} "relmain" "relmain.out" ] \ | |
517 | [list "Run pr2404" \ | |
518 | "-Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" \ | |
519 | {dummy.c} "pr2404" "pr2404.out" ] \ | |
520 | [list "Run pr18458" \ | |
521 | "-Wl,--no-as-needed,-z,now tmpdir/libpr18458a.so tmpdir/libpr18458b.so" "" \ | |
522 | {pr18458c.c} "pr18458" "pass.out" ] \ | |
523 | ] | |
d2dee3b2 | 524 | |
d2dee3b2 | 525 | # NetBSD ELF systems do not currently support the .*_array sections. |
982c6f26 | 526 | run_ld_link_exec_tests $run_tests "*-*-netbsdelf*" |
55255dae | 527 | |
fd121c5c JW |
528 | # These tests require dlopen support. |
529 | set dlopen_run_tests [list \ | |
530 | [list "Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" \ | |
531 | "-Wl,--no-as-needed,--dynamic-list=dl1.list $extralibs" "" \ | |
532 | {dl1main.c} "dl1a" "dl1.out" ] \ | |
533 | [list "Run dl1b with --dynamic-list-data and dlopen on libdl1.so" \ | |
534 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
535 | {dl1main.c} "dl1b" "dl1.out" ] \ | |
536 | [list "Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" \ | |
537 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
538 | {dl6amain.c} "dl6a1" "dl6a.out" ] \ | |
539 | [list "Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" \ | |
540 | "-Wl,--no-as-needed,-Bsymbolic-functions $extralibs" "" \ | |
541 | {dl6amain.c} "dl6a2" "dl6b.out" ] \ | |
542 | [list "Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" \ | |
543 | "-Wl,--no-as-needed,-Bsymbolic $extralibs" "" \ | |
544 | {dl6amain.c} "dl6a3" "dl6b.out" ] \ | |
545 | [list "Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" \ | |
546 | "-Wl,--no-as-needed,-Bsymbolic,--dynamic-list-data $extralibs" "" \ | |
547 | {dl6amain.c} "dl6a4" "dl6a.out" ] \ | |
548 | [list "Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" \ | |
549 | "-Wl,--no-as-needed,-Bsymbolic-functions,--dynamic-list-cpp-new $extralibs" "" \ | |
550 | {dl6amain.c} "dl6a5" "dl6b.out" ] \ | |
551 | [list "Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" \ | |
552 | "-Wl,--no-as-needed,--dynamic-list-cpp-new,-Bsymbolic-functions $extralibs" "" \ | |
553 | {dl6amain.c} "dl6a6" "dl6b.out" ] \ | |
554 | [list "Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" \ | |
555 | "-Wl,--no-as-needed,--dynamic-list-data,-Bsymbolic $extralibs" "" \ | |
556 | {dl6amain.c} "dl6a7" "dl6a.out" ] \ | |
557 | [list "Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" \ | |
558 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
559 | {dl6bmain.c} "dl6b1" "dl6a.out" ] \ | |
560 | [list "Run dl6b2 with dlopen on libdl6b.so" \ | |
561 | "-Wl,--no-as-needed $extralibs" "" \ | |
562 | {dl6bmain.c} "dl6b2" "dl6b.out" ] \ | |
563 | [list "Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" \ | |
564 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
565 | {dl6cmain.c} "dl6c1" "dl6b.out" ] \ | |
566 | [list "Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" \ | |
567 | "-Wl,--no-as-needed,--dynamic-list-data $extralibs" "" \ | |
568 | {dl6dmain.c} "dl6d1" "dl6b.out" ] \ | |
569 | ] | |
570 | ||
571 | # Only run them when libdl is available. | |
572 | if [check_libdl_available] { | |
573 | # XFAIL on NetBSD ELF systems as they do not currently support the .*_array | |
574 | # sections. | |
575 | run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsdelf*" | |
576 | } | |
577 | ||
63406f0a L |
578 | # Check --no-add-needed and --no-copy-dt-needed-entries |
579 | set testname "--no-add-needed" | |
f1d7f4a6 | 580 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 581 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
582 | pass $testname |
583 | } { | |
584 | fail $testname | |
585 | } | |
586 | set testname "--no-copy-dt-needed-entries" | |
f1d7f4a6 | 587 | set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] |
e65cb106 | 588 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
589 | pass $testname |
590 | } { | |
591 | fail $testname | |
592 | } | |
8fbb09e8 | 593 | set testname "--no-add-needed -shared" |
f1d7f4a6 | 594 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 595 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
596 | pass $testname |
597 | } { | |
598 | fail $testname | |
599 | } | |
600 | set testname "--no-copy-dt-needed-entries -shared" | |
f1d7f4a6 | 601 | set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"] |
4e95fbcd | 602 | if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { |
8fbb09e8 L |
603 | pass $testname |
604 | } { | |
605 | fail $testname | |
606 | } | |
63406f0a | 607 | |
dd98f8d2 | 608 | # Check to see if the C++ compiler works |
55255dae L |
609 | if { [which $CXX] == 0 } { |
610 | return | |
611 | } | |
612 | ||
613 | set build_cxx_tests { | |
614 | {"Build libdl3a.so with --dynamic-list=dl3.list" | |
615 | "-shared -Wl,--dynamic-list=dl3.list" "-fPIC" | |
616 | {dl3.cc} {} "libdl3a.so" "c++"} | |
617 | {"Build libdl3b.so with -Bsymbolic" | |
618 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
619 | {dl3.cc} {} "libdl3b.so" "c++"} | |
620 | {"Build libdl3a.so with --dynamic-list-cpp-typeinfo" | |
621 | "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC" | |
622 | {dl3.cc} {} "libdl3c.so" "c++"} | |
d8cf8b51 | 623 | {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" |
199add01 | 624 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC -ansi" |
d8cf8b51 L |
625 | {del.cc new.cc} {} "libnew1a.so" "c++"} |
626 | {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" | |
199add01 | 627 | "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC -ansi" |
d8cf8b51 | 628 | {del.cc new.cc} {} "libnew1b.so" "c++"} |
55255dae L |
629 | } |
630 | ||
b37470e4 L |
631 | # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer. |
632 | # {"Run with libdl3b.so" | |
633 | # "tmpdir/libdl3b.so" "" | |
634 | # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"} | |
cb5ab6c8 L |
635 | set run_cxx_tests { |
636 | {"Run with libdl3a.so" | |
637 | "-Wl,--no-as-needed tmpdir/libdl3a.so" "" | |
638 | {dl3main.cc} "dl3a" "dl3a.out" "" "c++"} | |
55255dae | 639 | {"Run with libdl3c.so" |
5cb49709 | 640 | "-Wl,--no-as-needed tmpdir/libdl3c.so" "" |
55255dae | 641 | {dl3main.cc} "dl3c" "dl3a.out" "" "c++"} |
d8cf8b51 | 642 | {"Run with libnew1a.so" |
d9816402 | 643 | "-Wl,--no-as-needed tmpdir/libnew1a.so" "" |
199add01 | 644 | {dl5.cc} "dl5a" "dl5.out" "-ansi" "c++"} |
d8cf8b51 | 645 | {"Run with libnew1b.so" |
d9816402 | 646 | "-Wl,--no-as-needed tmpdir/libnew1b.so" "" |
199add01 | 647 | {dl5.cc} "dl5b" "dl5.out" "-ansi" "c++"} |
55255dae L |
648 | } |
649 | ||
650 | run_cc_link_tests $build_cxx_tests | |
982c6f26 | 651 | run_ld_link_exec_tests $run_cxx_tests |
22ef172a L |
652 | |
653 | if { [istarget *-*-linux*] | |
654 | || [istarget *-*-nacl*] | |
655 | || [istarget *-*-gnu*] } { | |
656 | run_cc_link_tests [list \ | |
657 | [list \ | |
658 | "Build libpr2404b.a with PIE" \ | |
659 | "" \ | |
660 | "-fPIE" \ | |
661 | { pr2404b.c } \ | |
662 | {} \ | |
663 | "libpr2404b.a" \ | |
664 | ] \ | |
07492f66 L |
665 | [list \ |
666 | "Build pr19579a.o" \ | |
667 | "" "-fPIE" \ | |
668 | {pr19579a.c} \ | |
669 | {} \ | |
670 | "libpr19579a.a" \ | |
671 | ] \ | |
672 | [list \ | |
673 | "Build libpr19579.so" \ | |
674 | "-shared" \ | |
675 | "-fPIC" \ | |
676 | {pr19579b.c} \ | |
677 | {} \ | |
678 | "libpr19579.so" \ | |
679 | ] \ | |
22ef172a | 680 | ] |
982c6f26 | 681 | run_ld_link_exec_tests [list \ |
22ef172a L |
682 | [list \ |
683 | "Run pr2404 with PIE" \ | |
d9816402 | 684 | "-pie -Wl,--no-as-needed tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ |
22ef172a L |
685 | "" \ |
686 | { dummy.c } \ | |
687 | "pr2404pie" \ | |
688 | "pr2404.out" \ | |
689 | "-fPIE" \ | |
690 | ] \ | |
1659f720 L |
691 | [list \ |
692 | "Run pr18718" \ | |
693 | "" \ | |
694 | "" \ | |
c45bd4fd | 695 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
696 | "pr18718" \ |
697 | "pass.out" \ | |
edcab5e8 | 698 | "-O2 -I../bfd" \ |
1659f720 L |
699 | ] \ |
700 | [list \ | |
701 | "Run pr18718 with PIE (1)" \ | |
702 | "-pie" \ | |
703 | "" \ | |
c45bd4fd | 704 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
705 | "pr18718pie1" \ |
706 | "pass.out" \ | |
edcab5e8 | 707 | "-O2 -fPIE -I../bfd" \ |
1659f720 L |
708 | ] \ |
709 | [list \ | |
710 | "Run pr18718 with PIE (2)" \ | |
711 | "" \ | |
712 | "" \ | |
c45bd4fd | 713 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
714 | "pr18718pie2" \ |
715 | "pass.out" \ | |
edcab5e8 | 716 | "-O2 -fPIE -I../bfd" \ |
1659f720 L |
717 | ] \ |
718 | [list \ | |
719 | "Run pr18718 with PIC (1)" \ | |
720 | "" \ | |
721 | "" \ | |
c45bd4fd | 722 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
723 | "pr18718pic1" \ |
724 | "pass.out" \ | |
edcab5e8 | 725 | "-O2 -fPIC -I../bfd" \ |
1659f720 L |
726 | ] \ |
727 | [list \ | |
728 | "Run pr18718 with PIC (2)" \ | |
729 | "-pie" \ | |
730 | "" \ | |
c45bd4fd | 731 | { pr18718.c check-ptr-eq.c } \ |
1659f720 L |
732 | "pr18718pic2" \ |
733 | "pass.out" \ | |
edcab5e8 | 734 | "-O2 -fPIC -I../bfd" \ |
1659f720 | 735 | ] \ |
07492f66 L |
736 | [list \ |
737 | "Run pr19579" \ | |
d9816402 | 738 | "-pie -Wl,--no-as-needed,-z,text tmpdir/pr19579a.o tmpdir/libpr19579.so" \ |
07492f66 L |
739 | "" \ |
740 | {dummy.c} \ | |
741 | "pr19579" \ | |
742 | "pass.out" \ | |
743 | "-fPIE" \ | |
744 | ] \ | |
22ef172a L |
745 | ] |
746 | } | |
aec6b87e | 747 | |
f1b2ca70 | 748 | proc mix_pic_and_non_pic {xfails cflags ldflags exe} { |
aec6b87e L |
749 | run_cc_link_tests [list \ |
750 | [list \ | |
751 | "Build libpr19719a.so" \ | |
752 | "-shared -Wl,-soname,libpr19719.so" \ | |
753 | "-fPIC" \ | |
754 | { pr19719d.c } \ | |
755 | {} \ | |
756 | "libpr19719a.so" \ | |
757 | ] \ | |
758 | [list \ | |
759 | "Build libpr19719b.so" \ | |
760 | "-shared -Wl,-soname,libpr19719.so" \ | |
761 | "-fPIC" \ | |
762 | { dummy.c } \ | |
763 | {} \ | |
764 | "libpr19719b.so" \ | |
765 | ] \ | |
766 | [list \ | |
f1b2ca70 | 767 | "Build libpr19719b.o" \ |
aec6b87e L |
768 | "-r -nostdlib" \ |
769 | "-fPIC" \ | |
770 | { pr19719b.c } \ | |
771 | {} \ | |
772 | "libpr19719b.o" \ | |
773 | ] \ | |
774 | ] | |
775 | ||
f1b2ca70 | 776 | send_log "cp tmpdir/libpr19719b.so tmpdir/libpr19719.so\n" |
aec6b87e L |
777 | exec cp tmpdir/libpr19719b.so tmpdir/libpr19719.so |
778 | ||
982c6f26 | 779 | run_ld_link_exec_tests [list \ |
aec6b87e | 780 | [list \ |
f1b2ca70 | 781 | "Run $exe fun defined" \ |
d9816402 | 782 | "-Wl,--no-as-needed,-rpath,tmpdir $ldflags tmpdir/libpr19719b.o tmpdir/libpr19719.so" \ |
aec6b87e L |
783 | "" \ |
784 | { pr19719a.c pr19719c.c } \ | |
f1b2ca70 | 785 | $exe \ |
aec6b87e L |
786 | "pass.out" \ |
787 | "$cflags" \ | |
788 | ] \ | |
789 | ] | |
790 | ||
f1b2ca70 | 791 | send_log "cp tmpdir/libpr19719a.so tmpdir/libpr19719.so\n" |
aec6b87e L |
792 | exec cp tmpdir/libpr19719a.so tmpdir/libpr19719.so |
793 | ||
7494161b L |
794 | foreach targ $xfails { |
795 | setup_xfail $targ | |
796 | } | |
797 | ||
d9816402 AM |
798 | if ![isnative] { |
799 | unsupported "Run $exe fun undefined" | |
800 | return | |
801 | } | |
802 | ||
f1b2ca70 | 803 | set exec_output [run_host_cmd "tmpdir/$exe" ""] |
aec6b87e | 804 | if {![string match "PASS" $exec_output]} { |
f1b2ca70 | 805 | fail "Run $exe fun undefined" |
aec6b87e | 806 | } else { |
f1b2ca70 | 807 | pass "Run $exe fun undefined" |
aec6b87e L |
808 | } |
809 | } | |
810 | ||
f1b2ca70 AM |
811 | mix_pic_and_non_pic [list "arm*-*-*" "aarch64*-*-*"] "" "" "pr19719" |
812 | mix_pic_and_non_pic [] "-fPIE" "-pie" "pr19719pie" |