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