]>
Commit | Line | Data |
---|---|---|
d2dee3b2 | 1 | # Expect script for various ELF tests. |
4b95cf5c | 2 | # Copyright (C) 2006-2014 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 | ||
45394486 NC |
24 | # The following tests require running the executable generated by ld, |
25 | # or enough of a build environment to create a fully linked executable. | |
26 | # This is not commonly available when testing a cross-built linker. | |
27 | if ![isnative] { | |
28 | return | |
29 | } | |
30 | ||
d2dee3b2 L |
31 | if ![is_elf_format] { |
32 | return | |
33 | } | |
34 | ||
dd98f8d2 | 35 | # Check to see if the C compiler works |
d2dee3b2 L |
36 | if { [which $CC] == 0 } { |
37 | return | |
38 | } | |
39 | ||
fb2c6e43 AT |
40 | # Add -ldl to extralibs if needed |
41 | if { ![istarget *-*-freebsd*]} { | |
42 | set extralibs "-ldl" | |
43 | } | |
44 | ||
d2dee3b2 L |
45 | set build_tests { |
46 | {"Build libfoo.so" | |
47 | "-shared" "-fPIC" | |
48 | {foo.c} {} "libfoo.so"} | |
49 | {"Build versioned libfoo.so" | |
50 | "-shared -Wl,--version-script=foo.map" "-fPIC" | |
55255dae | 51 | {foo.c} {} "libfoov.so"} |
d2dee3b2 L |
52 | {"Build libbar.so" |
53 | "-shared" "-fPIC" | |
54 | {begin.c end.c} {} "libbar.so"} | |
fab4a87f L |
55 | {"Build warn libbar.so" |
56 | "-shared" "-fPIC" | |
df71cb5c | 57 | {beginwarn.c end.c} {{readelf {-S --wide} libbarw.rd}} "libbarw.so" |
dd98f8d2 | 58 | "C" "^.*\\\): warning: function foo is deprecated$"} |
d2dee3b2 L |
59 | {"Build hidden libbar.so" |
60 | "-shared" "-fPIC" | |
61 | {begin.c endhidden.c} {} "libbarh.so"} | |
62 | {"Build protected libbar.so" | |
63 | "-shared" "-fPIC" | |
64 | {begin.c endprotected.c} {} "libbarp.so"} | |
65 | {"Build libbar.so with libfoo.so" | |
66 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
67 | {end.c} {} "libbarfoo.so"} | |
68 | {"Build libar.so with versioned libfoo.so" | |
69 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
70 | {end.c} {} "libbarfoov.so"} | |
71 | {"Build hidden libbar.so with libfoo.so" | |
72 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
73 | {endhidden.c} {} "libbarhfoo.so"} | |
74 | {"Build hidden libar.so with versioned libfoo.so" | |
75 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
76 | {endhidden.c} {} "libbarhfoov.so"} | |
77 | {"Build protected libbar.so with libfoo.so" | |
78 | "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC" | |
79 | {endprotected.c} {} "libbarpfoo.so"} | |
80 | {"Build protected libbar.so with versioned libfoo.so" | |
81 | "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC" | |
82 | {endprotected.c} {} "libbarpfoov.so"} | |
55255dae L |
83 | {"Build libdl1.so" |
84 | "-shared" "-fPIC" | |
85 | {dl1.c} {} "libdl1.so"} | |
86 | {"Build libdl2a.so with --dynamic-list=dl2.list" | |
87 | "-shared -Wl,--dynamic-list=dl2.list" "-fPIC" | |
88 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
b7b7fe3f AS |
89 | {"Build libdl2a.so with --dynamic-list=dl2a.list" |
90 | "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC" | |
91 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
40b36307 L |
92 | {"Build libdl2a.so with --dynamic-list-data" |
93 | "-shared -Wl,--dynamic-list-data" "-fPIC" | |
94 | {dl2.c dl2xxx.c} {} "libdl2a.so"} | |
55255dae L |
95 | {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list" |
96 | "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC" | |
97 | {dl2.c dl2xxx.c} {} "libdl2b.so"} | |
d8cf8b51 | 98 | {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list" |
40b36307 | 99 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC" |
d8cf8b51 | 100 | {dl2.c dl2xxx.c} {} "libdl2c.so"} |
c555238b L |
101 | {"Build libdl4a.so with --dynamic-list=dl4.list" |
102 | "-shared -Wl,--dynamic-list=dl4.list" "-fPIC" | |
103 | {dl4.c dl4xxx.c} {} "libdl4a.so"} | |
d8cf8b51 | 104 | {"Build libdl4b.so with --dynamic-list-data" |
40b36307 | 105 | "-shared -Wl,--dynamic-list-data" "-fPIC" |
c555238b | 106 | {dl4.c dl4xxx.c} {} "libdl4b.so"} |
d8cf8b51 L |
107 | {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list" |
108 | "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC" | |
109 | {dl4.c dl4xxx.c} {} "libdl4c.so"} | |
110 | {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list" | |
40b36307 | 111 | "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC" |
d8cf8b51 L |
112 | {dl4.c dl4xxx.c} {} "libdl4d.so"} |
113 | {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new" | |
114 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" | |
115 | {dl4.c dl4xxx.c} {} "libdl4e.so"} | |
116 | {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions" | |
117 | "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC" | |
118 | {dl4.c dl4xxx.c} {} "libdl4f.so"} | |
119 | {"Build libdl6a.so" | |
120 | "-shared" "-fPIC" | |
121 | {dl6.c} {} "libdl6a.so"} | |
122 | {"Build libdl6b.so with -Bsymbolic --dynamic-list-data" | |
123 | "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC" | |
124 | {dl6.c} {} "libdl6b.so"} | |
125 | {"Build libdl6c.so with -Bsymbolic" | |
126 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
127 | {dl6.c} {} "libdl6c.so"} | |
128 | {"Build libdl6d.so with --dynamic-list-data -Bsymbolic" | |
129 | "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC" | |
130 | {dl6.c} {} "libdl6d.so"} | |
43edfb7f L |
131 | {"Build libdata1.so" |
132 | "-shared" "-fPIC" | |
133 | {data1.c} {} "libdata1.so"} | |
a47edf27 L |
134 | {"Build libdata2.so" |
135 | "-shared" "-fPIC" | |
136 | {data2.c} {} "libdata2.so"} | |
0a36a439 L |
137 | {"Build libcomm1.o" |
138 | "-r -nostdlib" "" | |
139 | {comm1.c} {} "libcomm1.o"} | |
140 | {"Build libfunc1.so" | |
141 | "-shared" "-fPIC" | |
142 | {func1.c} {} "libfunc1.so"} | |
d8880531 L |
143 | {"Build libpr9676-1.a" |
144 | "" "-fPIC" | |
145 | {pr9676-1.c} {} "libpr9676-1.a"} | |
146 | {"Build libpr9676-2.a" | |
147 | "" "-fPIC" | |
148 | {pr9676-2.c} {} "libpr9676-2.a"} | |
149 | {"Build libpr9676-3.so" | |
150 | "-shared" "-fPIC" | |
151 | {pr9676-3.c} {} "libpr9676-3.so"} | |
152 | {"Build libpr9676-4.so" | |
153 | "-shared" "-fPIC" | |
154 | {pr9676-4.c} {} "libpr9676-4.so"} | |
155 | {"Build libpr9676-4a.so" | |
156 | "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group" | |
157 | "-fPIC" | |
158 | {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"} | |
54ac0771 L |
159 | {"Build libpr9679.so" |
160 | "-shared" "-fPIC -O0" | |
161 | {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"} | |
d023c380 L |
162 | {"Build libpr11138-1.so" |
163 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
164 | {pr11138-1.c} {} "libpr11138-1.so"} | |
165 | {"Build libpr11138-2.o" | |
166 | "-r -nostdlib" "" | |
167 | {pr11138-2.c} {} "libpr11138-2.o"} | |
3e0882af L |
168 | {"Build pr13250-1.so" |
169 | "-shared" "-fPIC" | |
170 | {pr13250-1.c} {} "libpr13250-1.so"} | |
171 | {"Build pr13250-2.so with libpr13250-1.so" | |
5cb49709 | 172 | "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC" |
3e0882af L |
173 | {pr13250-2.c} {} "libpr13250-2.so"} |
174 | {"Build libpr13250-3.o" | |
175 | "-r -nostdlib" "" | |
176 | {pr13250-3.c} {} "libpr13250-3.o"} | |
bc9ad2e4 L |
177 | {"Build libpr14323-2.so" |
178 | "-shared" "-fPIC" | |
179 | {pr14323-2.c} {} "libpr14323-2.so"} | |
dda8ddc5 L |
180 | {"Build pr14862-1.o" |
181 | "-r -nostdlib" "" | |
182 | {pr14862-1.c} {} "libpr14862-1.o"} | |
183 | {"Build libpr14862.so" | |
184 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
185 | {pr14862-2.c} {} "libpr14862.so"} | |
63406f0a L |
186 | {"Build libneeded1b.so" |
187 | "-shared" "-fPIC" | |
188 | {needed1b.c} {} "libneeded1b.so"} | |
189 | {"Build libneeded1a.so" | |
2eb64a9f | 190 | "-shared -Wl,--add-needed,--no-as-needed -Ltmpdir -lneeded1b" "-fPIC" |
63406f0a L |
191 | {needed1a.c} {} "libneeded1a.so"} |
192 | {"Build libneeded1c.o" | |
193 | "-r -nostdlib" "" | |
194 | {needed1c.c} {} "libneeded1c.o"} | |
8fbb09e8 L |
195 | {"Build libneeded1pic.o" |
196 | "-r -nostdlib" "-fPIC" | |
197 | {needed1c.c} {} "libneeded1pic.o"} | |
198 | {"Build needed1a.so with --add-needed" | |
199 | "-shared tmpdir/libneeded1pic.o -Wl,--add-needed,-rpath=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" | |
200 | {dummy.c} {} "needed1a.so"} | |
201 | {"Build needed1b.so with --copy-dt-needed-entries" | |
202 | "-shared tmpdir/libneeded1pic.o -Wl,--copy-dt-needed-entries,-rpath=tmpdir,-z,defs -Ltmpdir -lneeded1a" "" | |
203 | {dummy.c} {} "needed1b.so"} | |
204 | {"Build needed1a.so with --no-add-needed" | |
205 | "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed -Ltmpdir -lneeded1a" "" | |
206 | {dummy.c} {} "needed1c.so"} | |
207 | {"Build needed1b.so with --no-copy-dt-needed-entries" | |
208 | "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries -Ltmpdir -lneeded1a" "" | |
209 | {dummy.c} {} "needed1d.so"} | |
8877b5e5 AM |
210 | {"Build librel.so" |
211 | "-shared" "-fPIC" | |
212 | {rel.c} {} "librel.so"} | |
5e319dd3 L |
213 | {"Build libneeded2a.so" |
214 | "-shared" "-fPIC" | |
215 | {needed2a.c} {} "libneeded2a.so"} | |
216 | {"Build libneeded2b.so" | |
217 | "-shared -Wl,--version-script,needed2.ver" "-fPIC" | |
218 | {needed2b.c} {} "libneeded2b.so"} | |
219 | {"Build libneeded2c.o" | |
220 | "-r -nostdlib" "" | |
221 | {needed2c.c} {} "libneeded2c.o"} | |
222 | {"Build needed2" | |
223 | "tmpdir/libneeded2c.o -Wl,--as-needed tmpdir/libneeded2a.so tmpdir/libneeded2b.so" "" | |
224 | {dummy.c} {} "needed2"} | |
cec2c50d L |
225 | {"Build libpr2404a.so" |
226 | "-shared" "-fPIC" | |
227 | {pr2404a.c} {} "libpr2404a.so"} | |
228 | {"Build libpr2404b.a" | |
229 | "" "" | |
230 | {pr2404b.c} {} "libpr2404b.a"} | |
50a53d3f L |
231 | {"Build rdynamic-1" |
232 | "-rdynamic -Wl,--gc-sections" "-ffunction-sections" | |
233 | {rdynamic-1.c} {{readelf {-s} rdynamic-1.rd}} "rdynamic-1"} | |
d6f6f455 L |
234 | {"Build dynamic-1" |
235 | "-Wl,--dynamic-list,dynamic-1.syms -Wl,--gc-sections" "-ffunction-sections" | |
236 | {dynamic-1.c} {{readelf {-s} dynamic-1.rd}} "dynamic-1"} | |
d2dee3b2 L |
237 | } |
238 | ||
dd98f8d2 NC |
239 | run_cc_link_tests $build_tests |
240 | ||
d2dee3b2 L |
241 | set run_tests { |
242 | {"Run normal with libfoo.so" | |
243 | "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" | |
244 | {main.c} "normal" "normal.out"} | |
245 | {"Run protected with libfoo.so" | |
246 | "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" | |
247 | {main.c} "protected" "normal.out"} | |
248 | {"Run hidden with libfoo.so" | |
249 | "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" | |
250 | {main.c} "hidden" "hidden.out"} | |
251 | {"Run normal with versioned libfoo.so" | |
252 | "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" | |
253 | {main.c} "normalv" "normal.out"} | |
fab4a87f L |
254 | {"Run warn with versioned libfoo.so" |
255 | "tmpdir/beginwarn.o tmpdir/libfoov.so" "" | |
256 | {main.c} "warn" "warn.out" | |
257 | "" "" "^.*\\\): warning: function foo is deprecated$"} | |
d2dee3b2 L |
258 | {"Run protected with versioned libfoo.so" |
259 | "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" | |
260 | {main.c} "protected" "normal.out"} | |
261 | {"Run hidden with versioned libfoo.so" | |
262 | "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" | |
263 | {main.c} "hiddenv" "hidden.out"} | |
264 | {"Run normal libbar.so with libfoo.so" | |
265 | "tmpdir/libbarfoo.so tmpdir/libfoo.so" "" | |
266 | {main.c} "normal" "normal.out"} | |
267 | {"Run protected libbar.so with libfoo.so" | |
268 | "tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" | |
269 | {main.c} "protected" "normal.out"} | |
270 | {"Run hidden libbar.so with libfoo.so" | |
271 | "tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" | |
272 | {main.c} "hidden" "hidden.out"} | |
273 | {"Run normal libbar.so with versioned libfoo.so" | |
274 | "tmpdir/libbarfoov.so tmpdir/libfoov.so" "" | |
275 | {main.c} "normal" "normal.out"} | |
276 | {"Run protected libbar.so with versioned libfoo.so" | |
277 | "tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" | |
278 | {main.c} "protected" "normal.out"} | |
279 | {"Run hidden libbar.so with versioned libfoo.so" | |
280 | "tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" | |
281 | {main.c} "hidden" "hidden.out"} | |
d8cf8b51 | 282 | {"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" |
fb2c6e43 | 283 | "--dynamic-list=dl1.list $extralibs" "" |
d8cf8b51 L |
284 | {dl1main.c} "dl1a" "dl1.out"} |
285 | {"Run dl1b with --dynamic-list-data and dlopen on libdl1.so" | |
fb2c6e43 | 286 | "--dynamic-list-data $extralibs" "" |
d8cf8b51 | 287 | {dl1main.c} "dl1b" "dl1.out"} |
55255dae L |
288 | {"Run with libdl2a.so" |
289 | "tmpdir/libdl2a.so" "" | |
290 | {dl2main.c} "dl2a" "dl2a.out"} | |
291 | {"Run with libdl2b.so" | |
292 | "tmpdir/libdl2b.so" "" | |
293 | {dl2main.c} "dl2b" "dl2b.out"} | |
d8cf8b51 L |
294 | {"Run with libdl2c.so" |
295 | "tmpdir/libdl2c.so" "" | |
296 | {dl2main.c} "dl2c" "dl2b.out"} | |
c555238b L |
297 | {"Run with libdl4a.so" |
298 | "tmpdir/libdl4a.so" "" | |
299 | {dl4main.c} "dl4a" "dl4a.out"} | |
300 | {"Run with libdl4b.so" | |
301 | "tmpdir/libdl4b.so" "" | |
d8cf8b51 L |
302 | {dl4main.c} "dl4b" "dl4a.out"} |
303 | {"Run with libdl4c.so" | |
304 | "tmpdir/libdl4c.so" "" | |
305 | {dl4main.c} "dl4c" "dl4b.out"} | |
306 | {"Run with libdl4d.so" | |
307 | "tmpdir/libdl4d.so" "" | |
308 | {dl4main.c} "dl4d" "dl4b.out"} | |
309 | {"Run with libdl4e.so" | |
310 | "tmpdir/libdl4e.so" "" | |
311 | {dl4main.c} "dl4e" "dl4a.out"} | |
312 | {"Run with libdl4f.so" | |
313 | "tmpdir/libdl4f.so" "" | |
314 | {dl4main.c} "dl4f" "dl4a.out"} | |
315 | {"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" | |
fb2c6e43 | 316 | "--dynamic-list-data $extralibs" "" |
d8cf8b51 L |
317 | {dl6amain.c} "dl6a1" "dl6a.out"} |
318 | {"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" | |
fb2c6e43 | 319 | "-Bsymbolic-functions $extralibs" "" |
d8cf8b51 L |
320 | {dl6amain.c} "dl6a2" "dl6b.out"} |
321 | {"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" | |
fb2c6e43 | 322 | "-Bsymbolic $extralibs" "" |
d8cf8b51 L |
323 | {dl6amain.c} "dl6a3" "dl6b.out"} |
324 | {"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" | |
fb2c6e43 | 325 | "-Bsymbolic --dynamic-list-data $extralibs" "" |
d8cf8b51 L |
326 | {dl6amain.c} "dl6a4" "dl6a.out"} |
327 | {"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" | |
fb2c6e43 | 328 | "-Bsymbolic-functions --dynamic-list-cpp-new $extralibs" "" |
d8cf8b51 L |
329 | {dl6amain.c} "dl6a5" "dl6b.out"} |
330 | {"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" | |
fb2c6e43 | 331 | "--dynamic-list-cpp-new -Bsymbolic-functions $extralibs" "" |
d8cf8b51 L |
332 | {dl6amain.c} "dl6a6" "dl6b.out"} |
333 | {"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" | |
fb2c6e43 | 334 | "--dynamic-list-data -Bsymbolic $extralibs" "" |
d8cf8b51 L |
335 | {dl6amain.c} "dl6a7" "dl6a.out"} |
336 | {"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" | |
fb2c6e43 | 337 | "--dynamic-list-data $extralibs" "" |
d8cf8b51 L |
338 | {dl6bmain.c} "dl6b1" "dl6a.out"} |
339 | {"Run dl6b2 with dlopen on libdl6b.so" | |
fb2c6e43 | 340 | "$extralibs" "" |
d8cf8b51 L |
341 | {dl6bmain.c} "dl6b2" "dl6b.out"} |
342 | {"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" | |
fb2c6e43 | 343 | "--dynamic-list-data $extralibs" "" |
d8cf8b51 L |
344 | {dl6cmain.c} "dl6c1" "dl6b.out"} |
345 | {"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" | |
fb2c6e43 | 346 | "--dynamic-list-data $extralibs" "" |
d8cf8b51 | 347 | {dl6dmain.c} "dl6d1" "dl6b.out"} |
43edfb7f L |
348 | {"Run with libdata1.so" |
349 | "tmpdir/libdata1.so" "" | |
350 | {dynbss1.c} "dynbss1" "pass.out"} | |
a47edf27 L |
351 | {"Run with libdata2.so" |
352 | "tmpdir/libdata2.so" "" | |
353 | {weakdef1.c} "weakdef1" "pass.out"} | |
0a36a439 L |
354 | {"Run with libfunc1.so comm1.o" |
355 | "tmpdir/libfunc1.so tmpdir/comm1.o" "" | |
356 | {dummy.c} "comm1" "pass.out"} | |
357 | {"Run with comm1.o libfunc1.so" | |
358 | "tmpdir/comm1.o tmpdir/libfunc1.so" "" | |
359 | {dummy.c} "comm1" "pass.out"} | |
d023c380 L |
360 | {"Run with pr11138-2.c libpr11138-1.so" |
361 | "--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" | |
362 | {dummy.c} "pr11138a" "pr11138.out"} | |
363 | {"Run with libpr11138-1.so pr11138-2.c" | |
364 | "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" | |
365 | {dummy.c} "pr11138b" "pr11138.out"} | |
3e0882af L |
366 | {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so" |
367 | "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" "" | |
368 | {dummy.c} "pr13250" "pass.out"} | |
bc9ad2e4 L |
369 | {"Run with pr14323-1.c pr14323-2.so" |
370 | "tmpdir/libpr14323-2.so" "" | |
371 | {pr14323-1.c} "pr14323" "pass.out"} | |
dda8ddc5 L |
372 | {"Run with pr14862-1.c libpr14862.so" |
373 | "--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" "" | |
374 | {dummy.c} "pr14862" "pr14862.out"} | |
63406f0a L |
375 | {"Link with --add-needed" |
376 | "tmpdir/libneeded1c.o --add-needed -rpath=tmpdir -Ltmpdir -lneeded1a" "" | |
377 | {dummy.c} "needed1a" "needed1.out"} | |
378 | {"Link with --copy-dt-needed-entries" | |
379 | "tmpdir/libneeded1c.o --copy-dt-needed-entries -rpath=tmpdir -Ltmpdir -lneeded1a" "" | |
380 | {dummy.c} "needed1b" "needed1.out"} | |
8877b5e5 AM |
381 | {"Run relmain" |
382 | "--no-as-needed -rpath=tmpdir -Ltmpdir -lrel" "" | |
383 | {relmain.c} "relmain" "relmain.out"} | |
cec2c50d L |
384 | {"Run pr2404" |
385 | "tmpdir/pr2404b.o tmpdir/libpr2404a.so" "" | |
386 | {dummy.c} "pr2404" "pr2404.out"} | |
d2dee3b2 L |
387 | } |
388 | ||
d2dee3b2 L |
389 | # NetBSD ELF systems do not currently support the .*_array sections. |
390 | run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests | |
55255dae | 391 | |
63406f0a L |
392 | # Check --no-add-needed and --no-copy-dt-needed-entries |
393 | set testname "--no-add-needed" | |
394 | set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] | |
e65cb106 | 395 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
396 | pass $testname |
397 | } { | |
398 | fail $testname | |
399 | } | |
400 | set testname "--no-copy-dt-needed-entries" | |
401 | set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] | |
e65cb106 | 402 | if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { |
63406f0a L |
403 | pass $testname |
404 | } { | |
405 | fail $testname | |
406 | } | |
8fbb09e8 L |
407 | set testname "--no-add-needed -shared" |
408 | set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag -shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"] | |
409 | if { [ regexp "undefined reference to `bar'" $exec_output ] } { | |
410 | pass $testname | |
411 | } { | |
412 | fail $testname | |
413 | } | |
414 | set testname "--no-copy-dt-needed-entries -shared" | |
415 | set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag -shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"] | |
416 | if { [ regexp "undefined reference to `bar'" $exec_output ] } { | |
417 | pass $testname | |
418 | } { | |
419 | fail $testname | |
420 | } | |
63406f0a | 421 | |
dd98f8d2 | 422 | # Check to see if the C++ compiler works |
55255dae L |
423 | if { [which $CXX] == 0 } { |
424 | return | |
425 | } | |
426 | ||
427 | set build_cxx_tests { | |
428 | {"Build libdl3a.so with --dynamic-list=dl3.list" | |
429 | "-shared -Wl,--dynamic-list=dl3.list" "-fPIC" | |
430 | {dl3.cc} {} "libdl3a.so" "c++"} | |
431 | {"Build libdl3b.so with -Bsymbolic" | |
432 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
433 | {dl3.cc} {} "libdl3b.so" "c++"} | |
434 | {"Build libdl3a.so with --dynamic-list-cpp-typeinfo" | |
435 | "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC" | |
436 | {dl3.cc} {} "libdl3c.so" "c++"} | |
d8cf8b51 | 437 | {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" |
40b36307 | 438 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" |
d8cf8b51 L |
439 | {del.cc new.cc} {} "libnew1a.so" "c++"} |
440 | {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" | |
441 | "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC" | |
442 | {del.cc new.cc} {} "libnew1b.so" "c++"} | |
55255dae L |
443 | } |
444 | ||
b37470e4 L |
445 | # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer. |
446 | # {"Run with libdl3b.so" | |
447 | # "tmpdir/libdl3b.so" "" | |
448 | # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"} | |
cb5ab6c8 L |
449 | set run_cxx_tests { |
450 | {"Run with libdl3a.so" | |
451 | "-Wl,--no-as-needed tmpdir/libdl3a.so" "" | |
452 | {dl3main.cc} "dl3a" "dl3a.out" "" "c++"} | |
55255dae | 453 | {"Run with libdl3c.so" |
5cb49709 | 454 | "-Wl,--no-as-needed tmpdir/libdl3c.so" "" |
55255dae | 455 | {dl3main.cc} "dl3c" "dl3a.out" "" "c++"} |
d8cf8b51 L |
456 | {"Run with libnew1a.so" |
457 | "tmpdir/libnew1a.so" "" | |
458 | {dl5.cc} "dl5a" "dl5.out" "" "c++"} | |
459 | {"Run with libnew1b.so" | |
460 | "tmpdir/libnew1b.so" "" | |
461 | {dl5.cc} "dl5b" "dl5.out" "" "c++"} | |
55255dae L |
462 | } |
463 | ||
464 | run_cc_link_tests $build_cxx_tests | |
465 | run_ld_link_exec_tests [] $run_cxx_tests | |
22ef172a L |
466 | |
467 | if { [istarget *-*-linux*] | |
468 | || [istarget *-*-nacl*] | |
469 | || [istarget *-*-gnu*] } { | |
470 | run_cc_link_tests [list \ | |
471 | [list \ | |
472 | "Build libpr2404b.a with PIE" \ | |
473 | "" \ | |
474 | "-fPIE" \ | |
475 | { pr2404b.c } \ | |
476 | {} \ | |
477 | "libpr2404b.a" \ | |
478 | ] \ | |
479 | ] | |
480 | run_ld_link_exec_tests [] [list \ | |
481 | [list \ | |
482 | "Run pr2404 with PIE" \ | |
483 | "-pie tmpdir/pr2404b.o tmpdir/libpr2404a.so" \ | |
484 | "" \ | |
485 | { dummy.c } \ | |
486 | "pr2404pie" \ | |
487 | "pr2404.out" \ | |
488 | "-fPIE" \ | |
489 | ] \ | |
490 | ] | |
491 | } |