a6f97092a4624adb21ddb523b55c64f830657b2e
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / shared.exp
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
21 if ![is_elf_format] {
22 return
23 }
24
25 # The following tests require running the executable generated by ld.
26 if ![isnative] {
27 return
28 }
29
30 # Check if compiler works
31 if { [which $CC] == 0 } {
32 return
33 }
34
35 set 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"
41 {foo.c} {} "libfoov.so"}
42 {"Build libbar.so"
43 "-shared" "-fPIC"
44 {begin.c end.c} {} "libbar.so"}
45 {"Build hidden libbar.so"
46 "-shared" "-fPIC"
47 {begin.c endhidden.c} {} "libbarh.so"}
48 {"Build protected libbar.so"
49 "-shared" "-fPIC"
50 {begin.c endprotected.c} {} "libbarp.so"}
51 {"Build libbar.so with libfoo.so"
52 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
53 {end.c} {} "libbarfoo.so"}
54 {"Build libar.so with versioned libfoo.so"
55 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
56 {end.c} {} "libbarfoov.so"}
57 {"Build hidden libbar.so with libfoo.so"
58 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
59 {endhidden.c} {} "libbarhfoo.so"}
60 {"Build hidden libar.so with versioned libfoo.so"
61 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
62 {endhidden.c} {} "libbarhfoov.so"}
63 {"Build protected libbar.so with libfoo.so"
64 "-shared tmpdir/begin.o tmpdir/libfoo.so" "-fPIC"
65 {endprotected.c} {} "libbarpfoo.so"}
66 {"Build protected libbar.so with versioned libfoo.so"
67 "-shared tmpdir/begin.o tmpdir/libfoov.so" "-fPIC"
68 {endprotected.c} {} "libbarpfoov.so"}
69 {"Build libdl1.so"
70 "-shared" "-fPIC"
71 {dl1.c} {} "libdl1.so"}
72 {"Build libdl2a.so with --dynamic-list=dl2.list"
73 "-shared -Wl,--dynamic-list=dl2.list" "-fPIC"
74 {dl2.c dl2xxx.c} {} "libdl2a.so"}
75 {"Build libdl2a.so with --dynamic-list-data"
76 "-shared -Wl,--dynamic-list-data" "-fPIC"
77 {dl2.c dl2xxx.c} {} "libdl2a.so"}
78 {"Build libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
79 "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
80 {dl2.c dl2xxx.c} {} "libdl2b.so"}
81 {"Build libdl2b.so with --dynamic-list-data and dl2xxx.list"
82 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl2xxx.list" "-fPIC"
83 {dl2.c dl2xxx.c} {} "libdl2b.so"}
84 {"Build libdl4a.so with --dynamic-list=dl4.list"
85 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
86 {dl4.c dl4xxx.c} {} "libdl4a.so"}
87 {"Build libdl4a.so with --dynamic-list-data"
88 "-shared -Wl,--dynamic-list-data" "-fPIC"
89 {dl4.c dl4xxx.c} {} "libdl4a.so"}
90 {"Build libdl4b.so with --dynamic-list=dl4.list and dl4xxx.list"
91 "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
92 {dl4.c dl4xxx.c} {} "libdl4b.so"}
93 {"Build libdl4b.so with --dynamic-list-data and dl4xxx.list"
94 "-shared -Wl,--dynamic-list-data,--dynamic-list=dl4xxx.list" "-fPIC"
95 {dl4.c dl4xxx.c} {} "libdl4b.so"}
96 }
97
98 set run_tests {
99 {"Run normal with libfoo.so"
100 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
101 {main.c} "normal" "normal.out"}
102 {"Run protected with libfoo.so"
103 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" ""
104 {main.c} "protected" "normal.out"}
105 {"Run hidden with libfoo.so"
106 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" ""
107 {main.c} "hidden" "hidden.out"}
108 {"Run normal with versioned libfoo.so"
109 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
110 {main.c} "normalv" "normal.out"}
111 {"Run protected with versioned libfoo.so"
112 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
113 {main.c} "protected" "normal.out"}
114 {"Run hidden with versioned libfoo.so"
115 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" ""
116 {main.c} "hiddenv" "hidden.out"}
117 {"Run normal libbar.so with libfoo.so"
118 "tmpdir/libbarfoo.so tmpdir/libfoo.so" ""
119 {main.c} "normal" "normal.out"}
120 {"Run protected libbar.so with libfoo.so"
121 "tmpdir/libbarpfoo.so tmpdir/libfoo.so" ""
122 {main.c} "protected" "normal.out"}
123 {"Run hidden libbar.so with libfoo.so"
124 "tmpdir/libbarhfoo.so tmpdir/libfoo.so" ""
125 {main.c} "hidden" "hidden.out"}
126 {"Run normal libbar.so with versioned libfoo.so"
127 "tmpdir/libbarfoov.so tmpdir/libfoov.so" ""
128 {main.c} "normal" "normal.out"}
129 {"Run protected libbar.so with versioned libfoo.so"
130 "tmpdir/libbarpfoov.so tmpdir/libfoov.so" ""
131 {main.c} "protected" "normal.out"}
132 {"Run hidden libbar.so with versioned libfoo.so"
133 "tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
134 {main.c} "hidden" "hidden.out"}
135 {"Run dl1 with --dynamic-list=dl1.list and dlopen on libdl1.so"
136 "--dynamic-list=dl1.list -ldl" ""
137 {dl1main.c} "dl1" "dl1.out"}
138 {"Run dl1 with --dynamic-list-data and dlopen on libdl1.so"
139 "--dynamic-list-data -ldl" ""
140 {dl1main.c} "dl1" "dl1.out"}
141 {"Run with libdl2a.so"
142 "tmpdir/libdl2a.so" ""
143 {dl2main.c} "dl2a" "dl2a.out"}
144 {"Run with libdl2b.so"
145 "tmpdir/libdl2b.so" ""
146 {dl2main.c} "dl2b" "dl2b.out"}
147 {"Run with libdl4a.so"
148 "tmpdir/libdl4a.so" ""
149 {dl4main.c} "dl4a" "dl4a.out"}
150 {"Run with libdl4b.so"
151 "tmpdir/libdl4b.so" ""
152 {dl4main.c} "dl4b" "dl4b.out"}
153 }
154
155 run_cc_link_tests $build_tests
156 # NetBSD ELF systems do not currently support the .*_array sections.
157 run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests
158
159 # Check if compiler works
160 if { [which $CXX] == 0 } {
161 return
162 }
163
164 set build_cxx_tests {
165 {"Build libdl3a.so with --dynamic-list=dl3.list"
166 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
167 {dl3.cc} {} "libdl3a.so" "c++"}
168 {"Build libdl3b.so with -Bsymbolic"
169 "-shared -Wl,-Bsymbolic" "-fPIC"
170 {dl3.cc} {} "libdl3b.so" "c++"}
171 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
172 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
173 {dl3.cc} {} "libdl3c.so" "c++"}
174 {"Build libdnew.so with -Bsymbolic-functions -dynamic-list-cpp-new"
175 "-shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new" "-fPIC"
176 {del.cc new.cc} {} "libnew.so" "c++"}
177 }
178
179 set run_cxx_tests {
180 {"Run with libdl3a.so"
181 "tmpdir/libdl3a.so" ""
182 {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
183 {"Run with libdl3b.so"
184 "tmpdir/libdl3b.so" ""
185 {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
186 {"Run with libdl3c.so"
187 "tmpdir/libdl3c.so" ""
188 {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
189 {"Run with libnew.so"
190 "tmpdir/libnew.so" ""
191 {dl5.cc} "dl5" "dl5.out" "" "c++"}
192 }
193
194 run_cc_link_tests $build_cxx_tests
195 run_ld_link_exec_tests [] $run_cxx_tests
This page took 0.044809 seconds and 4 git commands to generate.