1 # Copyright (C) 2012-2023 Free Software Foundation, Inc.
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.
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.
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.
18 # These tests should be valid on all targets.
21 # I think currently all targets fail this one when listings are enabled.
22 gas_test "p2425.s" "" "" "pcrel values in assignment"
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".
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
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
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 {
40 fail "simplifiable double subtraction"
42 gas_test "p1480.s" "" "-a>" "simplifiable double subtraction"
45 # No floating point support in assembly code for CRIS and Z80.
46 if { ![istarget cris-*-*] && ![istarget crisv32-*-*]
47 && ![istarget z80-*-*] } then {
48 if { [istarget tic4x-*-*] } then {
51 set as_opt "--defsym hasnan=1"
53 gas_test "float.s" $as_opt "" "simple FP constants"
56 # This test is meaningless for the PA; the difference of two undefined
57 # symbols is something that is (and must be) supported on the PA.
58 # The same is true for ALPHA-VMS.
60 # The AVR, MICROBLAZE, MN10300, RL78 and RX ports all support link time
61 # relaxation, which in turn allows for link time resolution of the
62 # differences of two previously undefined symbols. Hence this test will
63 # not pass for these targets.
64 if { ![istarget alpha*-*-*vms*]
65 && ![istarget am3*-*-*]
66 && ![istarget avr-*-*]
67 && ![istarget ft32-*-*]
68 && ![istarget hppa*-*-*]
69 && ![istarget microblaze-*-*]
70 && ![istarget loongarch*-*-*]
71 && ![istarget mn10300-*-*]
72 && ![istarget msp430*-*-*]
73 && ![istarget powerpc*-*-aix*]
74 && ![istarget riscv*-*-*]
75 && ![istarget rl78-*-*]
76 && ![istarget rs6000*-*-aix*]
77 && ![istarget rx-*-*] } then {
78 gas_test_error "diff1.s" "" "difference of two undefined symbols"
81 gas_test_error "equiv1.s" "" ".equiv for symbol already set to another one"
82 gas_test_error "equiv2.s" "" ".equiv for symbol already set to an expression"
84 # The inode comparison used to detect identical input and output files
85 # doesn't work on non-Posix hosts.
86 if { ![ishost "*-*-mingw*"] } then {
87 gas_test_error "none.s" "-o $srcdir/$subdir/none.s" "Output file must be distinct from input"
90 # .equ works differently on some targets.
91 switch -glob $target_triplet {
95 gas_test "equ-ok.s" "" "" ".equ for symbol already set"
96 gas_test_error "equ-bad.s" "" ".equ for symbol already set through .eqv"
100 gas_test "eqv-ok.s" "" "" ".eqv support"
101 gas_test_error "eqv-bad.s" "" ".eqv for symbol already set"
102 if { [istarget "pdp11-*-*"] } then {
103 run_dump_test eqv-dot-pdp11
105 run_dump_test eqv-dot
108 if { ![istarget "bfin-*-*"] } then {
109 gas_test "assign-ok.s" "" "" "== assignment support"
111 gas_test_error "assign-bad.s" "" "== assignment for symbol already set"
112 run_dump_test assign-bad-recursive
113 run_dump_test local-label-overflow
115 run_dump_test simple-forward
116 run_dump_test forward
118 # aout relocs are often weird, so is mep. don't bother testing
119 # som doesn't use a .text section
120 # mmix doesn't like .L1:
121 # ti addresses aren't octets.
122 if { ![is_aout_format] } {
123 switch -glob $target_triplet {
127 alpha-*-*linux*ecoff { }
142 # .set works differently on some targets.
143 # most of the tests won't work on targets that set linkrelax.
144 # 4 octet bytes confuse address matching on ti targets.
145 # pdp11 gets unexpected reloc types.
146 switch -glob $target_triplet {
165 # These targets fail redef2 because they disallow redefined
167 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
168 setup_xfail "loongarch*-*-*" "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
169 setup_xfail "avr-*-*"
171 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
172 setup_xfail "loongarch*-*-*" "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
173 setup_xfail "avr-*-*"
174 # rs6000-aix disallows redefinition via .comm.
175 if [is_xcoff_format] {
178 # These targets fail redef3 because section contents for the
179 # word referencing the .comm sym is not zero and/or its reloc
180 # has a non-zero addend. Relaxing the test would hide real
182 setup_xfail "bfin-*-*" "i\[3-7\]86-*-*coff" \
183 "i\[3-7\]86-*-*pe" "i\[3-7\]86-*-go32*" \
184 "i\[3-7\]86-*-cygwin*" "i\[3-7\]86-*-mingw*" \
185 "x86_64-*-cygwin*" "x86_64-*-mingw*"
187 gas_test_error "redef4.s" "" ".set for symbol already used as label"
188 gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
193 set testname "comment.s: comments in listings"
198 gas_start "comment.s" "-al"
200 # Apparently CRLF is received when using ptys for subprocesses; hence the
203 -re "^ +1\[ \t\]+# This\[^\n\]*\n" { set x1 1 }
204 -re "^ +2\[ \t\]+# correctly\[^\n\]*\n" { set x2 1 }
205 -re "^ +3\[ \t\]+/. C comments too. ./\r?\r?\n" { set x3 1 }
207 timeout { perror "timeout\n"; break }
212 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
217 # This test checks the output of the -ag switch. It must detect at least
218 # the name of the input file, output file, and options passed.
219 proc general_info_section {} {
220 set testname "general info section in listings"
225 gas_start "comment.s" "-agn"
228 -re "^ \[^\n\]*\t: .*\-agn\[^\n\]*\n" { set x1 1 }
229 -re "^ \[^\n\]*\t: \[^\n\]*comment\.s\[^\n\]*\n" { set x2 1 }
230 -re "^ \[^\n\]*\t: a\.out\[^\n\]*\n" { set x3 1 }
232 timeout { perror "timeout\n"; break }
237 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
243 # Test x930509a -- correct assembly of differences involving forward
248 set testname "difference between forward references"
250 gas_start "x930509.s" "-al"
252 # We need to accommodate both byte orders here.
253 # If ".long" means an 8-byte value on some target someday, this test will have
256 -re "^ +1 .... 00 ?00 ?00 ?00" { fail $testname; set x 1 }
257 -re "^ +1 .... 04 ?00 ?00 ?00" { pass $testname; set x 1 }
258 -re "^ +1 .... 00 ?00 ?00 ?04" { pass $testname; set x 1 }
260 timeout { perror "timeout\n"; break }
265 if !$x then { fail $testname }
268 # This test is meaningless for the PA and CR16/CRX: the difference of two
269 # symbols cannot be resolved by the assembler.
270 # C54x assembler (for compatibility) does not allow differences between
271 # forward references.
272 # C30 counts a four byte offset as a difference of one.
273 if { ![istarget *c30*-*-*]
274 && ![istarget *c4x*-*-*]
275 && ![istarget *c54x*-*-*]
276 && ![istarget cr16*-*-*]
277 && ![istarget crx*-*-*]
278 && ![istarget ft32-*-*]
279 && ![istarget h8300*-*-*]
280 && ![istarget hppa*-*-*] } then {
281 # msp430, mn10[23]00 and riscv emit two relocs to handle the difference of two symbols.
282 setup_xfail "am3*-*-*" "loongarch*-*-*" "mn10200-*-*" "mn10300*-*-*" "msp430*-*-*" "riscv*-*-*"
286 # ".struct" and ".align" have different meanings on c54x
287 # These directives are done in the c54x-specific tests instead
288 switch -glob $target_triplet {
299 # '<' and '>' appear to have special meanings on the excluded targets
300 switch -glob $target_triplet {
309 run_dump_test altmacro
310 # The second test is valid only when '!' is not a comment
311 # character (it is allowed to be a line comment character).
312 if [string match "" [lindex [gas_run excl.s "-o /dev/null" ""] 0]] {
313 run_dump_test altmac2
314 # Similarly this test does not work when ! is a line separator.
320 # This test is for any COFF target.
321 # We omit the ARM toolchains because they define locals to
322 # start with '.', which eliminates .eos, .text etc from the output.
323 # Omit c54x, since .tag and .def mean something different on that target
324 if { ([istarget *-*-coff*] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff]) \
325 ||([istarget *-*-pe*] && ![istarget arm*-*-pe*]) \
326 || [istarget i*86-*-aix*] \
327 || [istarget i*86-*-go32*] \
328 || [istarget i*86-*-cygwin*] \
329 || [istarget x86_64-*-mingw*] \
330 || [istarget i*86-*-*nt] \
331 || [istarget i*86-*-interix*] } {
332 run_dump_test cofftag
335 # Test omitting conditionals from listings.
341 set testname "conditional listings"
342 if { [istarget "pdp11-*-*"] } then {
343 set listing "cond-pdp11.l"
347 gas_run cond.s "-alc" ">dump.out"
348 if ![string match "" $comp_output] {
349 send_log "$comp_output\n"
352 if { [regexp_diff dump.out $srcdir/$subdir/$listing] } {
360 # This test is not suitable for the PA for various reasons
361 # not limited to the fact that it depends on specific section
362 # names appearing in the output file.
363 # Again, p2align doesn't work on c54x and related targets.
364 switch -glob $target_triplet {
365 alpha-*-linux*ecoff { }
374 remote_download host "$srcdir/$subdir/incbin.dat"
379 # Various targets use too custom handling to be able to sensibly create
380 # common expecations for this test. Also .equ works differently on some
382 if { ![istarget avr-*-*]
383 && ![istarget bfin-*-*]
384 && ![istarget cris*-*-*]
385 && ![istarget dlx-*-*]
386 && ![istarget hppa*-*-*]
387 && ![istarget m68k-*-*]
388 && ![istarget nios2-*-*]
389 && ![istarget pj-*-*]
390 && ![istarget sh*-*-*]
391 && ![istarget *c4x-*-*]
392 && ![istarget *c54x-*-*]
393 && ![istarget *c6x-*-*]
394 && ![istarget z80-*-*] } then {
395 # Some further targets' custom handling fails to recognize the overflows.
396 setup_xfail "crx-*-*" "h8300-*-*" "mcore-*-*" "mn10200-*-*" "mn10300-*-*" "msp430-*-*" "ns32k-*-*"
397 run_list_test "overflow"
400 if { ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \
401 || [istarget "i*86-*-cygwin*"] \
402 || [istarget "i*86-*-mingw32*"] } {
403 gas_test "fastcall.s" "" "" "fastcall labels"
406 if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then {
409 run_dump_test sleb128
410 run_dump_test sleb128-2
411 run_dump_test sleb128-3
412 run_dump_test sleb128-4
413 run_dump_test sleb128-5
414 # .byte is not 8 bits on either tic4x or tic54x
415 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
416 run_dump_test sleb128-7
417 run_dump_test sleb128-8
419 run_dump_test sleb128-9
421 # .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
422 # .space is different on hppa*-hpux.
423 # MeP put bytes into packets.
424 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] && ![istarget "hppa*-*-hpux*"] && ![istarget "mep*-*-*"] } {
430 # ~ isn't an operator on PDP-11
431 if { ![istarget "pdp11-*-*"] } {
435 # poor little PDP-11 can't handle 16-byte values
436 if { ![istarget "pdp11-*-*"] } {
440 # .set works differently on some targets.
441 switch -glob $target_triplet {
447 run_dump_test weakref1
448 run_dump_test weakref1g
449 run_dump_test weakref1l
450 run_dump_test weakref1u
451 run_dump_test weakref1w
454 gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c => d => e"
455 gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
456 gas_test_error "weakref4.s" "" "is already defined"
463 run_dump_test quoted-sym-names
465 # Targets where # is not a line comment character don't transform
466 # "# <line> <file>" into .linefile (PR gas/29120).
467 setup_xfail "tic30-*-*"
468 run_list_test cond-2 "-al"
469 setup_xfail "tic30-*-*"
470 run_list_test linefile ""
472 # Again, .byte does not emit 8 bits on either tic4x or tic54x.
473 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
474 run_list_test const-1 "-alm"
477 run_list_test macro "-alm"
479 run_list_test pr20312
483 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
486 # Set $nop_type appropriately to indicate the NOP instruction mnemonic.
487 # Note - this code is made obsolete by the new .nops pseudo-op.
488 switch -glob $target_triplet {
505 run_dump_test "org-1" [list [list as "--defsym nop_type=$nop_type"]]
506 run_dump_test "org-2"
507 run_dump_test "org-3"
508 run_dump_test "org-4"
509 run_dump_test "org-5"
510 run_dump_test "org-6"
512 run_dump_test "fill-1"
514 gas_test "pr23938.s" "" "" ".xstabs"
517 run_dump_test "asciz"
518 run_dump_test "pr27384"
519 run_dump_test "pr27381"
520 run_dump_test "multibyte1"
521 run_dump_test "multibyte2"