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