2007-05-14 Denis Pilat <denis.pilat@st.com>
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / shared.exp
CommitLineData
d2dee3b2
L
1# Expect script for various ELF tests.
2# Copyright 2006 Free Software Foundation, Inc.
3#
4# This file is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 2 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program; if not, write to the Free Software
16# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
17#
18
19# Exclude non-ELF targets.
20
21if ![is_elf_format] {
22 return
23}
24
25# The following tests require running the executable generated by ld.
26if ![isnative] {
27 return
28}
29
30# Check if compiler works
31if { [which $CC] == 0 } {
32 return
33}
34
35set build_tests {
36 {"Build libfoo.so"
37 "-shared" "-fPIC"
38 {foo.c} {} "libfoo.so"}
39 {"Build versioned libfoo.so"
40 "-shared -Wl,--version-script=foo.map" "-fPIC"
55255dae 41 {foo.c} {} "libfoov.so"}
d2dee3b2
L
42 {"Build libbar.so"
43 "-shared" "-fPIC"
44 {begin.c end.c} {} "libbar.so"}
fab4a87f
L
45 {"Build warn libbar.so"
46 "-shared" "-fPIC"
47 {beginwarn.c end.c} {} "libbarw.so"}
d2dee3b2
L
48 {"Build hidden libbar.so"
49 "-shared" "-fPIC"
50 {begin.c endhidden.c} {} "libbarh.so"}
51 {"Build protected libbar.so"
52 "-shared" "-fPIC"
53 {begin.c endprotected.c} {} "libbarp.so"}
54 {"Build libbar.so with libfoo.so"
55 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
56 {end.c} {} "libbarfoo.so"}
57 {"Build libar.so with versioned libfoo.so"
58 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
59 {end.c} {} "libbarfoov.so"}
60 {"Build hidden libbar.so with libfoo.so"
61 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
62 {endhidden.c} {} "libbarhfoo.so"}
63 {"Build hidden libar.so with versioned libfoo.so"
64 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
65 {endhidden.c} {} "libbarhfoov.so"}
66 {"Build protected libbar.so with libfoo.so"
67 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
68 {endprotected.c} {} "libbarpfoo.so"}
69 {"Build protected libbar.so with versioned libfoo.so"
70 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
71 {endprotected.c} {} "libbarpfoov.so"}
55255dae
L
72 {"Build libdl1.so"
73 "-shared" "-fPIC"
74 {dl1.c} {} "libdl1.so"}
75 {"Build libdl2a.so with --dynamic-list=dl2.list"
76 "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
77 {dl2.c dl2xxx.c} {} "libdl2a.so"}
40b36307
L
78 {"Build libdl2a.so with --dynamic-list-data"
79 "-shared -Wl,--dynamic-list-data" "-fPIC"
80 {dl2.c dl2xxx.c} {} "libdl2a.so"}
55255dae
L
81 {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
82 "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
83 {dl2.c dl2xxx.c} {} "libdl2b.so"}
d8cf8b51 84 {"Build libdl2c.so with --dynamic-list-data and dl2xxx.list"
40b36307 85 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
d8cf8b51 86 {dl2.c dl2xxx.c} {} "libdl2c.so"}
c555238b
L
87 {"Build libdl4a.so with --dynamic-list=dl4.list"
88 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
89 {dl4.c dl4xxx.c} {} "libdl4a.so"}
d8cf8b51 90 {"Build libdl4b.so with --dynamic-list-data"
40b36307 91 "-shared -Wl,--dynamic-list-data" "-fPIC"
c555238b 92 {dl4.c dl4xxx.c} {} "libdl4b.so"}
d8cf8b51
L
93 {"Build libdl4c.so with --dynamic-list=dl4.list and dl4xxx.list"
94 "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
95 {dl4.c dl4xxx.c} {} "libdl4c.so"}
96 {"Build libdl4d.so with --dynamic-list-data and dl4xxx.list"
40b36307 97 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
d8cf8b51
L
98 {dl4.c dl4xxx.c} {} "libdl4d.so"}
99 {"Build libdl4e.so with -Bsymbolic-functions --dynamic-list-cpp-new"
100 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
101 {dl4.c dl4xxx.c} {} "libdl4e.so"}
102 {"Build libdl4f.so with --dynamic-list-cpp-new -Bsymbolic-functions"
103 "-shared -Wl,--dynamic-list-cpp-new,-Bsymbolic-functions" "-fPIC"
104 {dl4.c dl4xxx.c} {} "libdl4f.so"}
105 {"Build libdl6a.so"
106 "-shared" "-fPIC"
107 {dl6.c} {} "libdl6a.so"}
108 {"Build libdl6b.so with -Bsymbolic --dynamic-list-data"
109 "-shared -Wl,-Bsymbolic,--dynamic-list-data" "-fPIC"
110 {dl6.c} {} "libdl6b.so"}
111 {"Build libdl6c.so with -Bsymbolic"
112 "-shared -Wl,-Bsymbolic" "-fPIC"
113 {dl6.c} {} "libdl6c.so"}
114 {"Build libdl6d.so with --dynamic-list-data -Bsymbolic"
115 "-shared -Wl,--dynamic-list-data,-Bsymbolic" "-fPIC"
116 {dl6.c} {} "libdl6d.so"}
d2dee3b2
L
117}
118
119set run_tests {
120 {"Run normal with libfoo.so"
121 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
122 {main.c} "normal" "normal.out"}
123 {"Run protected with libfoo.so"
124 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" ""
125 {main.c} "protected" "normal.out"}
126 {"Run hidden with libfoo.so"
127 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" ""
128 {main.c} "hidden" "hidden.out"}
129 {"Run normal with versioned libfoo.so"
130 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
131 {main.c} "normalv" "normal.out"}
fab4a87f
L
132 {"Run warn with versioned libfoo.so"
133 "tmpdir/beginwarn.o tmpdir/libfoov.so" ""
134 {main.c} "warn" "warn.out"
135 "" "" "^.*\\\): warning: function foo is deprecated$"}
d2dee3b2
L
136 {"Run protected with versioned libfoo.so"
137 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
138 {main.c} "protected" "normal.out"}
139 {"Run hidden with versioned libfoo.so"
140 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" ""
141 {main.c} "hiddenv" "hidden.out"}
142 {"Run normal libbar.so with libfoo.so"
143 "tmpdir/libbarfoo.so tmpdir/libfoo.so" ""
144 {main.c} "normal" "normal.out"}
145 {"Run protected libbar.so with libfoo.so"
146 "tmpdir/libbarpfoo.so tmpdir/libfoo.so" ""
147 {main.c} "protected" "normal.out"}
148 {"Run hidden libbar.so with libfoo.so"
149 "tmpdir/libbarhfoo.so tmpdir/libfoo.so" ""
150 {main.c} "hidden" "hidden.out"}
151 {"Run normal libbar.so with versioned libfoo.so"
152 "tmpdir/libbarfoov.so tmpdir/libfoov.so" ""
153 {main.c} "normal" "normal.out"}
154 {"Run protected libbar.so with versioned libfoo.so"
155 "tmpdir/libbarpfoov.so tmpdir/libfoov.so" ""
156 {main.c} "protected" "normal.out"}
157 {"Run hidden libbar.so with versioned libfoo.so"
158 "tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
159 {main.c} "hidden" "hidden.out"}
d8cf8b51 160 {"Run dl1a with --dynamic-list=dl1.list and dlopen on libdl1.so"
55255dae 161 "--dynamic-list=dl1.list -ldl" ""
d8cf8b51
L
162 {dl1main.c} "dl1a" "dl1.out"}
163 {"Run dl1b with --dynamic-list-data and dlopen on libdl1.so"
40b36307 164 "--dynamic-list-data -ldl" ""
d8cf8b51 165 {dl1main.c} "dl1b" "dl1.out"}
55255dae
L
166 {"Run with libdl2a.so"
167 "tmpdir/libdl2a.so" ""
168 {dl2main.c} "dl2a" "dl2a.out"}
169 {"Run with libdl2b.so"
170 "tmpdir/libdl2b.so" ""
171 {dl2main.c} "dl2b" "dl2b.out"}
d8cf8b51
L
172 {"Run with libdl2c.so"
173 "tmpdir/libdl2c.so" ""
174 {dl2main.c} "dl2c" "dl2b.out"}
c555238b
L
175 {"Run with libdl4a.so"
176 "tmpdir/libdl4a.so" ""
177 {dl4main.c} "dl4a" "dl4a.out"}
178 {"Run with libdl4b.so"
179 "tmpdir/libdl4b.so" ""
d8cf8b51
L
180 {dl4main.c} "dl4b" "dl4a.out"}
181 {"Run with libdl4c.so"
182 "tmpdir/libdl4c.so" ""
183 {dl4main.c} "dl4c" "dl4b.out"}
184 {"Run with libdl4d.so"
185 "tmpdir/libdl4d.so" ""
186 {dl4main.c} "dl4d" "dl4b.out"}
187 {"Run with libdl4e.so"
188 "tmpdir/libdl4e.so" ""
189 {dl4main.c} "dl4e" "dl4a.out"}
190 {"Run with libdl4f.so"
191 "tmpdir/libdl4f.so" ""
192 {dl4main.c} "dl4f" "dl4a.out"}
193 {"Run dl6a1 with --dynamic-list-data and dlopen on libdl6a.so"
194 "--dynamic-list-data -ldl" ""
195 {dl6amain.c} "dl6a1" "dl6a.out"}
196 {"Run dl6a2 with -Bsymbolic-functions and dlopen on libdl6a.so"
197 "-Bsymbolic-functions -ldl" ""
198 {dl6amain.c} "dl6a2" "dl6b.out"}
199 {"Run dl6a3 with -Bsymbolic and dlopen on libdl6a.so"
200 "-Bsymbolic -ldl" ""
201 {dl6amain.c} "dl6a3" "dl6b.out"}
202 {"Run dl6a4 with -Bsymbolic --dynamic-list-data and dlopen on libdl6a.so"
203 "-Bsymbolic --dynamic-list-data -ldl" ""
204 {dl6amain.c} "dl6a4" "dl6a.out"}
205 {"Run dl6a5 with -Bsymbolic-functions --dynamic-list-cpp-new and dlopen on libdl6a.so"
206 "-Bsymbolic-functions --dynamic-list-cpp-new -ldl" ""
207 {dl6amain.c} "dl6a5" "dl6b.out"}
208 {"Run dl6a6 with --dynamic-list-cpp-new -Bsymbolic-functions and dlopen on libdl6a.so"
209 "--dynamic-list-cpp-new -Bsymbolic-functions -ldl" ""
210 {dl6amain.c} "dl6a6" "dl6b.out"}
211 {"Run dl6a7 with --dynamic-list-data -Bsymbolic and dlopen on libdl6a.so"
212 "--dynamic-list-data -Bsymbolic -ldl" ""
213 {dl6amain.c} "dl6a7" "dl6a.out"}
214 {"Run dl6b1 with --dynamic-list-data and dlopen on libdl6b.so"
215 "--dynamic-list-data -ldl" ""
216 {dl6bmain.c} "dl6b1" "dl6a.out"}
217 {"Run dl6b2 with dlopen on libdl6b.so"
218 "-ldl" ""
219 {dl6bmain.c} "dl6b2" "dl6b.out"}
220 {"Run dl6c1 with --dynamic-list-data and dlopen on libdl6c.so"
221 "--dynamic-list-data -ldl" ""
222 {dl6cmain.c} "dl6c1" "dl6b.out"}
223 {"Run dl6d1 with --dynamic-list-data and dlopen on libdl6d.so"
224 "--dynamic-list-data -ldl" ""
225 {dl6dmain.c} "dl6d1" "dl6b.out"}
d2dee3b2
L
226}
227
228run_cc_link_tests $build_tests
229# NetBSD ELF systems do not currently support the .*_array sections.
230run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests
55255dae
L
231
232# Check if compiler works
233if { [which $CXX] == 0 } {
234 return
235}
236
237set build_cxx_tests {
238 {"Build libdl3a.so with --dynamic-list=dl3.list"
239 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
240 {dl3.cc} {} "libdl3a.so" "c++"}
241 {"Build libdl3b.so with -Bsymbolic"
242 "-shared -Wl,-Bsymbolic" "-fPIC"
243 {dl3.cc} {} "libdl3b.so" "c++"}
244 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
245 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
246 {dl3.cc} {} "libdl3c.so" "c++"}
d8cf8b51 247 {"Build libdnew1a.so with --Bsymbolic-functions --dynamic-list-cpp-new"
40b36307 248 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
d8cf8b51
L
249 {del.cc new.cc} {} "libnew1a.so" "c++"}
250 {"Build libdnew1b.so with --dynamic-list-data --dynamic-list-cpp-new"
251 "-shared -Wl,--dynamic-list-data,--dynamic-list-cpp-new" "-fPIC"
252 {del.cc new.cc} {} "libnew1b.so" "c++"}
55255dae
L
253}
254
255set run_cxx_tests {
256 {"Run with libdl3a.so"
257 "tmpdir/libdl3a.so" ""
258 {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
259 {"Run with libdl3b.so"
260 "tmpdir/libdl3b.so" ""
261 {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
262 {"Run with libdl3c.so"
263 "tmpdir/libdl3c.so" ""
264 {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
d8cf8b51
L
265 {"Run with libnew1a.so"
266 "tmpdir/libnew1a.so" ""
267 {dl5.cc} "dl5a" "dl5.out" "" "c++"}
268 {"Run with libnew1b.so"
269 "tmpdir/libnew1b.so" ""
270 {dl5.cc} "dl5b" "dl5.out" "" "c++"}
55255dae
L
271}
272
273run_cc_link_tests $build_cxx_tests
274run_ld_link_exec_tests [] $run_cxx_tests
This page took 0.062224 seconds and 4 git commands to generate.