7d635b7edffc76a6530db8043bd10aa006280efb
[deliverable/binutils-gdb.git] / gas / testsuite / gas / all / gas.exp
1 # Copyright (C) 2012-2014 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 # These tests should be valid on all targets.
19 #
20
21 # I think currently all targets fail this one when listings are enabled.
22 gas_test "p2425.s" "" "" "pcrel values in assignment"
23
24 # p1480.s uses a ".space" directive which for most assemblers means
25 # "allocate some space". On the PA it means "switch into this space".
26 #
27 # Therefore this test (as it is currently written) is completely bogus
28 # for any PA target. Do not bother trying to run it and just claim
29 # it fails.
30 #
31 # The C54x uses ".space" to allocate bits, and requires absolute expressions;
32 # The ".space" directive is taken care of in the C54x-specific tests, so fail
33 # here
34 #
35 # The test also doesn't work on mep targets, since they use RELC, and it
36 # will avoid simplifying the expression since it conservatively assumes
37 # ugly expressions can be saved until link-time.
38 if { [istarget hppa*-*-*] || [istarget *c54x*-*-*] || [istarget mep*-*-*]} then {
39 setup_xfail *-*-*
40 fail "simplifiable double subtraction"
41 } else {
42 gas_test "p1480.s" "" "-a>" "simplifiable double subtraction"
43 }
44
45 # No floating point support in assembly code for CRIS and Z80.
46 if { ![istarget cris-*-*] && ![istarget crisv32-*-*]
47 && ![istarget z80-*-*] } then {
48 gas_test "float.s" "" "" "simple FP constants"
49 }
50
51 # This test is meaningless for the PA; the difference of two undefined
52 # symbols is something that is (and must be) supported on the PA.
53 # The same is true for alpha-vms
54 #
55 # The MN10300 port supports link time relaxation which in turn allows
56 # for link time resolution of the differneces of two symbols which are
57 # undefined at assembly time. Hence this test will not pass for the
58 # MN10300. The same thing is true for the RX port as well.
59 if { ![istarget hppa*-*-*]
60 && ![istarget alpha*-*-*vms*]
61 && ![istarget rx-*-*]
62 && ![istarget mn10300-*-*]
63 && ![istarget msp430*-*-*]
64 && ![istarget am3*-*-*] } then {
65 gas_test_error "diff1.s" "" "difference of two undefined symbols"
66 }
67
68 gas_test_error "equiv1.s" "" ".equiv for symbol already set to another one"
69 gas_test_error "equiv2.s" "" ".equiv for symbol already set to an expression"
70
71 # .equ works differently on some targets.
72 case $target_triplet in {
73 { hppa*-*-* } { }
74 { *c54x*-*-* } { }
75 default {
76 gas_test "equ-ok.s" "" "" ".equ for symbol already set"
77 gas_test_error "equ-bad.s" "" ".equ for symbol already set through .eqv"
78 }
79 }
80
81 gas_test "eqv-ok.s" "" "" ".eqv support"
82 gas_test_error "eqv-bad.s" "" ".eqv for symbol already set"
83
84 if { ![istarget "bfin-*-*"] } then {
85 gas_test "assign-ok.s" "" "" "== assignment support"
86 }
87 gas_test_error "assign-bad.s" "" "== assignment for symbol already set"
88
89 # .equ works differently on some targets.
90 # linkrelax-ing prevents most forward references from working.
91 case $target_triplet in {
92 { *c54x*-*-* } { }
93 { cr16*-*-* } { }
94 { crx*-*-* } { }
95 { h8300*-*-* } { }
96 { hppa*-*-* } { }
97 { mep-*-* } { }
98 { mn10\[23\]00*-*-* } { }
99 default {
100 # Some targets don't manage to resolve BFD_RELOC_8 for constants.
101 setup_xfail "alpha*-*-*" "*c30*-*-*" "*c4x*-*-*" \
102 "d\[13\]0v*-*-*" "i860-*-*" \
103 "nds32*-*-*" "pdp11-*-*" "xtensa*-*-*"
104 run_dump_test forward
105 }
106 }
107
108 # aout relocs are often weird, so is mep. don't bother testing
109 # som doesn't use a .text section
110 # mmix doesn't like .L1:
111 # ti addresses aren't octets.
112 if { ![is_aout_format] } {
113 case $target_triplet in {
114 { hppa*64*-*-* } {
115 run_dump_test fwdexp
116 }
117 { hppa*-*-hpux* } { }
118 { mep-*-* } { }
119 { mmix-*-* } { }
120 { nds32*-*-* } { }
121 { tic30*-*-* } { }
122 { tic4x*-*-* } { }
123 { tic54x*-*-* } { }
124 default {
125 run_dump_test fwdexp
126 }
127 }
128 }
129
130 # .set works differently on some targets.
131 # most of the tests won't work on targets that set linkrelax.
132 # 4 octet bytes confuse address matching on ti targets.
133 # pdp11 gets unexpected reloc types.
134 case $target_triplet in {
135 { alpha*-*-* } { }
136 { cr16*-*-* } { }
137 { crx*-*-* } { }
138 { h8300-*-* } { }
139 { mips*-*-* } { }
140 { mn10200-*-* } { }
141 { mn10300-*-* } { }
142 { msp430*-*-* } { }
143 { nds32*-*-* } { }
144 { pdp11-*-* } { }
145 { tic30*-*-* } { }
146 { tic4x*-*-* } { }
147 { tic54x*-*-* } { }
148 { xtensa*-*-* } { }
149 { z80-*-* } { }
150 default {
151 run_dump_test redef
152 # These targets fail redef2 because they disallow redefined
153 # symbols on relocs.
154 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*"
155 setup_xfail "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
156 run_dump_test redef2
157 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*"
158 setup_xfail "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
159 # rs6000-aix disallows redefinition via .comm.
160 setup_xfail "*-*-aix*"
161 # SOM uses a different syntax for .comm
162 setup_xfail "hppa*-*-hpux*"
163 # These targets fail redef3 because section contents for the
164 # word referencing the .comm sym is not zero and/or its reloc
165 # has a non-zero addend. Relaxing the test would hide real
166 # failures such as or32-elf.
167 setup_xfail "bfin-*-*" "i\[3-7\]86-*-*coff" \
168 "i\[3-7\]86-*-*pe" "i\[3-7\]86-*-go32*" \
169 "i\[3-7\]86-*-cygwin*" "i\[3-7\]86-*-mingw*" "x86_64-*-mingw*"
170 run_dump_test redef3
171 gas_test_error "redef4.s" "" ".set for symbol already used as label"
172 gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
173 }
174 }
175
176 proc do_comment {} {
177 set testname "comment.s: comments in listings"
178 set x1 0
179 set x2 0
180 set x3 0
181 set white {[ \t]*}
182 gas_start "comment.s" "-al"
183 while 1 {
184 # Apparently CRLF is received when using ptys for subprocesses; hence the
185 # \r\n for line 3.
186 expect {
187 -re "^ +1\[ \t\]+# This\[^\n\]*\n" { set x1 1 }
188 -re "^ +2\[ \t\]+# correctly\[^\n\]*\n" { set x2 1 }
189 -re "^ +3\[ \t\]+/. C comments too. ./\r?\r?\n" { set x3 1 }
190 -re "\[^\n\]*\n" { }
191 timeout { perror "timeout\n"; break }
192 eof { break }
193 }
194 }
195 gas_finish
196 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
197 }
198
199 # m32c pads out sections, even empty ones.
200 case $target_triplet in {
201 { m32c-*-* } { }
202 default {
203 do_comment
204 }
205 }
206
207 # This test checks the output of the -ag switch. It must detect at least
208 # the name of the input file, output file, and options passed.
209 proc general_info_section {} {
210 set testname "general info section in listings"
211 set x1 0
212 set x2 0
213 set x3 0
214 set white {[ \t]*}
215 gas_start "comment.s" "-agn"
216 while 1 {
217 expect {
218 -re "^ \[^\n\]*\t: .*\-agn\[^\n\]*\n" { set x1 1 }
219 -re "^ \[^\n\]*\t: \[^\n\]*comment\.s\[^\n\]*\n" { set x2 1 }
220 -re "^ \[^\n\]*\t: a\.out\[^\n\]*\n" { set x3 1 }
221 -re "\[^\n\]*\n" { }
222 timeout { perror "timeout\n"; break }
223 eof { break }
224 }
225 }
226 gas_finish
227 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
228 }
229
230 general_info_section
231
232 #
233 # Test x930509a -- correct assembly of differences involving forward
234 # references.
235 #
236
237 proc do_930509a {} {
238 set testname "difference between forward references"
239 set x 0
240 gas_start "x930509.s" "-al"
241 while 1 {
242 # We need to accomodate both byte orders here.
243 # If ".long" means an 8-byte value on some target someday, this test will have
244 # to be fixed.
245 expect {
246 -re "^ +1 .... 00 ?00 ?00 ?00" { fail $testname; set x 1 }
247 -re "^ +1 .... 04 ?00 ?00 ?00" { pass $testname; set x 1 }
248 -re "^ +1 .... 00 ?00 ?00 ?04" { pass $testname; set x 1 }
249 -re "\[^\n\]*\n" { }
250 timeout { perror "timeout\n"; break }
251 eof { break }
252 }
253 }
254 gas_finish
255 if !$x then { fail $testname }
256 }
257
258 # This test is meaningless for the PA and CR16/CRX: the difference of two
259 # symbols cannot be resolved by the assembler.
260 # C54x assembler (for compatibility) does not allow differences between
261 # forward references.
262 # C30 counts a four byte offset as a difference of one.
263 if { ![istarget hppa*-*-*] &&
264 ![istarget cr16*-*-*] &&
265 ![istarget crx*-*-*] &&
266 ![istarget *c30*-*-*] &&
267 ![istarget *c4x*-*-*] &&
268 ![istarget *c54x*-*-*] } then {
269 # the vax fails because VMS can apparently actually handle this
270 # case in relocs, so gas doesn't handle it itself.
271 # msp430 and mn10300 emit two relocs to handle the difference of two symbols.
272 setup_xfail "mn10300*-*-*" "msp430*-*-*" "vax*-*-vms*"
273 do_930509a
274 }
275
276 # ".struct" and ".align" have different meanings on c54x
277 # These directives are done in the c54x-specific tests instead
278 case $target_triplet in {
279 { hppa*-*-* } { }
280 { *c4x*-*-* } { }
281 { *c54x*-*-* } { }
282 default {
283 run_dump_test struct
284 run_dump_test align
285 run_dump_test align2
286 }
287 }
288
289 # '<' and '>' appear to have special meanings on the excluded targets
290 case $target_triplet in {
291 { frv-*-* } { }
292 { hppa*-*-* } { }
293 { m32r-*-* } { }
294 { mmix-*-* } { }
295 { *c4x*-*-* } { }
296 { *c54x*-*-* } { }
297 { bfin-*-* } { }
298 default {
299 run_dump_test altmacro
300 # The second test is valid only when '!' is not a comment
301 # character (it is allowed to be a line comment character).
302 if [string match "" [lindex [gas_run excl.s "-o /dev/null" ""] 0]] {
303 run_dump_test altmac2
304 # Similarly this test does not work when ! is a line seperator.
305 run_dump_test eval
306 }
307 }
308 }
309
310 # This test is for any COFF target.
311 # We omit the ARM toolchains because they define locals to
312 # start with '.', which eliminates .eos, .text etc from the output.
313 # Omit c54x, since .tag and .def mean something different on that target
314 if { ([istarget *-*-coff*] && ![istarget arm*-*-coff] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff]) \
315 ||([istarget *-*-pe*] && ![istarget arm*-*-pe*]) \
316 || [istarget i*86-*-aix*] \
317 || [istarget i*86-*-sco*] \
318 || [istarget i*86-*-isc*] \
319 || [istarget i*86-*-go32*] \
320 || [istarget i*86-*-cygwin*] \
321 || [istarget x86_64-*-mingw*] \
322 || [istarget i*86-*-*nt] \
323 || [istarget i*86-*-interix*] \
324 || ([istarget i960-*-vxworks5.*] && ![istarget i960-*-vxworks5.0*]) } {
325 run_dump_test cofftag
326 }
327
328 # Test omitting conditionals from listings.
329 proc test_cond {} {
330 global comp_output
331 global srcdir
332 global subdir
333
334 set testname "conditional listings"
335 gas_run cond.s "-alc" ">dump.out"
336 if ![string match "" $comp_output] {
337 send_log "$comp_output\n"
338 fail $testname
339 } else {
340 if { [regexp_diff dump.out $srcdir/$subdir/cond.l] } {
341 fail $testname
342 } else {
343 pass $testname
344 }
345 }
346 }
347
348 # This test is not suitable for the PA for various reasons
349 # not limited to the fact that it depends on specific section
350 # names appearing in the output file.
351 # again, p2align doesn't work on c54x target
352 case $target_triplet in {
353 { hppa*-*-* } { }
354 { *c4x*-*-* } { }
355 { *c54x*-*-* } { }
356 { rx-*-* } { }
357 default {
358 test_cond
359 remote_download host "$srcdir/$subdir/incbin.dat"
360 run_dump_test incbin
361 }
362 }
363
364 if { ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \
365 || [istarget "i*86-*-cygwin*"] \
366 || [istarget "i*86-*-mingw32*"] } {
367 gas_test "fastcall.s" "" "" "fastcall labels"
368 }
369
370 if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then {
371 run_dump_test assign
372 }
373 run_dump_test sleb128
374 run_dump_test sleb128-2
375 run_dump_test sleb128-3
376 setup_xfail "nds32*-*-*"
377 run_dump_test sleb128-4
378 run_dump_test sleb128-5
379 # .byte is not 8 bits on either tic4x or tic54x
380 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
381 run_dump_test sleb128-7
382 }
383
384 # .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
385 # .space is different on hppa*-hpux.
386 # MeP put bytes into packets.
387 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] && ![istarget "hppa*-*-hpux*"] && ![istarget "mep*-*-*"] } {
388 run_dump_test relax
389 }
390
391 # powerpc and s390 allow a string argument to .byte
392 if { ![istarget "powerpc*-*-*"] && ![istarget "rs6000*-*-*"] && ![istarget "s390*-*-*"] } {
393 run_dump_test byte
394 }
395
396 # .quad is 16 bytes on i960.
397 if { ![istarget "i960-*-*"] } {
398 run_dump_test quad
399 }
400
401 # som doesn't use .data section.
402 case $target_triplet in {
403 { hppa*64*-*-* } {
404 run_dump_test octa
405 }
406 { hppa*-*-hpux* } { }
407 default {
408 run_dump_test octa
409 }
410 }
411
412 # .set works differently on some targets.
413 case $target_triplet in {
414 { alpha*-*-* } { }
415 { mips*-*-* } { }
416 { *c54x*-*-* } { }
417 { z80-*-* } { }
418 default {
419 setup_xfail "nds32*-*-*"
420 run_dump_test weakref1
421 run_dump_test weakref1g
422 run_dump_test weakref1l
423 run_dump_test weakref1u
424 run_dump_test weakref1w
425 }
426 }
427 gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c => d => e"
428 gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
429 gas_test_error "weakref4.s" "" "is already defined"
430
431 run_dump_test string
432
433 load_lib gas-dg.exp
434 dg-init
435 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
436 dg-finish
This page took 0.098696 seconds and 3 git commands to generate.