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