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