Commit | Line | Data |
---|---|---|
d2dee3b2 | 1 | # Expect script for various ELF tests. |
aa820537 | 2 | # Copyright 2006, 2007, 2008, 2009 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" | |
dd98f8d2 NC |
52 | {beginwarn.c end.c} {} "libbarw.so" |
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"} | |
0a36a439 L |
129 | {"Build libcomm1.o" |
130 | "-r -nostdlib" "" | |
131 | {comm1.c} {} "libcomm1.o"} | |
132 | {"Build libfunc1.so" | |
133 | "-shared" "-fPIC" | |
134 | {func1.c} {} "libfunc1.so"} | |
d8880531 L |
135 | {"Build libpr9676-1.a" |
136 | "" "-fPIC" | |
137 | {pr9676-1.c} {} "libpr9676-1.a"} | |
138 | {"Build libpr9676-2.a" | |
139 | "" "-fPIC" | |
140 | {pr9676-2.c} {} "libpr9676-2.a"} | |
141 | {"Build libpr9676-3.so" | |
142 | "-shared" "-fPIC" | |
143 | {pr9676-3.c} {} "libpr9676-3.so"} | |
144 | {"Build libpr9676-4.so" | |
145 | "-shared" "-fPIC" | |
146 | {pr9676-4.c} {} "libpr9676-4.so"} | |
147 | {"Build libpr9676-4a.so" | |
148 | "-shared tmpdir/pr9676-4.o -Ltmpdir -lpr9676-3 -Wl,--start-group -lpr9676-1 -lpr9676-2 -Wl,--end-group" | |
149 | "-fPIC" | |
150 | {dummy.c} {{readelf {-s} pr9676.rd}} "libpr9676-4a.so"} | |
54ac0771 L |
151 | {"Build libpr9679.so" |
152 | "-shared" "-fPIC -O0" | |
153 | {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"} | |
d023c380 L |
154 | {"Build libpr11138-1.so" |
155 | "-shared -Wl,--version-script=pr11138-1.map" "-fPIC" | |
156 | {pr11138-1.c} {} "libpr11138-1.so"} | |
157 | {"Build libpr11138-2.o" | |
158 | "-r -nostdlib" "" | |
159 | {pr11138-2.c} {} "libpr11138-2.o"} | |
d2dee3b2 L |
160 | } |
161 | ||
dd98f8d2 NC |
162 | run_cc_link_tests $build_tests |
163 | ||
d2dee3b2 L |
164 | set run_tests { |
165 | {"Run normal with libfoo.so" | |
166 | "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" "" | |
167 | {main.c} "normal" "normal.out"} | |
168 | {"Run protected with libfoo.so" | |
169 | "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" "" | |
170 | {main.c} "protected" "normal.out"} | |
171 | {"Run hidden with libfoo.so" | |
172 | "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" "" | |
173 | {main.c} "hidden" "hidden.out"} | |
174 | {"Run normal with versioned libfoo.so" | |
175 | "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" "" | |
176 | {main.c} "normalv" "normal.out"} | |
fab4a87f L |
177 | {"Run warn with versioned libfoo.so" |
178 | "tmpdir/beginwarn.o tmpdir/libfoov.so" "" | |
179 | {main.c} "warn" "warn.out" | |
180 | "" "" "^.*\\\): warning: function foo is deprecated$"} | |
d2dee3b2 L |
181 | {"Run protected with versioned libfoo.so" |
182 | "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" "" | |
183 | {main.c} "protected" "normal.out"} | |
184 | {"Run hidden with versioned libfoo.so" | |
185 | "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" "" | |
186 | {main.c} "hiddenv" "hidden.out"} | |
187 | {"Run normal libbar.so with libfoo.so" | |
188 | "tmpdir/libbarfoo.so tmpdir/libfoo.so" "" | |
189 | {main.c} "normal" "normal.out"} | |
190 | {"Run protected libbar.so with libfoo.so" | |
191 | "tmpdir/libbarpfoo.so tmpdir/libfoo.so" "" | |
192 | {main.c} "protected" "normal.out"} | |
193 | {"Run hidden libbar.so with libfoo.so" | |
194 | "tmpdir/libbarhfoo.so tmpdir/libfoo.so" "" | |
195 | {main.c} "hidden" "hidden.out"} | |
196 | {"Run normal libbar.so with versioned libfoo.so" | |
197 | "tmpdir/libbarfoov.so tmpdir/libfoov.so" "" | |
198 | {main.c} "normal" "normal.out"} | |
199 | {"Run protected libbar.so with versioned libfoo.so" | |
200 | "tmpdir/libbarpfoov.so tmpdir/libfoov.so" "" | |
201 | {main.c} "protected" "normal.out"} | |
202 | {"Run hidden libbar.so with versioned libfoo.so" | |
203 | "tmpdir/libbarhfoov.so tmpdir/libfoov.so" "" | |
204 | {main.c} "hidden" "hidden.out"} | |
d8cf8b51 | 205 | {"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so" |
55255dae | 206 | "--dynamic-list=dl1.list -ldl" "" |
d8cf8b51 L |
207 | {dl1main.c} "dl1a" "dl1.out"} |
208 | {"Run dl1b with --dynamic-list-data and dlopen on libdl1.so" | |
40b36307 | 209 | "--dynamic-list-data -ldl" "" |
d8cf8b51 | 210 | {dl1main.c} "dl1b" "dl1.out"} |
55255dae L |
211 | {"Run with libdl2a.so" |
212 | "tmpdir/libdl2a.so" "" | |
213 | {dl2main.c} "dl2a" "dl2a.out"} | |
214 | {"Run with libdl2b.so" | |
215 | "tmpdir/libdl2b.so" "" | |
216 | {dl2main.c} "dl2b" "dl2b.out"} | |
d8cf8b51 L |
217 | {"Run with libdl2c.so" |
218 | "tmpdir/libdl2c.so" "" | |
219 | {dl2main.c} "dl2c" "dl2b.out"} | |
c555238b L |
220 | {"Run with libdl4a.so" |
221 | "tmpdir/libdl4a.so" "" | |
222 | {dl4main.c} "dl4a" "dl4a.out"} | |
223 | {"Run with libdl4b.so" | |
224 | "tmpdir/libdl4b.so" "" | |
d8cf8b51 L |
225 | {dl4main.c} "dl4b" "dl4a.out"} |
226 | {"Run with libdl4c.so" | |
227 | "tmpdir/libdl4c.so" "" | |
228 | {dl4main.c} "dl4c" "dl4b.out"} | |
229 | {"Run with libdl4d.so" | |
230 | "tmpdir/libdl4d.so" "" | |
231 | {dl4main.c} "dl4d" "dl4b.out"} | |
232 | {"Run with libdl4e.so" | |
233 | "tmpdir/libdl4e.so" "" | |
234 | {dl4main.c} "dl4e" "dl4a.out"} | |
235 | {"Run with libdl4f.so" | |
236 | "tmpdir/libdl4f.so" "" | |
237 | {dl4main.c} "dl4f" "dl4a.out"} | |
238 | {"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so" | |
239 | "--dynamic-list-data -ldl" "" | |
240 | {dl6amain.c} "dl6a1" "dl6a.out"} | |
241 | {"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so" | |
242 | "-Bsymbolic-functions -ldl" "" | |
243 | {dl6amain.c} "dl6a2" "dl6b.out"} | |
244 | {"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so" | |
245 | "-Bsymbolic -ldl" "" | |
246 | {dl6amain.c} "dl6a3" "dl6b.out"} | |
247 | {"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so" | |
248 | "-Bsymbolic --dynamic-list-data -ldl" "" | |
249 | {dl6amain.c} "dl6a4" "dl6a.out"} | |
250 | {"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so" | |
251 | "-Bsymbolic-functions --dynamic-list-cpp-new -ldl" "" | |
252 | {dl6amain.c} "dl6a5" "dl6b.out"} | |
253 | {"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so" | |
254 | "--dynamic-list-cpp-new -Bsymbolic-functions -ldl" "" | |
255 | {dl6amain.c} "dl6a6" "dl6b.out"} | |
256 | {"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so" | |
257 | "--dynamic-list-data -Bsymbolic -ldl" "" | |
258 | {dl6amain.c} "dl6a7" "dl6a.out"} | |
259 | {"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so" | |
260 | "--dynamic-list-data -ldl" "" | |
261 | {dl6bmain.c} "dl6b1" "dl6a.out"} | |
262 | {"Run dl6b2 with dlopen on libdl6b.so" | |
263 | "-ldl" "" | |
264 | {dl6bmain.c} "dl6b2" "dl6b.out"} | |
265 | {"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so" | |
266 | "--dynamic-list-data -ldl" "" | |
267 | {dl6cmain.c} "dl6c1" "dl6b.out"} | |
268 | {"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so" | |
269 | "--dynamic-list-data -ldl" "" | |
270 | {dl6dmain.c} "dl6d1" "dl6b.out"} | |
43edfb7f L |
271 | {"Run with libdata1.so" |
272 | "tmpdir/libdata1.so" "" | |
273 | {dynbss1.c} "dynbss1" "pass.out"} | |
0a36a439 L |
274 | {"Run with libfunc1.so comm1.o" |
275 | "tmpdir/libfunc1.so tmpdir/comm1.o" "" | |
276 | {dummy.c} "comm1" "pass.out"} | |
277 | {"Run with comm1.o libfunc1.so" | |
278 | "tmpdir/comm1.o tmpdir/libfunc1.so" "" | |
279 | {dummy.c} "comm1" "pass.out"} | |
d023c380 L |
280 | {"Run with pr11138-2.c libpr11138-1.so" |
281 | "--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" "" | |
282 | {dummy.c} "pr11138a" "pr11138.out"} | |
283 | {"Run with libpr11138-1.so pr11138-2.c" | |
284 | "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" "" | |
285 | {dummy.c} "pr11138b" "pr11138.out"} | |
d2dee3b2 L |
286 | } |
287 | ||
d2dee3b2 L |
288 | # NetBSD ELF systems do not currently support the .*_array sections. |
289 | run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests | |
55255dae | 290 | |
dd98f8d2 | 291 | # Check to see if the C++ compiler works |
55255dae L |
292 | if { [which $CXX] == 0 } { |
293 | return | |
294 | } | |
295 | ||
296 | set build_cxx_tests { | |
297 | {"Build libdl3a.so with --dynamic-list=dl3.list" | |
298 | "-shared -Wl,--dynamic-list=dl3.list" "-fPIC" | |
299 | {dl3.cc} {} "libdl3a.so" "c++"} | |
300 | {"Build libdl3b.so with -Bsymbolic" | |
301 | "-shared -Wl,-Bsymbolic" "-fPIC" | |
302 | {dl3.cc} {} "libdl3b.so" "c++"} | |
303 | {"Build libdl3a.so with --dynamic-list-cpp-typeinfo" | |
304 | "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC" | |
305 | {dl3.cc} {} "libdl3c.so" "c++"} | |
d8cf8b51 | 306 | {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new" |
40b36307 | 307 | "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC" |
d8cf8b51 L |
308 | {del.cc new.cc} {} "libnew1a.so" "c++"} |
309 | {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new" | |
310 | "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC" | |
311 | {del.cc new.cc} {} "libnew1b.so" "c++"} | |
55255dae L |
312 | } |
313 | ||
314 | set run_cxx_tests { | |
315 | {"Run with libdl3a.so" | |
316 | "tmpdir/libdl3a.so" "" | |
317 | {dl3main.cc} "dl3a" "dl3a.out" "" "c++"} | |
b37470e4 L |
318 | # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer. |
319 | # {"Run with libdl3b.so" | |
320 | # "tmpdir/libdl3b.so" "" | |
321 | # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"} | |
55255dae L |
322 | {"Run with libdl3c.so" |
323 | "tmpdir/libdl3c.so" "" | |
324 | {dl3main.cc} "dl3c" "dl3a.out" "" "c++"} | |
d8cf8b51 L |
325 | {"Run with libnew1a.so" |
326 | "tmpdir/libnew1a.so" "" | |
327 | {dl5.cc} "dl5a" "dl5.out" "" "c++"} | |
328 | {"Run with libnew1b.so" | |
329 | "tmpdir/libnew1b.so" "" | |
330 | {dl5.cc} "dl5b" "dl5.out" "" "c++"} | |
55255dae L |
331 | } |
332 | ||
333 | run_cc_link_tests $build_cxx_tests | |
334 | run_ld_link_exec_tests [] $run_cxx_tests |