]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gas/testsuite/gas/all/gas.exp
PR23800, .eqv doesn't always defer expression evaluation
[thirdparty/binutils-gdb.git] / gas / testsuite / gas / all / gas.exp
1 # Copyright (C) 2012-2018 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 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.
59 if { ![istarget alpha*-*-*vms*]
60 && ![istarget am3*-*-*]
61 && ![istarget avr-*-*]
62 && ![istarget ft32-*-*]
63 && ![istarget hppa*-*-*]
64 && ![istarget microblaze-*-*]
65 && ![istarget mn10300-*-*]
66 && ![istarget msp430*-*-*]
67 && ![istarget riscv*-*-*]
68 && ![istarget rl78-*-*]
69 && ![istarget rx-*-*] } then {
70 gas_test_error "diff1.s" "" "difference of two undefined symbols"
71 }
72
73 gas_test_error "equiv1.s" "" ".equiv for symbol already set to another one"
74 gas_test_error "equiv2.s" "" ".equiv for symbol already set to an expression"
75
76 # The inode comparison used to detect identical input and output files
77 # doesn't work on non-Posix hosts.
78 if { ![ishost "*-*-mingw*"] } then {
79 gas_test_error "none.s" "-o $srcdir/$subdir/none.s" "Output file must be distinct from input"
80 }
81
82 # .equ works differently on some targets.
83 case $target_triplet in {
84 { hppa*-*-* } { }
85 { *c54x*-*-* } { }
86 default {
87 gas_test "equ-ok.s" "" "" ".equ for symbol already set"
88 gas_test_error "equ-bad.s" "" ".equ for symbol already set through .eqv"
89 }
90 }
91
92 gas_test "eqv-ok.s" "" "" ".eqv support"
93 gas_test_error "eqv-bad.s" "" ".eqv for symbol already set"
94 run_dump_test eqv-dot
95
96 if { ![istarget "bfin-*-*"] } then {
97 gas_test "assign-ok.s" "" "" "== assignment support"
98 }
99 gas_test_error "assign-bad.s" "" "== assignment for symbol already set"
100
101 # .equ works differently on some targets.
102 # linkrelax-ing prevents most forward references from working.
103 case $target_triplet in {
104 { am3*-*-* } { }
105 { *c54x*-*-* } { }
106 { cr16*-*-* } { }
107 { crx*-*-* } { }
108 { h8300*-*-* } { }
109 { hppa*-*-* } { }
110 { mep-*-* } { }
111 { microblaze-*-* } { }
112 { mn10\[23\]00*-*-* } { }
113 default {
114 # Some targets don't manage to resolve BFD_RELOC_8 for constants.
115 setup_xfail "alpha*-*-*" "*c30*-*-*" "*c4x*-*-*" \
116 "d\[13\]0v*-*-*" \
117 "pdp11-*-*" "xtensa*-*-*"
118 run_dump_test forward
119 }
120 }
121
122 # aout relocs are often weird, so is mep. don't bother testing
123 # som doesn't use a .text section
124 # mmix doesn't like .L1:
125 # ti addresses aren't octets.
126 if { ![is_aout_format] } {
127 case $target_triplet in {
128 { hppa*64*-*-* } {
129 run_dump_test fwdexp
130 }
131 { alpha-*-*linux*ecoff } { }
132 { alpha-*-osf* } { }
133 { hppa*-*-hpux* } { }
134 { mep-*-* } { }
135 { mmix-*-* } { }
136 { nds32*-*-* } { }
137 { tic30*-*-* } { }
138 { tic4x*-*-* } { }
139 { tic54x*-*-* } { }
140 default {
141 run_dump_test fwdexp
142 }
143 }
144 }
145
146 # .set works differently on some targets.
147 # most of the tests won't work on targets that set linkrelax.
148 # 4 octet bytes confuse address matching on ti targets.
149 # pdp11 gets unexpected reloc types.
150 case $target_triplet in {
151 { alpha*-*-* } { }
152 { am3*-*-* } { }
153 { cr16*-*-* } { }
154 { crx*-*-* } { }
155 { h8300-*-* } { }
156 { mips*-*-* } { }
157 { mn10200-*-* } { }
158 { mn10300-*-* } { }
159 { msp430*-*-* } { }
160 { nds32*-*-* } { }
161 { pdp11-*-* } { }
162 { tic30*-*-* } { }
163 { tic4x*-*-* } { }
164 { tic54x*-*-* } { }
165 { xtensa*-*-* } { }
166 { z80-*-* } { }
167 default {
168 run_dump_test redef
169 # These targets fail redef2 because they disallow redefined
170 # symbols on relocs.
171 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
172 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
173 run_dump_test redef2
174 setup_xfail "m68hc1*-*-*" "m6811-*-*" "m6812-*-*" "rl78-*-*"
175 setup_xfail "riscv*-*-*" "rx-*-*" "vax*-*-*" "xgate*-*-*" "z8k-*-*"
176 # rs6000-aix disallows redefinition via .comm.
177 setup_xfail "*-*-aix*"
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
181 # failures.
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*"
186 run_dump_test redef3
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"
189 }
190 }
191
192 proc do_comment {} {
193 set testname "comment.s: comments in listings"
194 set x1 0
195 set x2 0
196 set x3 0
197 set white {[ \t]*}
198 gas_start "comment.s" "-al"
199 while 1 {
200 # Apparently CRLF is received when using ptys for subprocesses; hence the
201 # \r\n for line 3.
202 expect {
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 }
206 -re "\[^\n\]*\n" { }
207 timeout { perror "timeout\n"; break }
208 eof { break }
209 }
210 }
211 gas_finish
212 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
213 }
214
215 # m32c pads out sections, even empty ones.
216 case $target_triplet in {
217 { m32c-*-* } { }
218 default {
219 do_comment
220 }
221 }
222
223 # This test checks the output of the -ag switch. It must detect at least
224 # the name of the input file, output file, and options passed.
225 proc general_info_section {} {
226 set testname "general info section in listings"
227 set x1 0
228 set x2 0
229 set x3 0
230 set white {[ \t]*}
231 gas_start "comment.s" "-agn"
232 while 1 {
233 expect {
234 -re "^ \[^\n\]*\t: .*\-agn\[^\n\]*\n" { set x1 1 }
235 -re "^ \[^\n\]*\t: \[^\n\]*comment\.s\[^\n\]*\n" { set x2 1 }
236 -re "^ \[^\n\]*\t: a\.out\[^\n\]*\n" { set x3 1 }
237 -re "\[^\n\]*\n" { }
238 timeout { perror "timeout\n"; break }
239 eof { break }
240 }
241 }
242 gas_finish
243 if [all_ones $x1 $x2 $x3] then { pass $testname } else { fail $testname }
244 }
245
246 general_info_section
247
248 #
249 # Test x930509a -- correct assembly of differences involving forward
250 # references.
251 #
252
253 proc do_930509a {} {
254 set testname "difference between forward references"
255 set x 0
256 gas_start "x930509.s" "-al"
257 while 1 {
258 # We need to accommodate both byte orders here.
259 # If ".long" means an 8-byte value on some target someday, this test will have
260 # to be fixed.
261 expect {
262 -re "^ +1 .... 00 ?00 ?00 ?00" { fail $testname; set x 1 }
263 -re "^ +1 .... 04 ?00 ?00 ?00" { pass $testname; set x 1 }
264 -re "^ +1 .... 00 ?00 ?00 ?04" { pass $testname; set x 1 }
265 -re "\[^\n\]*\n" { }
266 timeout { perror "timeout\n"; break }
267 eof { break }
268 }
269 }
270 gas_finish
271 if !$x then { fail $testname }
272 }
273
274 # This test is meaningless for the PA and CR16/CRX: the difference of two
275 # symbols cannot be resolved by the assembler.
276 # C54x assembler (for compatibility) does not allow differences between
277 # forward references.
278 # C30 counts a four byte offset as a difference of one.
279 if { ![istarget *c30*-*-*]
280 && ![istarget *c4x*-*-*]
281 && ![istarget *c54x*-*-*]
282 && ![istarget cr16*-*-*]
283 && ![istarget crx*-*-*]
284 && ![istarget ft32-*-*]
285 && ![istarget h8300*-*-*]
286 && ![istarget hppa*-*-*] } then {
287 # The vax fails because VMS can apparently actually handle this
288 # case in relocs, so gas doesn't handle it itself.
289 # msp430, mn10[23]00 and riscv emit two relocs to handle the difference of two symbols.
290 setup_xfail "am3*-*-*" "mn10200-*-*" "mn10300*-*-*" "msp430*-*-*" "riscv*-*-*" "vax*-*-vms*"
291 do_930509a
292 }
293
294 # ".struct" and ".align" have different meanings on c54x
295 # These directives are done in the c54x-specific tests instead
296 case $target_triplet in {
297 { hppa*-*-* } { }
298 { *c4x*-*-* } { }
299 { *c54x*-*-* } { }
300 default {
301 run_dump_test struct
302 run_dump_test align
303 setup_xfail "ns32k-*-*"
304 run_dump_test align2
305 }
306 }
307
308 # '<' and '>' appear to have special meanings on the excluded targets
309 case $target_triplet in {
310 { frv-*-* } { }
311 { hppa*-*-* } { }
312 { m32r-*-* } { }
313 { mmix-*-* } { }
314 { *c4x*-*-* } { }
315 { *c54x*-*-* } { }
316 { bfin-*-* } { }
317 default {
318 run_dump_test altmacro
319 # The second test is valid only when '!' is not a comment
320 # character (it is allowed to be a line comment character).
321 if [string match "" [lindex [gas_run excl.s "-o /dev/null" ""] 0]] {
322 run_dump_test altmac2
323 # Similarly this test does not work when ! is a line separator.
324 run_dump_test eval
325 }
326 }
327 }
328
329 # This test is for any COFF target.
330 # We omit the ARM toolchains because they define locals to
331 # start with '.', which eliminates .eos, .text etc from the output.
332 # Omit c54x, since .tag and .def mean something different on that target
333 if { ([istarget *-*-coff*] && ![istarget arm*-*-coff] && ![istarget *c4x*-*-coff] && ![istarget *c54x*-*-coff]) \
334 ||([istarget *-*-pe*] && ![istarget arm*-*-pe*]) \
335 || [istarget i*86-*-aix*] \
336 || [istarget i*86-*-sco*] \
337 || [istarget i*86-*-isc*] \
338 || [istarget i*86-*-go32*] \
339 || [istarget i*86-*-cygwin*] \
340 || [istarget x86_64-*-mingw*] \
341 || [istarget i*86-*-*nt] \
342 || [istarget i*86-*-interix*] } {
343 run_dump_test cofftag
344 }
345
346 # Test omitting conditionals from listings.
347 proc test_cond {} {
348 global comp_output
349 global srcdir
350 global subdir
351
352 set testname "conditional listings"
353 gas_run cond.s "-alc" ">dump.out"
354 if ![string match "" $comp_output] {
355 send_log "$comp_output\n"
356 fail $testname
357 } else {
358 if { [regexp_diff dump.out $srcdir/$subdir/cond.l] } {
359 fail $testname
360 } else {
361 pass $testname
362 }
363 }
364 }
365
366 # This test is not suitable for the PA for various reasons
367 # not limited to the fact that it depends on specific section
368 # names appearing in the output file.
369 # Again, p2align doesn't work on c54x and related targets.
370 case $target_triplet in {
371 { alpha-*-linux*ecoff} { }
372 { alpha-*-osf*} { }
373 { hppa*-*-* } { }
374 { *c4x*-*-* } { }
375 { *c54x*-*-* } { }
376 { rl78-*-* } { }
377 { rx-*-* } { }
378 default {
379 test_cond
380 remote_download host "$srcdir/$subdir/incbin.dat"
381 run_dump_test incbin
382 }
383 }
384
385 if { ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \
386 || [istarget "i*86-*-cygwin*"] \
387 || [istarget "i*86-*-mingw32*"] } {
388 gas_test "fastcall.s" "" "" "fastcall labels"
389 }
390
391 if { ![istarget "bfin-*-*"] && ![istarget "nds32*-*-*"] } then {
392 run_dump_test assign
393 }
394 run_dump_test sleb128
395 run_dump_test sleb128-2
396 run_dump_test sleb128-3
397 run_dump_test sleb128-4
398 run_dump_test sleb128-5
399 # .byte is not 8 bits on either tic4x or tic54x
400 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] } {
401 run_dump_test sleb128-7
402 run_dump_test sleb128-8
403 }
404 run_dump_test sleb128-9
405
406 # .byte is 32 bits on tic4x, and .p2align isn't supported on tic54x
407 # .space is different on hppa*-hpux.
408 # MeP put bytes into packets.
409 if { ![istarget "tic4x*-*-*"] && ![istarget "tic54x*-*-*"] && ![istarget "hppa*-*-hpux*"] && ![istarget "mep*-*-*"] } {
410 run_dump_test relax
411 }
412
413 # powerpc and s390 allow a string argument to .byte
414 if { ![istarget "powerpc*-*-*"] && ![istarget "rs6000*-*-*"] && ![istarget "s390*-*-*"] } {
415 run_dump_test byte
416 }
417
418 run_dump_test quad
419 run_dump_test octa
420
421 # .set works differently on some targets.
422 case $target_triplet in {
423 { alpha*-*-* } { }
424 { mips*-*-* } { }
425 { *c54x*-*-* } { }
426 { z80-*-* } { }
427 default {
428 setup_xfail "nds32*-*-*"
429 run_dump_test weakref1
430 run_dump_test weakref1g
431 run_dump_test weakref1l
432 run_dump_test weakref1u
433 run_dump_test weakref1w
434 }
435 }
436 gas_test_error "weakref2.s" "" "e: would close weakref loop: e => a => b => c => d => e"
437 gas_test_error "weakref3.s" "" "a: would close weakref loop: a => b => c => d => e => a"
438 gas_test_error "weakref4.s" "" "is already defined"
439
440 run_dump_test string
441 if [is_elf_format] {
442 run_dump_test none
443 }
444
445 run_dump_test quoted-sym-names
446
447 run_list_test pr20312
448
449 load_lib gas-dg.exp
450 dg-init
451 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
452 dg-finish
453
454 # Set $nop_type appropriately to indicate the NOP instruction mnemonic.
455 case $target_triplet in {
456 { "mmix-*-*" } {
457 set nop_type 5
458 }
459 { "or1k*-*-*" } {
460 set nop_type 2
461 }
462 { "ia64-*-*" } {
463 set nop_type 1
464 }
465 default {
466 set nop_type 0
467 }
468 }
469 run_dump_test "org-1" [list [list as "--defsym nop_type=$nop_type"]]
470 run_dump_test "org-2"
471 run_dump_test "org-3"
472 run_dump_test "org-4"
473 run_dump_test "org-5"
474 run_dump_test "org-6"
475
476 run_dump_test "fill-1"