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