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