1 # Expect script for various ELF tests.
2 # Copyright 2006 Free Software Foundation, Inc.
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.
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.
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.
19 # Exclude non-ELF targets.
25 # The following tests require running the executable generated by ld.
30 # Check if compiler works
31 if { [which $CC] == 0 } {
38 {foo.c} {} "libfoo.so"}
39 {"Build versioned libfoo.so"
40 "-shared -Wl,--version-script=foo.map" "-fPIC"
41 {foo.c} {} "libfoov.so"}
44 {begin.c end.c} {} "libbar.so"}
45 {"Build hidden libbar.so"
47 {begin.c endhidden.c} {} "libbarh.so"}
48 {"Build protected libbar.so"
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"}
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 libdl2b.so with --dynamic-list=dl2.list and dl2xxx.list"
76 "-shared -Wl,--dynamic-list=dl2.list,--dynamic-list=dl2xxx.list" "-fPIC"
77 {dl2.c dl2xxx.c} {} "libdl2b.so"}
78 {"Build libdl4a.so with --dynamic-list=dl4.list"
79 "-shared -Wl,--dynamic-list=dl4.list" "-fPIC"
80 {dl4.c dl4xxx.c} {} "libdl4a.so"}
81 {"Build libdl4b.so with --dynamic-list=dl4.list and dl4xxx.list"
82 "-shared -Wl,--dynamic-list=dl4.list,--dynamic-list=dl4xxx.list" "-fPIC"
83 {dl4.c dl4xxx.c} {} "libdl4b.so"}
87 {"Run normal with libfoo.so"
88 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/end.o" ""
89 {main.c} "normal" "normal.out"}
90 {"Run protected with libfoo.so"
91 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endprotected.o" ""
92 {main.c} "protected" "normal.out"}
93 {"Run hidden with libfoo.so"
94 "tmpdir/begin.o tmpdir/libfoo.so tmpdir/endhidden.o" ""
95 {main.c} "hidden" "hidden.out"}
96 {"Run normal with versioned libfoo.so"
97 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/end.o" ""
98 {main.c} "normalv" "normal.out"}
99 {"Run protected with versioned libfoo.so"
100 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endprotected.o" ""
101 {main.c} "protected" "normal.out"}
102 {"Run hidden with versioned libfoo.so"
103 "tmpdir/begin.o tmpdir/libfoov.so tmpdir/endhidden.o" ""
104 {main.c} "hiddenv" "hidden.out"}
105 {"Run normal libbar.so with libfoo.so"
106 "tmpdir/libbarfoo.so tmpdir/libfoo.so" ""
107 {main.c} "normal" "normal.out"}
108 {"Run protected libbar.so with libfoo.so"
109 "tmpdir/libbarpfoo.so tmpdir/libfoo.so" ""
110 {main.c} "protected" "normal.out"}
111 {"Run hidden libbar.so with libfoo.so"
112 "tmpdir/libbarhfoo.so tmpdir/libfoo.so" ""
113 {main.c} "hidden" "hidden.out"}
114 {"Run normal libbar.so with versioned libfoo.so"
115 "tmpdir/libbarfoov.so tmpdir/libfoov.so" ""
116 {main.c} "normal" "normal.out"}
117 {"Run protected libbar.so with versioned libfoo.so"
118 "tmpdir/libbarpfoov.so tmpdir/libfoov.so" ""
119 {main.c} "protected" "normal.out"}
120 {"Run hidden libbar.so with versioned libfoo.so"
121 "tmpdir/libbarhfoov.so tmpdir/libfoov.so" ""
122 {main.c} "hidden" "hidden.out"}
123 {"Run with dlopen on libdl1.so"
124 "--dynamic-list=dl1.list -ldl" ""
125 {dl1main.c} "dl1" "dl1.out"}
126 {"Run with libdl2a.so"
127 "tmpdir/libdl2a.so" ""
128 {dl2main.c} "dl2a" "dl2a.out"}
129 {"Run with libdl2b.so"
130 "tmpdir/libdl2b.so" ""
131 {dl2main.c} "dl2b" "dl2b.out"}
132 {"Run with libdl4a.so"
133 "tmpdir/libdl4a.so" ""
134 {dl4main.c} "dl4a" "dl4a.out"}
135 {"Run with libdl4b.so"
136 "tmpdir/libdl4b.so" ""
137 {dl4main.c} "dl4b" "dl4b.out"}
140 run_cc_link_tests $build_tests
141 # NetBSD ELF systems do not currently support the .*_array sections.
142 run_ld_link_exec_tests [list "*-*-netbsdelf*"] $run_tests
144 # Check if compiler works
145 if { [which $CXX] == 0 } {
149 set build_cxx_tests {
150 {"Build libdl3a.so with --dynamic-list=dl3.list"
151 "-shared -Wl,--dynamic-list=dl3.list" "-fPIC"
152 {dl3.cc} {} "libdl3a.so" "c++"}
153 {"Build libdl3b.so with -Bsymbolic"
154 "-shared -Wl,-Bsymbolic" "-fPIC"
155 {dl3.cc} {} "libdl3b.so" "c++"}
156 {"Build libdl3a.so with --dynamic-list-cpp-typeinfo"
157 "-shared -Wl,--dynamic-list-cpp-typeinfo" "-fPIC"
158 {dl3.cc} {} "libdl3c.so" "c++"}
162 {"Run with libdl3a.so"
163 "tmpdir/libdl3a.so" ""
164 {dl3main.cc} "dl3a" "dl3a.out" "" "c++"}
165 {"Run with libdl3b.so"
166 "tmpdir/libdl3b.so" ""
167 {dl3main.cc} "dl3b" "dl3b.out" "" "c++"}
168 {"Run with libdl3c.so"
169 "tmpdir/libdl3c.so" ""
170 {dl3main.cc} "dl3c" "dl3a.out" "" "c++"}
173 run_cc_link_tests $build_cxx_tests
174 run_ld_link_exec_tests [] $run_cxx_tests