ld: Append -mx86-used-note=no to ASFLAGS
[deliverable/binutils-gdb.git] / ld / testsuite / ld-elf / elf.exp
1 # Expect script for various ELF tests.
2 # Copyright (C) 2002-2018 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
33 # hpux .comm differs from everyone else
34 set hpux ""
35 set old_asflags $ASFLAGS
36 if [istarget "*-*-hpux*"] {
37 set hpux "--defsym HPUX=1"
38 set ASFLAGS "$ASFLAGS --defsym HPUX=1"
39 }
40
41 if { [istarget alpha*-*-* ] } {
42 # The compress1 test is written expecting 32-bit addresses; force the
43 # executable down into the low address space to match.
44 # ??? How can we adjust just the one testcase?
45 set LDFLAGS "$LDFLAGS -Ttext-segment 0x1000000"
46 }
47
48 if { [istarget "*-*-nacl*"] } {
49 # The eh[1-4] cases are written to expect ELFCLASS64 layout on x86-64.
50 # But the target default is ELFCLASS32. So the cases explicitly use
51 # -melf_x86_64 to select that, but NaCl needs a different emulation name.
52 set options_regsub(ld) {-melf_x86_64 -melf_x86_64_nacl}
53 }
54
55 if { [istarget "*-*-solaris*"] } {
56 # Same for Solaris
57 set options_regsub(ld) {-melf_x86_64 -melf_x86_64_sol2}
58 }
59
60 if { [is_remote host] } then {
61 remote_download host merge.ld
62 }
63
64 # Note - the output file from the second test (symbol3w.a) is
65 # used in the proc is_elf64 test below...
66 run_ld_link_tests [list \
67 [list "Build symbol3.a" \
68 "" "" $hpux \
69 {symbol3.s} {} "symbol3.a" ] \
70 [list "Build symbol3w.a" \
71 "" "" "" \
72 {symbol3w.s} {} "symbol3w.a" ] \
73 ]
74
75
76 if [is_elf64 tmpdir/symbol3w.a] {
77 set ASFLAGS "$ASFLAGS --defsym ALIGN=3"
78 } else {
79 set ASFLAGS "$ASFLAGS --defsym ALIGN=2"
80 }
81
82
83
84 # Targets that use _bfd_generic_link_add_symbols won't pass pr21703 tests
85 run_ld_link_tests {
86 {"PR ld/21703"
87 "--allow-multiple-definition tmpdir/pr21703-1.o tmpdir/pr21703-2.o" "" "" \
88 {pr21703-1.s pr21703-2.s} {{readelf {-s} pr21703.sd}} "pr21703" }
89 {"PR ld/21703 -r"
90 "-r --allow-multiple-definition tmpdir/pr21703-3.o tmpdir/pr21703-4.o" "" "" \
91 {pr21703-3.s pr21703-4.s} {{readelf {-s} pr21703-r.sd}} "pr21703.o" }
92 } "d30v-*-*" "dlx-*-*" "pj-*-*" "xgate-*-*"
93
94 if [is_underscore_target] {
95 set ASFLAGS "$ASFLAGS --defsym UNDERSCORE=1"
96 }
97
98 global ASFLAGS
99 set saved_ASFLAGS "$ASFLAGS"
100 if { [istarget "i?86-*-*"] || [istarget "x86_64-*-*"] } {
101 set ASFLAGS "$ASFLAGS -mx86-used-note=no"
102 }
103
104 set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
105 foreach t $test_list {
106 # We need to strip the ".d", but can leave the dirname.
107 verbose [file rootname $t]
108 run_dump_test [file rootname $t]
109 }
110
111 set ASFLAGS "$saved_ASFLAGS"
112
113 # Targets using the generic linker backend don't support generating
114 # an import library.
115 set xfail_implib ""
116 if [is_generic_elf] {
117 set xfail_implib "*-*-*"
118 }
119
120 # Check that the --out-implib option work correctly.
121 run_ld_link_tests [list \
122 [list "Generate empty import library" \
123 "--out-implib=tmpdir/implib.lib" "" \
124 [concat "--defsym NO_GLOBAL=1" $hpux] \
125 {implib.s} \
126 {{ld empty-implib.out}} \
127 "implib" ] \
128 [list "Generate import library" \
129 "--out-implib=tmpdir/implib.lib" "" \
130 $hpux \
131 {implib.s} \
132 {{readelf {-s tmpdir/implib.lib} implib.rd}} \
133 "implib" ] \
134 ] $xfail_implib
135
136 #v850 gas complains about .tbss.var section attributes.
137 if { [check_gc_sections_available] && ![istarget "v850-*-*"] } {
138 run_ld_link_tests {
139 {"--gc-sections on tls variable"
140 "--gc-section" "" "" {tls_gc.s} {} "tls_gc"}
141 }
142 }
143
144 if { [istarget *-*-*linux*]
145 || [istarget *-*-nacl*]
146 || [istarget *-*-gnu*] } {
147 run_ld_link_tests {
148 {"stack exec" "-z execstack" "" "" {stack.s}
149 {{readelf {-Wl} stack-exec.rd}} "stack-exec.exe"}
150 {"stack noexec" "-z noexecstack" "" "" {stack.s}
151 {{readelf {-Wl} stack-noexec.rd}} "stack-noexec.exe"}
152 {"stack size" "-z stack-size=0x123400" "" "" {stack.s}
153 {{readelf {-Wl} stack-size.rd}} "stack-size.exe"}
154 }
155 }
156
157 set LDFLAGS $old_ldflags
158 set ASFLAGS $old_asflags
159
160 # Check to see if the C compiler works
161 if { [which $CC] == 0 } {
162 return
163 }
164
165 if [check_gc_sections_available] {
166 run_cc_link_tests {
167 {"PR ld/13195" "-Wl,--gc-sections" ""
168 {pr13195.c} {} "pr13195"}
169 }
170 }
171
172 set array_tests {
173 {"preinit array" "" ""
174 {preinit.c} "preinit" "preinit.out"}
175 {"init array" "" ""
176 {init.c} "init" "init.out"}
177 {"fini array" "" ""
178 {fini.c} "fini" "fini.out"}
179 {"init array mixed" "" ""
180 {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
181 }
182 set array_tests_pie {
183 {"PIE preinit array" "-pie" ""
184 {preinit.c} "preinit" "preinit.out" "-fPIE"}
185 {"PIE init array" "-pie" ""
186 {init.c} "init" "init.out" "-fPIE"}
187 {"PIE fini array" "-pie" ""
188 {fini.c} "fini" "fini.out" "-fPIE"}
189 {"PIE init array mixed" "-pie" ""
190 {init-mixed.c} "init-mixed" "init-mixed.out" "-I. -fPIE"}
191 {"PIE PR ld/14525" "-pie" ""
192 {pr14525.c} "pr14525" "pr14525.out" "-fPIE"}
193 }
194 set array_tests_static {
195 {"static preinit array" "-static" ""
196 {preinit.c} "preinit" "preinit.out"}
197 {"static init array" "-static" ""
198 {init.c} "init" "init.out"}
199 {"static fini array" "-static" ""
200 {fini.c} "fini" "fini.out"}
201 {"static init array mixed" "-static" ""
202 {init-mixed.c} "init-mixed" "init-mixed.out" "-I."}
203 }
204
205 # NetBSD ELF systems do not currently support the .*_array sections.
206 set xfails "*-*-netbsdelf*"
207 run_ld_link_exec_tests $array_tests $xfails
208
209 if { [istarget *-*-linux*]
210 || [istarget *-*-nacl*]
211 || [istarget *-*-gnu*] } {
212 run_ld_link_exec_tests $array_tests_pie $xfails
213
214 run_ld_link_exec_tests [list \
215 [list \
216 "Run mbind2a" \
217 "$NOPIE_LDFLAGS -Wl,-z,common-page-size=0x4000" \
218 "" \
219 { mbind2a.s mbind2b.c } \
220 "mbind2a" \
221 "pass.out" \
222 "-O2 -I../bfd" \
223 ] \
224 [list \
225 "Run mbind2b" \
226 "-static -Wl,-z,common-page-size=0x4000" \
227 "" \
228 { mbind2a.s mbind2b.c } \
229 "mbind2b" \
230 "pass.out" \
231 "-O2 -I../bfd" \
232 ] \
233 ]
234 }
235
236 # <http://www.gnu.org/software/hurd/open_issues/binutils.html#static>
237 # Be cautious to not XFAIL for *-*-linux-gnu*, *-*-kfreebsd-gnu*, etc.
238 switch -regexp $target_triplet {
239 ^\[^-\]*-\[^-\]*-gnu.*$ {
240 set xfails "*-*-*"
241 }
242 }
243 run_ld_link_exec_tests $array_tests_static $xfails
244
245 catch "exec rm -f tmpdir/preinit tmpdir/init tmpdir/fini tmpdir/init-mixed" status
This page took 0.036611 seconds and 5 git commands to generate.