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