This patch introduces support for specifing views in .loc directives, so that the...
[deliverable/binutils-gdb.git] / gas / testsuite / gas / all / gas.exp
CommitLineData
2571583a 1# Copyright (C) 2012-2017 Free Software Foundation, Inc.
5bf135a7
NC
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
252b5132
RH
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.
22gas_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.
39bec121
TW
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#
280d71bf
DB
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.
38if { [istarget hppa*-*-*] || [istarget *c54x*-*-*] || [istarget mep*-*-*]} then {
252b5132
RH
39 setup_xfail *-*-*
40 fail "simplifiable double subtraction"
41} else {
42 gas_test "p1480.s" "" "-a>" "simplifiable double subtraction"
43}
44
3c9b82ba
NC
45# No floating point support in assembly code for CRIS and Z80.
46if { ![istarget cris-*-*] && ![istarget crisv32-*-*]
47 && ![istarget z80-*-*] } then {
483f05e3
HPN
48 gas_test "float.s" "" "" "simple FP constants"
49}
252b5132
RH
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.
3ee6e4fb 53# The same is true for ALPHA-VMS.
569006e5 54#
3ee6e4fb
NC
55# The AVR, MICROBLAZE, MN10300, RL78 and RX ports all support link time
56# relaxation, which in turn allows for link time resolution of the
57# differences of two previously undefined symbols. Hence this test will
58# not pass for these targets.
59if { ![istarget alpha*-*-*vms*]
60 && ![istarget am3*-*-*]
edc9e9a6 61 && ![istarget avr-*-*]
3ee6e4fb
NC
62 && ![istarget hppa*-*-*]
63 && ![istarget microblaze-*-*]
c7927a3c 64 && ![istarget mn10300-*-*]
13761a11 65 && ![istarget msp430*-*-*]
3ee6e4fb
NC
66 && ![istarget rl78-*-*]
67 && ![istarget rx-*-*] } then {
252b5132
RH
68 gas_test_error "diff1.s" "" "difference of two undefined symbols"
69}
70
9497f5ac
NC
71gas_test_error "equiv1.s" "" ".equiv for symbol already set to another one"
72gas_test_error "equiv2.s" "" ".equiv for symbol already set to an expression"
73
74# .equ works differently on some targets.
75case $target_triplet in {
76 { hppa*-*-* } { }
77 { *c54x*-*-* } { }
78 default {
79 gas_test "equ-ok.s" "" "" ".equ for symbol already set"
80 gas_test_error "equ-bad.s" "" ".equ for symbol already set through .eqv"
81 }
82}
83
84gas_test "eqv-ok.s" "" "" ".eqv support"
85gas_test_error "eqv-bad.s" "" ".eqv for symbol already set"
86
3f904b16
AM
87if { ![istarget "bfin-*-*"] } then {
88 gas_test "assign-ok.s" "" "" "== assignment support"
89}
9497f5ac
NC
90gas_test_error "assign-bad.s" "" "== assignment for symbol already set"
91
92# .equ works differently on some targets.
93# linkrelax-ing prevents most forward references from working.
94case $target_triplet in {
ec0c103c 95 { *c54x*-*-* } { }
3ccac826 96 { cr16*-*-* } { }
9497f5ac
NC
97 { crx*-*-* } { }
98 { h8300*-*-* } { }
99 { hppa*-*-* } { }
ec0c103c 100 { mep-*-* } { }
3ee6e4fb 101 { microblaze-*-* } { }
9497f5ac 102 { mn10\[23\]00*-*-* } { }
9497f5ac
NC
103 default {
104 # Some targets don't manage to resolve BFD_RELOC_8 for constants.
c4990c4b 105 setup_xfail "alpha*-*-*" "*c30*-*-*" "*c4x*-*-*" \
d56a8dda 106 "d\[13\]0v*-*-*" "i860-*-*" \
35c08157 107 "nds32*-*-*" "pdp11-*-*" "xtensa*-*-*"
9497f5ac
NC
108 run_dump_test forward
109 }
110}
111
e8044f35 112# aout relocs are often weird, so is mep. don't bother testing
f9022510
AM
113# som doesn't use a .text section
114# mmix doesn't like .L1:
115# ti addresses aren't octets.
116if { ![is_aout_format] } {
117 case $target_triplet in {
01c51e44
DA
118 { hppa*64*-*-* } {
119 run_dump_test fwdexp
120 }
3ee6e4fb
NC
121 { alpha-*-*linux*ecoff } { }
122 { alpha-*-osf* } { }
01c51e44 123 { hppa*-*-hpux* } { }
f9022510 124 { mep-*-* } { }
f9022510 125 { mmix-*-* } { }
35c08157 126 { nds32*-*-* } { }
f9022510
AM
127 { tic30*-*-* } { }
128 { tic4x*-*-* } { }
129 { tic54x*-*-* } { }
130 default {
131 run_dump_test fwdexp
132 }
133 }
134}
135
9497f5ac 136# .set works differently on some targets.
f42fb574
AM
137# most of the tests won't work on targets that set linkrelax.
138# 4 octet bytes confuse address matching on ti targets.
139# pdp11 gets unexpected reloc types.
9497f5ac
NC
140case $target_triplet in {
141 { alpha*-*-* } { }
f42fb574
AM
142 { cr16*-*-* } { }
143 { crx*-*-* } { }
144 { h8300-*-* } { }
9497f5ac 145 { mips*-*-* } { }
f42fb574
AM
146 { mn10200-*-* } { }
147 { mn10300-*-* } { }
13761a11 148 { msp430*-*-* } { }
35c08157 149 { nds32*-*-* } { }
f42fb574
AM
150 { pdp11-*-* } { }
151 { tic30*-*-* } { }
152 { tic4x*-*-* } { }
153 { tic54x*-*-* } { }
154 { xtensa*-*-* } { }
3c9b82ba 155 { z80-*-* } { }
9497f5ac 156 default {
9497f5ac 157 run_dump_test redef
3ee6e4fb 158 setup_xfail "arm-epoc-pe*"
8b0aac0f
AM
159 # These targets fail redef2 because they disallow redefined
160 # symbols on relocs.
3ee6e4fb 161 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
e23eba97 162 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
5ca0ee01 163 run_dump_test redef2
3ee6e4fb 164 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
e23eba97 165 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
8b0aac0f
AM
166 # rs6000-aix disallows redefinition via .comm.
167 setup_xfail "*-*-aix*"
168 # SOM uses a different syntax for .comm
169 setup_xfail "hppa*-*-hpux*"
170 # These targets fail redef3 because section contents for the
171 # word referencing the .comm sym is not zero and/or its reloc
172 # has a non-zero addend. Relaxing the test would hide real
73589c9d 173 # failures.
8b0aac0f
AM
174 setup_xfail "bfin-*-*" "i\[3-7\]86-*-*coff" \
175 "i\[3-7\]86-*-*pe" "i\[3-7\]86-*-go32*" \
3ee6e4fb
NC
176 "i\[3-7\]86-*-cygwin*" "i\[3-7\]86-*-mingw*" \
177 "x86_64-*-cygwin*" "x86_64-*-mingw*"
92757bc9 178 run_dump_test redef3
92757bc9 179 gas_test_error "redef4.s" "" ".set for symbol already used as label"
92757bc9 180 gas_test_error "redef5.s" "" ".set for symbol already defined through .comm"
9497f5ac
NC
181 }
182}
183
252b5132
RH
184proc do_comment {} {
185 set testname "comment.s: comments in listings"
186 set x1 0
187 set x2 0
188 set x3 0
189 set white {[ \t]*}
190 gas_start "comment.s" "-al"
191 while 1 {
192# Apparently CRLF is received when using ptys for subprocesses; hence the
193# \r\n for line 3.
194 expect {
195 -re "^ +1\[ \t\]+# This\[^\n\]*\n" { set x1 1 }
196 -re "^ +2\[ \t\]+# correctly\[^\n\]*\n" { set x2 1 }
7f6a71ff 197 -re "^ +3\[ \t\]+/. C comments too. ./\r?\r?\n" { set x3 1 }
252b5132
RH
198 -re "\[^\n\]*\n" { }
199 timeout { perror "timeout\n"; break }
200 eof { break }
201 }
202 }
203 gas_finish
204 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
205}
206
bad6899a
AM
207# m32c pads out sections, even empty ones.
208case $target_triplet in {
209 { m32c-*-* } { }
210 default {
211 do_comment
212 }
213}
252b5132 214
83f10cb2
NC
215# This test checks the output of the -ag switch. It must detect at least
216# the name of the input file, output file, and options passed.
217proc general_info_section {} {
218 set testname "general info section in listings"
219 set x1 0
220 set x2 0
221 set x3 0
222 set white {[ \t]*}
223 gas_start "comment.s" "-agn"
224 while 1 {
225 expect {
c7927a3c 226 -re "^ \[^\n\]*\t: .*\-agn\[^\n\]*\n" { set x1 1 }
83f10cb2
NC
227 -re "^ \[^\n\]*\t: \[^\n\]*comment\.s\[^\n\]*\n" { set x2 1 }
228 -re "^ \[^\n\]*\t: a\.out\[^\n\]*\n" { set x3 1 }
229 -re "\[^\n\]*\n" { }
230 timeout { perror "timeout\n"; break }
231 eof { break }
232 }
233 }
234 gas_finish
235 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
236}
237
238general_info_section
239
252b5132
RH
240#
241# Test x930509a -- correct assembly of differences involving forward
242# references.
243#
244
245proc do_930509a {} {
246 set testname "difference between forward references"
247 set x 0
248 gas_start "x930509.s" "-al"
249 while 1 {
c29ae970 250# We need to accommodate both byte orders here.
252b5132
RH
251# If ".long" means an 8-byte value on some target someday, this test will have
252# to be fixed.
253 expect {
224de7a5
AM
254 -re "^ +1 .... 00 ?00 ?00 ?00" { fail $testname; set x 1 }
255 -re "^ +1 .... 04 ?00 ?00 ?00" { pass $testname; set x 1 }
256 -re "^ +1 .... 00 ?00 ?00 ?04" { pass $testname; set x 1 }
252b5132
RH
257 -re "\[^\n\]*\n" { }
258 timeout { perror "timeout\n"; break }
259 eof { break }
260 }
261 }
262 gas_finish
263 if !$x then { fail $testname }
264}
265
3ccac826
NC
266# This test is meaningless for the PA and CR16/CRX: the difference of two
267# symbols cannot be resolved by the assembler.
39bec121 268# C54x assembler (for compatibility) does not allow differences between
3ccac826 269# forward references.
8bda4946 270# C30 counts a four byte offset as a difference of one.
3ee6e4fb
NC
271if { ![istarget *c30*-*-*]
272 && ![istarget *c4x*-*-*]
273 && ![istarget *c54x*-*-*]
274 && ![istarget cr16*-*-*]
275 && ![istarget crx*-*-*]
276 && ![istarget h8300*-*-*]
277 && ![istarget hppa*-*-*] } then {
278 # The vax fails because VMS can apparently actually handle this
252b5132 279 # case in relocs, so gas doesn't handle it itself.
e23eba97
NC
280 # msp430, mn10[23]00 and riscv emit two relocs to handle the difference of two symbols.
281 setup_xfail "mn10200-*-*" "mn10300*-*-*" "msp430*-*-*" "riscv*-*-*" "vax*-*-vms*"
252b5132
RH
282 do_930509a
283}
284
39bec121
TW
285# ".struct" and ".align" have different meanings on c54x
286# These directives are done in the c54x-specific tests instead
252b5132
RH
287case $target_triplet in {
288 { hppa*-*-* } { }
48c5eb8a 289 { *c4x*-*-* } { }
39bec121 290 { *c54x*-*-* } { }
252b5132
RH
291 default {
292 run_dump_test struct
293 run_dump_test align
3ee6e4fb 294 setup_xfail "ns32k-*-*"
76101304 295 run_dump_test align2
252b5132
RH
296 }
297}
298
5069eab2
NC
299# '<' and '>' appear to have special meanings on the excluded targets
300case $target_triplet in {
5069eab2
NC
301 { frv-*-* } { }
302 { hppa*-*-* } { }
303 { m32r-*-* } { }
304 { mmix-*-* } { }
305 { *c4x*-*-* } { }
306 { *c54x*-*-* } { }
8df55cb8 307 { bfin-*-* } { }
5069eab2
NC
308 default {
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).
26a78d4a 312 if [string match "" [lindex [gas_run excl.s "-o /dev/null" ""] 0]] {
5069eab2 313 run_dump_test altmac2
c29ae970 314 # Similarly this test does not work when ! is a line separator.
9497f5ac 315 run_dump_test eval
5069eab2
NC
316 }
317 }
318}
caa32fe5 319
252b5132 320# This test is for any COFF target.
252b5132
RH
321# We omit the ARM toolchains because they define locals to
322# start with '.', which eliminates .eos, .text etc from the output.
39bec121 323# Omit c54x, since .tag and .def mean something different on that target
8c5fc800
JM
324if { ([istarget *-*-coff*] && ![istarget arm*-*-coff] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff]) \
325 ||([istarget *-*-pe*] && ![istarget arm*-*-pe*]) \
252b5132
RH
326 || [istarget i*86-*-aix*] \
327 || [istarget i*86-*-sco*] \
328 || [istarget i*86-*-isc*] \
329 || [istarget i*86-*-go32*] \
330 || [istarget i*86-*-cygwin*] \
42037fe5 331 || [istarget x86_64-*-mingw*] \
252b5132 332 || [istarget i*86-*-*nt] \
61feeec2 333 || [istarget i*86-*-interix*] \
252b5132
RH
334 || ([istarget i960-*-vxworks5.*] && ![istarget i960-*-vxworks5.0*]) } {
335 run_dump_test cofftag
336}
337
338# Test omitting conditionals from listings.
339proc test_cond {} {
340 global comp_output
341 global srcdir
342 global subdir
343
344 set testname "conditional listings"
224de7a5 345 gas_run cond.s "-alc" ">dump.out"
252b5132
RH
346 if ![string match "" $comp_output] {
347 send_log "$comp_output\n"
348 fail $testname
349 } else {
eb22018c 350 if { [regexp_diff dump.out $srcdir/$subdir/cond.l] } {
252b5132
RH
351 fail $testname
352 } else {
353 pass $testname
354 }
355 }
356}
357
c8060cba
JL
358# This test is not suitable for the PA for various reasons
359# not limited to the fact that it depends on specific section
360# names appearing in the output file.
3ee6e4fb 361# Again, p2align doesn't work on c54x and related targets.
aceebfd6 362case $target_triplet in {
3ee6e4fb
NC
363 { alpha-*-linux*ecoff} { }
364 { alpha-*-osf*} { }
aceebfd6 365 { hppa*-*-* } { }
48c5eb8a 366 { *c4x*-*-* } { }
aceebfd6 367 { *c54x*-*-* } { }
3ee6e4fb 368 { rl78-*-* } { }
c7927a3c 369 { rx-*-* } { }
aceebfd6
NC
370 default {
371 test_cond
7f6a71ff 372 remote_download host "$srcdir/$subdir/incbin.dat"
aceebfd6
NC
373 run_dump_test incbin
374 }
39bec121 375}
c9e38879 376
01ed09aa 377if { ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \
b46c1691
NC
378 || [istarget "i*86-*-cygwin*"] \
379 || [istarget "i*86-*-mingw32*"] } {
380 gas_test "fastcall.s" "" "" "fastcall labels"
381}
a7eec876 382
35c08157 383if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then {
3f904b16
AM
384 run_dump_test assign
385}
e5604d79 386run_dump_test sleb128
956a6ba3
JB
387run_dump_test sleb128-2
388run_dump_test sleb128-3
35c08157 389setup_xfail "nds32*-*-*"
956a6ba3
JB
390run_dump_test sleb128-4
391run_dump_test sleb128-5
4455e9ad
JB
392# .byte is not 8 bits on either tic4x or tic54x
393if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
394 run_dump_test sleb128-7
1a94eb29 395 run_dump_test sleb128-8
4455e9ad 396}
ba8826a8 397run_dump_test sleb128-9
ddc07134 398
5e9ed83f 399# .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
17b939cd 400# .space is different on hppa*-hpux.
ec0c103c
NC
401# MeP put bytes into packets.
402if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] && ![istarget "hppa*-*-hpux*"] && ![istarget "mep*-*-*"] } {
5e9ed83f
L
403 run_dump_test relax
404}
405
af47cd43
AK
406# powerpc and s390 allow a string argument to .byte
407if { ![istarget "powerpc*-*-*"] && ![istarget "rs6000*-*-*"] && ![istarget "s390*-*-*"] } {
9e59393e
AM
408 run_dump_test byte
409}
847d4311 410
ddc07134
AM
411# .quad is 16 bytes on i960.
412if { ![istarget "i960-*-*"] } {
413 run_dump_test quad
414}
e5604d79 415
01c51e44
DA
416# som doesn't use .data section.
417case $target_triplet in {
418 { hppa*64*-*-* } {
419 run_dump_test octa
420 }
421 { hppa*-*-hpux* } { }
422 default {
423 run_dump_test octa
424 }
425}
3c9b82ba
NC
426
427# .set works differently on some targets.
428case $target_triplet in {
92757bc9
JB
429 { alpha*-*-* } { }
430 { mips*-*-* } { }
431 { *c54x*-*-* } { }
3c9b82ba
NC
432 { z80-*-* } { }
433 default {
35c08157 434 setup_xfail "nds32*-*-*"
3c9b82ba
NC
435 run_dump_test weakref1
436 run_dump_test weakref1g
437 run_dump_test weakref1l
438 run_dump_test weakref1u
439 run_dump_test weakref1w
440 }
441}
06e77878
AO
442gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c => d => e"
443gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
b54788f8 444gas_test_error "weakref4.s" "" "is already defined"
06e77878 445
38a57ae7 446run_dump_test string
740bdc67
AM
447if [is_elf_format] {
448 run_dump_test none
449}
38a57ae7 450
d02603dc
NC
451run_dump_test quoted-sym-names
452
93a24ba7
MR
453run_list_test pr20312
454
a7eec876
HPN
455load_lib gas-dg.exp
456dg-init
457dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
458dg-finish
9875b365
MR
459
460# Set $nop_type appropriately to indicate the NOP instruction mnemonic.
461case $target_triplet in {
462 { "mmix-*-*" } {
463 set nop_type 5
464 }
465 { "i960-*-*" } {
466 set nop_type 4
467 }
468 { "i370-*-*" } {
469 set nop_type 3
470 }
471 { "or1k*-*-*" } {
472 set nop_type 2
473 }
474 { "ia64-*-*" } {
475 set nop_type 1
476 }
477 default {
478 set nop_type 0
479 }
480}
481run_dump_test "org-1" [list [list as "--defsym nop_type=$nop_type"]]
482run_dump_test "org-2"
483run_dump_test "org-3"
484run_dump_test "org-4"
485run_dump_test "org-5"
486run_dump_test "org-6"
This page took 0.982322 seconds and 4 git commands to generate.