31026e4148e229d2996cf03b68e0fed51140432e
[deliverable/binutils-gdb.git] / gas / testsuite / gas / elf / elf.exp
1 # Copyright (C) 2012-2020 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
16
17 #
18 # elf tests
19 #
20
21 proc run_elf_list_test { name suffix opts readelf_opts readelf_pipe } {
22 global READELF
23 global srcdir subdir
24 set testname "elf $name list"
25 set file $srcdir/$subdir/$name
26 gas_run ${name}.s "$opts -o dump.o" ">&dump.out"
27 if { ![string match "" $opts]
28 && [regexp_diff "dump.out" "${file}.l"] } then {
29 fail $testname
30 verbose "output is [file_contents "dump.out"]" 2
31 return
32 }
33 send_log "$READELF $readelf_opts dump.o $readelf_pipe > dump.out\n"
34 set status [gas_host_run "$READELF $readelf_opts dump.o" ">readelf.out"]
35 if { [lindex $status 0] != 0 || ![string match "" [lindex $status 1]] } then {
36 send_log "[lindex $status 1]\n"
37 fail $testname
38 return
39 }
40 catch "exec cat readelf.out $readelf_pipe > dump.out\n" comp_output
41 if ![string match "" $comp_output] then {
42 send_log "$comp_output\n"
43 fail $testname
44 return
45 }
46 verbose_eval {[file_contents "dump.out"]} 3
47 if { [regexp_diff "dump.out" "${file}.e${suffix}"] } then {
48 fail $testname
49 verbose "output is [file_contents "dump.out"]" 2
50 return
51 }
52 pass $testname
53 }
54
55 # We're testing bits in obj-elf -- don't run on anything else.
56 if { [is_elf_format] } then {
57 set target_machine ""
58 set dump_opts ""
59 if {[istarget "arc*-*-*"]} {
60 set target_machine -arc
61 }
62 if {[istarget "arm*-*-*"]} {
63 set target_machine -arm
64 }
65 if {[istarget "avr*-*-*"]} {
66 set dump_opts {{as -mno-link-relax}}
67 }
68 if {[istarget "m32r*-*-*"]} then {
69 set target_machine -m32r
70 }
71 if {[istarget "mips*-*-*"]} then {
72 set target_machine -mips
73 }
74 if {[istarget "msp430-*-*"]} then {
75 set target_machine -msp430
76 }
77 if {[istarget "pru-*-*"]} {
78 set dump_opts {{as -mno-link-relax}}
79 }
80 if {[istarget "riscv*-*-*"]} then {
81 set target_machine -riscv
82 set dump_opts {{as -mno-relax}}
83 }
84 if {[istarget "rl78-*-*"]} then {
85 set target_machine -rl78
86 }
87 if {[istarget "rx-*-*"]} then {
88 set target_machine -rx
89 }
90 if {[istarget "score-*-*"]} then {
91 set target_machine -score
92 }
93 if {[istarget "tic6x-*-*"]} then {
94 set target_machine -tic6x
95 }
96 if {[istarget "v850*-*-*"]} then {
97 set target_machine -v850
98 }
99 if {[istarget "xtensa*-*-*"]} then {
100 set target_machine -xtensa
101 set dump_opts {{as --no-link-relax}}
102 }
103
104 # The MN10300 and Xtensa ports disable the assembler's call frame
105 # optimization because it interfers with link-time relaxation of
106 # function prologues.
107 if {![istarget "mn10300-*-*"]
108 && ![istarget "am3*-*-*"]
109 && ![istarget "xtensa*-*-*"]
110 && ![istarget "msp430*-*-*"]
111 && ![istarget "nds32*-*-*"]
112 && ![istarget "am3*-*-*"]} then {
113 run_dump_test "ehopt0"
114 }
115 switch -glob $target_triplet {
116 m68k-*-* -
117 m68[03]??-*-* {
118 run_dump_test "file" { { as "--defsym m68k=1" } }
119 }
120 mmix-*-* {
121 run_dump_test "file" { { as "--defsym mmix=1" } }
122 }
123 xtensa*-*-* {
124 run_dump_test "file" { { as "--rename-section file.s=file.c" } }
125 }
126 default {
127 run_dump_test "file"
128 }
129 }
130 run_dump_test "file-2"
131 setup_xfail "nds32*-*-*"
132 run_dump_test "group0a"
133 run_dump_test "group0b"
134 run_dump_test "group0c"
135 run_dump_test "group1a"
136 run_dump_test "group1b"
137 run_dump_test "group2"
138 run_dump_test "group3"
139 switch -glob $target_triplet {
140 hppa64*-*-hpux* { }
141 riscv*-*-* { }
142 default {
143 run_dump_test "groupautoa"
144 }
145 }
146 switch -glob $target_triplet {
147 hppa64*-*-hpux* { }
148 riscv*-*-* { }
149 xtensa*-*-* { }
150 default {
151 run_dump_test "groupautob"
152 }
153 }
154 switch -glob $target_triplet {
155 alpha*-*-* { }
156 am3*-*-* { }
157 *c54x*-*-* { }
158 cr16*-*-* { }
159 crx*-*-* { }
160 h8300-*-* { }
161 hppa*-*-* { }
162 iq2000*-*-* { }
163 mips*-*-* { }
164 mn10200-*-* { }
165 mn10300-*-* { }
166 msp43*-*-* { }
167 rl78-*-* { }
168 riscv*-*-* { }
169 rx-*-* { }
170 default {
171 # The next test can fail if the target does not convert fixups
172 # against ordinary symbols into relocations against section symbols.
173 # This is usually revealed by the error message:
174 # symbol `sym' required but not present
175 setup_xfail "m681*-*-*" "m68hc*-*-*" "xgate-*-*" "vax-*-*"
176 run_dump_test redef
177 run_dump_test equ-reloc
178 }
179 }
180 run_dump_test "pseudo"
181 run_dump_test "section0"
182 run_dump_test "section1"
183 # The h8300 port issues a warning message for
184 # new sections created without atrributes.
185 if {! [istarget "h8300-*-*"]} then {
186 set as_flags "-al --generate-missing-build-notes=no"
187 switch -glob $target_triplet {
188 i*86-*-* -
189 x86_64-*-* {
190 set as_flags "$as_flags -mx86-used-note=no"
191 }
192 riscv*-*-* {
193 set as_flags "$as_flags -march-attr"
194 }
195 }
196 run_elf_list_test "section2" "$target_machine" "$as_flags" "-s" ""
197 }
198 run_dump_test "section3"
199 run_dump_test "section4"
200 if {! [istarget "h8300-*-*"] && ! [istarget "rx-*-*"]} then {
201 # The h8300 port issues a warning message for
202 # new sections created without atrributes.
203 # The RX port does not complain about changing the attributes of the
204 # .data and .bss sections since it does not use those names.
205 run_elf_list_test "section5" "" "-al -Z" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
206 }
207 run_dump_test "struct"
208 if { ![istarget "alpha*-*-*"] } then {
209 # The alpha port uses .set for state, e.g. nomacro.
210 run_dump_test "symtab"
211 }
212 run_dump_test "symver"
213 run_dump_test "pr21661"
214 run_dump_test "pr14891"
215
216 # No indirect functions on non-GNU targets.
217 # The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
218 # The non-eabi ARM ports sets it to ELFOSABI_ARM.
219 # So for these targets we cannot include an IFUNC symbol type
220 # in the symbol type test.
221 # We also need to exclude targets that do not support unique objects.
222 if { [istarget "*-*-hpux*"]
223 || [istarget "arm*-*-*"]
224 || [istarget "mips*-*-*"]
225 || [istarget "msp*-*-*"]
226 || [istarget "visium-*-*"]
227 || ![supports_gnu_unique]
228 } then {
229 # hppa64 has a non-standard common directive
230 if { ![istarget "hppa64*-*-hpux*"] } then {
231 run_elf_list_test "type-noifunc" "" "" "-s" "| grep \"1 *\\\[FONTC\\\]\""
232 }
233 } else {
234 run_dump_test ifunc-1
235 run_elf_list_test "type" "" "" "-s" "| grep \"1 *\\\[FIONTCU\\\]\""
236 run_elf_list_test "type-2" "" "--warn" "-s" "| grep \"0 *\\\[FIONT\\\]\""
237 }
238
239 run_dump_test "section6"
240 run_dump_test "section7"
241 run_dump_test "section8"
242 run_dump_test "section9"
243 run_dump_test "section10"
244 run_dump_test "section11"
245 run_dump_test "section12a"
246 run_dump_test "section12b"
247 run_dump_test "section13"
248 run_dump_test "section14"
249 run_dump_test "section15"
250 run_dump_test "section16a"
251 run_dump_test "section16b"
252 run_dump_test "section17"
253 run_dump_test "section18"
254 run_dump_test "section19"
255 run_dump_test "section20"
256 run_dump_test "section21"
257 run_dump_test "dwarf2-1" $dump_opts
258 run_dump_test "dwarf2-2" $dump_opts
259 run_dump_test "dwarf2-3" $dump_opts
260 run_dump_test "dwarf2-4" $dump_opts
261 run_dump_test "dwarf2-5" $dump_opts
262 run_dump_test "dwarf2-6" $dump_opts
263 run_dump_test "dwarf2-7" $dump_opts
264 run_dump_test "dwarf2-8" $dump_opts
265 run_dump_test "dwarf2-9" $dump_opts
266 run_dump_test "dwarf2-10" $dump_opts
267 run_dump_test "dwarf2-11" $dump_opts
268 run_dump_test "dwarf2-12" $dump_opts
269 run_dump_test "dwarf2-13" $dump_opts
270 run_dump_test "dwarf2-14" $dump_opts
271 run_dump_test "dwarf2-15" $dump_opts
272 run_dump_test "dwarf2-16" $dump_opts
273 run_dump_test "dwarf2-17" $dump_opts
274 run_dump_test "dwarf2-18" $dump_opts
275 run_dump_test "dwarf2-19" $dump_opts
276 run_dump_test "dwarf-5-file0" $dump_opts
277 run_dump_test "bss"
278 run_dump_test "bad-bss"
279 run_dump_test "bad-section-flag"
280 run_dump_test "bad-size"
281 run_dump_test "bad-group"
282
283 run_dump_test "syms"
284
285 run_dump_test "missing-build-notes"
286
287 run_dump_test "common1"
288 run_dump_test "common2"
289
290 # hpux has a non-standard common directive.
291 if { ![istarget "*-*-hpux*"] } then {
292 run_dump_test "common3a"
293 run_dump_test "common3b"
294 run_dump_test "common4a"
295 run_dump_test "common4b"
296 run_dump_test "common5a"
297 run_dump_test "common5b"
298 run_dump_test "common5c"
299 run_dump_test "common5d"
300 }
301
302 run_dump_test "strtab"
303
304 run_dump_test "bignums"
305
306 load_lib gas-dg.exp
307 dg-init
308 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
309 dg-finish
310 }
This page took 0.03516 seconds and 3 git commands to generate.