Remove ref_dynamic_nonweak added by accident
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / shared.exp
1 # Expect script for various ELF tests.
2 # Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 # Free Software Foundation, Inc.
4 #
5 # This file is part of the GNU Binutils.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
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
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 # MA 02110-1301, USA.
21 #
22
23 # Exclude non-ELF targets.
24
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
32 if ![is_elf_format] {
33 return
34 }
35
36 # Check to see if the C compiler works
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"
47 {foo.c} {} "libfoov.so"}
48 {"Build libbar.so"
49 "-shared" "-fPIC"
50 {begin.c end.c} {} "libbar.so"}
51 {"Build warn libbar.so"
52 "-shared" "-fPIC"
53 {beginwarn.c end.c} {} "libbarw.so"
54 "C" "^.*\\\): warning: function foo is deprecated$"}
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"}
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"}
85 {"Build libdl2a.so with --dynamic-list=dl2a.list"
86 "-shared -Wl,--dynamic-list=dl2a.list" "-fPIC"
87 {dl2.c dl2xxx.c} {} "libdl2a.so"}
88 {"Build libdl2a.so with --dynamic-list-data"
89 "-shared -Wl,--dynamic-list-data" "-fPIC"
90 {dl2.c dl2xxx.c} {} "libdl2a.so"}
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"}
94 {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
95 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
96 {dl2.c dl2xxx.c} {} "libdl2c.so"}
97 {"Build libdl4a.so with --dynamic-list=dl4.list"
98 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
99 {dl4.c dl4xxx.c} {} "libdl4a.so"}
100 {"Build libdl4b.so with --dynamic-list-data"
101 "-shared -Wl,--dynamic-list-data" "-fPIC"
102 {dl4.c dl4xxx.c} {} "libdl4b.so"}
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"
107 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
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"}
127 {"Build libdata1.so"
128 "-shared" "-fPIC"
129 {data1.c} {} "libdata1.so"}
130 {"Build libdata2.so"
131 "-shared" "-fPIC"
132 {data2.c} {} "libdata2.so"}
133 {"Build libcomm1.o"
134 "-r -nostdlib" ""
135 {comm1.c} {} "libcomm1.o"}
136 {"Build libfunc1.so"
137 "-shared" "-fPIC"
138 {func1.c} {} "libfunc1.so"}
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"}
155 {"Build libpr9679.so"
156 "-shared" "-fPIC -O0"
157 {pr9679-1.c pr9679-2.c} {{readelf {-s} pr9679.rd}} "libpr9679.so"}
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"}
164 {"Build pr13250-1.so"
165 "-shared" "-fPIC"
166 {pr13250-1.c} {} "libpr13250-1.so"}
167 {"Build pr13250-2.so with libpr13250-1.so"
168 "-shared -Wl,--no-as-needed tmpdir/libpr13250-1.so" "-fPIC"
169 {pr13250-2.c} {} "libpr13250-2.so"}
170 {"Build libpr13250-3.o"
171 "-r -nostdlib" ""
172 {pr13250-3.c} {} "libpr13250-3.o"}
173 {"Build libpr14323-2.so"
174 "-shared" "-fPIC"
175 {pr14323-2.c} {} "libpr14323-2.so"}
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"}
182 }
183
184 run_cc_link_tests $build_tests
185
186 set run_tests {
187 {"Run normal with libfoo.so"
188 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
189 {main.c} "normal" "normal.out"}
190 {"Run protected with libfoo.so"
191 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" ""
192 {main.c} "protected" "normal.out"}
193 {"Run hidden with libfoo.so"
194 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" ""
195 {main.c} "hidden" "hidden.out"}
196 {"Run normal with versioned libfoo.so"
197 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
198 {main.c} "normalv" "normal.out"}
199 {"Run warn with versioned libfoo.so"
200 "tmpdir/beginwarn.o tmpdir/libfoov.so" ""
201 {main.c} "warn" "warn.out"
202 "" "" "^.*\\\): warning: function foo is deprecated$"}
203 {"Run protected with versioned libfoo.so"
204 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
205 {main.c} "protected" "normal.out"}
206 {"Run hidden with versioned libfoo.so"
207 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" ""
208 {main.c} "hiddenv" "hidden.out"}
209 {"Run normal libbar.so with libfoo.so"
210 "tmpdir/libbarfoo.so tmpdir/libfoo.so" ""
211 {main.c} "normal" "normal.out"}
212 {"Run protected libbar.so with libfoo.so"
213 "tmpdir/libbarpfoo.so tmpdir/libfoo.so" ""
214 {main.c} "protected" "normal.out"}
215 {"Run hidden libbar.so with libfoo.so"
216 "tmpdir/libbarhfoo.so tmpdir/libfoo.so" ""
217 {main.c} "hidden" "hidden.out"}
218 {"Run normal libbar.so with versioned libfoo.so"
219 "tmpdir/libbarfoov.so tmpdir/libfoov.so" ""
220 {main.c} "normal" "normal.out"}
221 {"Run protected libbar.so with versioned libfoo.so"
222 "tmpdir/libbarpfoov.so tmpdir/libfoov.so" ""
223 {main.c} "protected" "normal.out"}
224 {"Run hidden libbar.so with versioned libfoo.so"
225 "tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
226 {main.c} "hidden" "hidden.out"}
227 {"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so"
228 "--dynamic-list=dl1.list -ldl" ""
229 {dl1main.c} "dl1a" "dl1.out"}
230 {"Run dl1b with --dynamic-list-data and dlopen on libdl1.so"
231 "--dynamic-list-data -ldl" ""
232 {dl1main.c} "dl1b" "dl1.out"}
233 {"Run with libdl2a.so"
234 "tmpdir/libdl2a.so" ""
235 {dl2main.c} "dl2a" "dl2a.out"}
236 {"Run with libdl2b.so"
237 "tmpdir/libdl2b.so" ""
238 {dl2main.c} "dl2b" "dl2b.out"}
239 {"Run with libdl2c.so"
240 "tmpdir/libdl2c.so" ""
241 {dl2main.c} "dl2c" "dl2b.out"}
242 {"Run with libdl4a.so"
243 "tmpdir/libdl4a.so" ""
244 {dl4main.c} "dl4a" "dl4a.out"}
245 {"Run with libdl4b.so"
246 "tmpdir/libdl4b.so" ""
247 {dl4main.c} "dl4b" "dl4a.out"}
248 {"Run with libdl4c.so"
249 "tmpdir/libdl4c.so" ""
250 {dl4main.c} "dl4c" "dl4b.out"}
251 {"Run with libdl4d.so"
252 "tmpdir/libdl4d.so" ""
253 {dl4main.c} "dl4d" "dl4b.out"}
254 {"Run with libdl4e.so"
255 "tmpdir/libdl4e.so" ""
256 {dl4main.c} "dl4e" "dl4a.out"}
257 {"Run with libdl4f.so"
258 "tmpdir/libdl4f.so" ""
259 {dl4main.c} "dl4f" "dl4a.out"}
260 {"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so"
261 "--dynamic-list-data -ldl" ""
262 {dl6amain.c} "dl6a1" "dl6a.out"}
263 {"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so"
264 "-Bsymbolic-functions -ldl" ""
265 {dl6amain.c} "dl6a2" "dl6b.out"}
266 {"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so"
267 "-Bsymbolic -ldl" ""
268 {dl6amain.c} "dl6a3" "dl6b.out"}
269 {"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so"
270 "-Bsymbolic --dynamic-list-data -ldl" ""
271 {dl6amain.c} "dl6a4" "dl6a.out"}
272 {"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so"
273 "-Bsymbolic-functions --dynamic-list-cpp-new -ldl" ""
274 {dl6amain.c} "dl6a5" "dl6b.out"}
275 {"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so"
276 "--dynamic-list-cpp-new -Bsymbolic-functions -ldl" ""
277 {dl6amain.c} "dl6a6" "dl6b.out"}
278 {"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so"
279 "--dynamic-list-data -Bsymbolic -ldl" ""
280 {dl6amain.c} "dl6a7" "dl6a.out"}
281 {"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so"
282 "--dynamic-list-data -ldl" ""
283 {dl6bmain.c} "dl6b1" "dl6a.out"}
284 {"Run dl6b2 with dlopen on libdl6b.so"
285 "-ldl" ""
286 {dl6bmain.c} "dl6b2" "dl6b.out"}
287 {"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so"
288 "--dynamic-list-data -ldl" ""
289 {dl6cmain.c} "dl6c1" "dl6b.out"}
290 {"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so"
291 "--dynamic-list-data -ldl" ""
292 {dl6dmain.c} "dl6d1" "dl6b.out"}
293 {"Run with libdata1.so"
294 "tmpdir/libdata1.so" ""
295 {dynbss1.c} "dynbss1" "pass.out"}
296 {"Run with libdata2.so"
297 "tmpdir/libdata2.so" ""
298 {weakdef1.c} "weakdef1" "pass.out"}
299 {"Run with libfunc1.so comm1.o"
300 "tmpdir/libfunc1.so tmpdir/comm1.o" ""
301 {dummy.c} "comm1" "pass.out"}
302 {"Run with comm1.o libfunc1.so"
303 "tmpdir/comm1.o tmpdir/libfunc1.so" ""
304 {dummy.c} "comm1" "pass.out"}
305 {"Run with pr11138-2.c libpr11138-1.so"
306 "--version-script=pr11138-2.map tmpdir/pr11138-2.o tmpdir/libpr11138-1.so" ""
307 {dummy.c} "pr11138a" "pr11138.out"}
308 {"Run with libpr11138-1.so pr11138-2.c"
309 "--version-script=pr11138-2.map tmpdir/libpr11138-1.so tmpdir/pr11138-2.o" ""
310 {dummy.c} "pr11138b" "pr11138.out"}
311 {"Run with pr13250-3.c, libpr13250-1.so and libpr13250-2.so"
312 "--as-needed tmpdir/pr13250-3.o tmpdir/libpr13250-1.so tmpdir/libpr13250-2.so" ""
313 {dummy.c} "pr13250" "pass.out"}
314 {"Run with pr14323-1.c pr14323-2.so"
315 "tmpdir/libpr14323-2.so" ""
316 {pr14323-1.c} "pr14323" "pass.out"}
317 {"Run with pr14862-1.c libpr14862.so"
318 "--as-needed tmpdir/libpr14862-1.o tmpdir/libpr14862.so" ""
319 {dummy.c} "pr14862" "pr14862.out"}
320 }
321
322 # NetBSD ELF systems do not currently support the .*_array sections.
323 run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests
324
325 # Check to see if the C++ compiler works
326 if { [which $CXX] == 0 } {
327 return
328 }
329
330 set build_cxx_tests {
331 {"Build libdl3a.so with --dynamic-list=dl3.list"
332 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
333 {dl3.cc} {} "libdl3a.so" "c++"}
334 {"Build libdl3b.so with -Bsymbolic"
335 "-shared -Wl,-Bsymbolic" "-fPIC"
336 {dl3.cc} {} "libdl3b.so" "c++"}
337 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
338 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
339 {dl3.cc} {} "libdl3c.so" "c++"}
340 {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
341 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
342 {del.cc new.cc} {} "libnew1a.so" "c++"}
343 {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
344 "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC"
345 {del.cc new.cc} {} "libnew1b.so" "c++"}
346 }
347
348 # "-shared -Bsymbolic" only works with gcc 4.5.0 and newer.
349 # {"Run with libdl3b.so"
350 # "tmpdir/libdl3b.so" ""
351 # {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
352 set run_cxx_tests {
353 {"Run with libdl3a.so"
354 "-Wl,--no-as-needed tmpdir/libdl3a.so" ""
355 {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
356 {"Run with libdl3c.so"
357 "-Wl,--no-as-needed tmpdir/libdl3c.so" ""
358 {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
359 {"Run with libnew1a.so"
360 "tmpdir/libnew1a.so" ""
361 {dl5.cc} "dl5a" "dl5.out" "" "c++"}
362 {"Run with libnew1b.so"
363 "tmpdir/libnew1b.so" ""
364 {dl5.cc} "dl5b" "dl5.out" "" "c++"}
365 }
366
367 run_cc_link_tests $build_cxx_tests
368 run_ld_link_exec_tests [] $run_cxx_tests
This page took 0.045615 seconds and 5 git commands to generate.