[ld, testsuite] XFAIL "pr20995-2", "Build pr20995-2.so" on arm*-*-eabi*
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / elf.exp
1 # Expect script for various ELF tests.
2 # Copyright (C) 2002-2017 Free Software Foundation, Inc.
3 #
4 # This file is part of the GNU Binutils.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
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
18 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 # MA 02110-1301, USA.
20 #
21
22 # Exclude non-ELF targets.
23
24 if ![is_elf_format] {
25 return
26 }
27
28 set old_ldflags $LDFLAGS
29 if { [istarget spu*-*-*] } {
30 set LDFLAGS "$LDFLAGS --local-store 0:0"
31 }
32 if { [istarget alpha*-*-* ] } {
33 # The compress1 test is written expecting 32-bit addresses; force the
34 # executable down into the low address space to match.
35 # ??? How can we adjust just the one testcase?
36 set LDFLAGS "$LDFLAGS -Ttext-segment 0x1000000"
37 }
38
39 if { [istarget "*-*-nacl*"] } {
40 # The eh[1-4] cases are written to expect ELFCLASS64 layout on x86-64.
41 # But the target default is ELFCLASS32. So the cases explicitly use
42 # -melf_x86_64 to select that, but NaCl needs a different emulation name.
43 set options_regsub(ld) {-melf_x86_64 -melf_x86_64_nacl}
44 }
45
46 if { [istarget "*-*-solaris*"] } {
47 # Same for Solaris
48 set options_regsub(ld) {-melf_x86_64 -melf_x86_64_sol2}
49 }
50
51 if { [is_remote host] } then {
52 remote_download host merge.ld
53 }
54
55 if { ![istarget hppa64*-hpux*] } {
56 run_ld_link_tests {
57 {"Build symbol3.a"
58 "" "" ""
59 {symbol3.s} {} "symbol3.a"}
60 {"Build symbol3w.a"
61 "" "" ""
62 {symbol3w.s} {} "symbol3w.a"}
63 }
64
65 if { [check_shared_lib_support] } then {
66 run_ld_link_tests {
67 {"Build pr14170a.o" "" "" "" "pr14170a.s" {} "pr14170.a" }
68 }
69 setup_xfail "tic6x-*-*"
70 run_ld_link_tests {
71 {"Build shared library for pr14170"
72 "-shared" "" "" "pr14170b.s" {} "pr14170.so" }
73 }
74 # bfin does not currently support copy relocs.
75 setup_xfail "bfin-*-*"
76 run_ld_link_tests {
77 {"PR ld/14170"
78 "--no-dynamic-linker tmpdir/pr14170a.o tmpdir/pr14170.so" "" "" "pr14170c.s"
79 { } "pr14170" }
80 }
81 }
82 }
83
84 # Only run these tests on targets that support creating shared libraries.
85 if { [check_shared_lib_support] } then {
86 # This target requires extra GAS options when building non-PIC code
87 # for linking with shared libraries.
88 set AFLAGS_NONPIC ""
89 if [istarget "mips*-*-*"] {
90 append AFLAGS_NONPIC " -call_nonpic"
91 }
92
93 # Run a test to check linking a shared library with a broken linker
94 # script that accidentally marks dynamic sections as notes. The
95 # resulting executable is not expected to work, but the linker
96 # should not seg-fault whilst creating the binary.
97 setup_xfail "tic6x-*-*"
98 run_ld_link_tests {
99 {"Build shared library for next test"
100 "-shared" "" "" "note-3.s" {} "note-3.so" }
101 {"Link using broken linker script"
102 "--script note-3.t tmpdir/note-3.so" "" "" ""
103 { { ld "note-3.l" } }
104 "a.out" }
105 }
106 setup_xfail "tic6x-*-*"
107 run_ld_link_tests {
108 {"Build pr17068.so"
109 "-shared" "" ""
110 {pr17068d.s} {} "pr17068.so"}
111 {"Build pr17068a.a"
112 "" "" ""
113 {pr17068a.s pr17068c.s pr17068ez.s} {} "pr17068a.a"}
114 {"Build pr17068b.a"
115 "" "" ""
116 {pr17068b.s pr17068e.s} {} "pr17068b.a"}
117 }
118 # bfin does not currently support copy relocs.
119 setup_xfail "bfin-*-*"
120 run_ld_link_tests {
121 {"pr17068 link --as-needed lib in group"
122 "--as-needed --no-dynamic-linker" "--start-group tmpdir/pr17068a.a tmpdir/pr17068.so tmpdir/pr17068b.a --end-group" ""
123 {start.s pr17068.s} {} "pr17068"}
124 }
125 # xfail on tic6x due to non-PIC/non-PID warnings
126 setup_xfail "tic6x-*-*"
127 # Fails on MIPS because ABI trickery means that a NULL reloc is also emitted.
128 setup_xfail "mips*-*-*"
129 # Fails on bfin because relocations are not created.
130 setup_xfail "bfin-*-*"
131 run_ld_link_tests {
132 {"-Bsymbolic-functions"
133 "-shared -Bsymbolic-functions" "" ""
134 {symbolic-func.s} {{readelf {-r --wide} symbolic-func.r}}
135 "symbolic-func.so"}
136 }
137 # xfail on tic6x due to non-PIC/non-PID warnings
138 setup_xfail "tic6x-*-*"
139 run_ld_link_tests {
140 {"Build pr20995.so"
141 "-shared" "" ""
142 {pr20995b.s} {} "pr20995.so"}
143 }
144 setup_xfail "tic6x-*-*"
145 # xfail on arm*-*-eabi*. The list can be enlarged to those targets that
146 # don't support GNU_RELRO. For more details, please see discussions at:
147 # https://sourceware.org/ml/binutils/2017-01/msg00441.html
148 setup_xfail "arm*-*-eabi*"
149 run_ld_link_tests {
150 {"Build pr20995-2.so"
151 "-shared -z relro" "" ""
152 {pr20995c.s} {{readelf {-l --wide} pr20995-2so.r}} "pr20995-2.so"}
153 }
154 # These targets don't copy dynamic variables into .bss.
155 setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*"
156 run_ld_link_tests [list \
157 [list \
158 "pr20995" \
159 "" "tmpdir/pr20995.so" "$AFLAGS_NONPIC" \
160 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995"]]
161 # xfail on arm*-*-eabi* is particularly because of no support of GNU_RELRO.
162 # Please see the link above for details.
163 setup_xfail "alpha-*-*" "bfin-*-*" "ia64-*-*" "xtensa-*-*" "arm*-*-eabi*"
164 run_ld_link_tests [list \
165 [list \
166 "pr20995-2" \
167 "" "tmpdir/pr20995-2.so" "$AFLAGS_NONPIC" \
168 {pr20995a.s} {{readelf {-S --wide} pr20995.r}} "pr20995-2"]]
169 }
170
171 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
172 foreach t $test_list {
173 # We need to strip the ".d", but can leave the dirname.
174 verbose [file rootname $t]
175 run_dump_test [file rootname $t]
176 }
177
178 # Targets using the generic linker backend don't support generating
179 # an import library.
180 set xfail_implib ""
181 if [is_generic_elf] {
182 set xfail_implib "*-*-*"
183 }
184
185 # Check that the --out-implib option work correctly.
186 run_ld_link_tests {
187 {"Generate empty import library"
188 "--out-implib=tmpdir/implib.lib" ""
189 "--defsym NO_GLOBAL=1"
190 {implib.s}
191 {{ld empty-implib.out}}
192 "implib"}
193 {"Generate import library"
194 "--out-implib=tmpdir/implib.lib" ""
195 ""
196 {implib.s}
197 {{readelf {-s tmpdir/implib.lib} implib.rd}}
198 "implib"}
199 } $xfail_implib
200
201 if { [istarget *-*-linux*]
202 || [istarget *-*-nacl*]
203 || [istarget *-*-gnu*] } {
204 run_ld_link_tests {
205 {"Weak symbols in dynamic objects 1 (support)"
206 "-shared" "" "" {weak-dyn-1a.s}
207 {}
208 "libweakdyn1a.so"}
209 {"Weak symbols in dynamic objects 1 (main test)"
210 "-shared tmpdir/libweakdyn1a.so -Tweak-dyn-1.ld" "" "" {weak-dyn-1b.s}
211 {{readelf {--relocs --wide} weak-dyn-1.rd}}
212 "libweakdyn1b.so"}
213 }
214 }
215
216 #v850 gas complains about .tbss.var section attributes.
217 if { [check_gc_sections_available] && ![istarget "v850-*-*"] } {
218 run_ld_link_tests {
219 {"--gc-sections on tls variable"
220 "--gc-section" "" "" {tls_gc.s} {} "tls_gc"}
221 }
222 }
223
224 if { [istarget *-*-*linux*]
225 || [istarget *-*-nacl*]
226 || [istarget *-*-gnu*] } {
227 run_ld_link_tests {
228 {"stack exec" "-z execstack" "" "" {stack.s}
229 {{readelf {-Wl} stack-exec.rd}} "stack-exec.exe"}
230 {"stack size" "-z stack-size=0x123400" "" "" {stack.s}
231 {{readelf {-Wl} stack-size.rd}} "stack-size.exe"}
232 }
233 }
234
235 set LDFLAGS $old_ldflags
236
237 # Check to see if the C compiler works
238 if { [which $CC] == 0 } {
239 return
240 }
241
242 if [check_gc_sections_available] {
243 run_cc_link_tests {
244 {"PR ld/13195" "-Wl,--gc-sections" ""
245 {pr13195.c} {} "pr13195"}
246 }
247 }
248
249 set array_tests {
250 {"preinit array" "" ""
251 {preinit.c} "preinit" "preinit.out"}
252 {"init array" "" ""
253 {init.c} "init" "init.out"}
254 {"fini array" "" ""
255 {fini.c} "fini" "fini.out"}
256 {"init array mixed" "" ""
257 {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
258 }
259 set array_tests_pie {
260 {"PIE preinit array" "-pie" ""
261 {preinit.c} "preinit" "preinit.out" "-fPIE"}
262 {"PIE init array" "-pie" ""
263 {init.c} "init" "init.out" "-fPIE"}
264 {"PIE fini array" "-pie" ""
265 {fini.c} "fini" "fini.out" "-fPIE"}
266 {"PIE init array mixed" "-pie" ""
267 {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
268 {"PIE PR ld/14525" "-pie" ""
269 {pr14525.c} "pr14525" "pr14525.out" "-fPIE"}
270 }
271 set array_tests_static {
272 {"static preinit array" "-static" ""
273 {preinit.c} "preinit" "preinit.out"}
274 {"static init array" "-static" ""
275 {init.c} "init" "init.out"}
276 {"static fini array" "-static" ""
277 {fini.c} "fini" "fini.out"}
278 {"static init array mixed" "-static" ""
279 {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
280 }
281
282 # NetBSD ELF systems do not currently support the .*_array sections.
283 set xfails "*-*-netbsdelf*"
284 run_ld_link_exec_tests $array_tests $xfails
285
286 if { [istarget *-*-linux*]
287 || [istarget *-*-nacl*]
288 || [istarget *-*-gnu*] } {
289 run_ld_link_exec_tests $array_tests_pie $xfails
290 }
291
292 # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>
293 # Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc.
294 switch -regexp $target_triplet {
295 ^\[^-\]*-\[^-\]*-gnu.*$ {
296 set xfails "*-*-*"
297 }
298 }
299 run_ld_link_exec_tests $array_tests_static $xfails
300
301 catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status
This page took 0.037168 seconds and 5 git commands to generate.