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