diff options
author | Jan Beulich <jbeulich@suse.com> | 2021-06-16 08:55:20 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2021-06-16 08:55:20 +0200 |
commit | 4504a6346777d544a144683bd2a534b686fbac41 (patch) | |
tree | 65f18b24a6c7df5caaf8eec8bd7ba25f7f466875 /gas/testsuite | |
parent | b80d4475804d5f3c4e9d996229e1569b7b3c8426 (diff) | |
download | gdb-4504a6346777d544a144683bd2a534b686fbac41.zip gdb-4504a6346777d544a144683bd2a534b686fbac41.tar.gz gdb-4504a6346777d544a144683bd2a534b686fbac41.tar.bz2 |
gas: fix overflow diagnostics
While the logic in fixup_segment() so far was off by 1 for fixups
dealing with quantities without known signedness, thus failing to report
an overflow when e.g. a byte-sized resulting value is -0x100, the logic
in emit_expr_with_reloc() reported an overflow even on large negative
values when the respective positive ones would not be warned
about, and when fixup_segment() wouldn't do so either. Such diagnostics
all ought to follow a similar pattern of what value range is acceptable.
(If expressions' X_unsigned was reliably set, emit_expr_with_reloc()'s
checking might make sense to tighten based on that flag.)
Note that with commit 80aab57939a0 ("Changes to let cons handle bignums
like general expressions") having added handling of nbytes >
sizeof(valueT) in the O_constant case, converting to O_big, the setting
to zero of "hibit" had become dead. With "hibit" no longer used, this
code now gets dropped altogether. But additionally a respective know()
gets inserted.
Diffstat (limited to 'gas/testsuite')
-rw-r--r-- | gas/testsuite/gas/all/gas.exp | 21 | ||||
-rw-r--r-- | gas/testsuite/gas/all/overflow.l | 9 | ||||
-rw-r--r-- | gas/testsuite/gas/all/overflow.s | 26 |
3 files changed, 56 insertions, 0 deletions
diff --git a/gas/testsuite/gas/all/gas.exp b/gas/testsuite/gas/all/gas.exp index e9648ff..389634f 100644 --- a/gas/testsuite/gas/all/gas.exp +++ b/gas/testsuite/gas/all/gas.exp @@ -372,6 +372,27 @@ switch -glob $target_triplet { } } +# Various targets use too custom handling to be able to sensibly create +# common expecations for this test. Also .equ works differently on some +# targets. +if { ![istarget avr-*-*] + && ![istarget bfin-*-*] + && ![istarget cris*-*-*] + && ![istarget dlx-*-*] + && ![istarget hppa*-*-*] + && ![istarget m68k-*-*] + && ![istarget nios2-*-*] + && ![istarget pj-*-*] + && ![istarget sh*-*-*] + && ![istarget *c4x-*-*] + && ![istarget *c54x-*-*] + && ![istarget *c6x-*-*] + && ![istarget z80-*-*] } then { + # Some further targets' custom handling fails to recognize the overflows. + setup_xfail "crx-*-*" "h8300-*-*" "mcore-*-*" "mn10200-*-*" "mn10300-*-*" "msp430-*-*" "ns32k-*-*" + run_list_test "overflow" +} + if { ([istarget "i*86-*-*pe*"] && ![istarget "i*86-*-openbsd*"]) \ || [istarget "i*86-*-cygwin*"] \ || [istarget "i*86-*-mingw32*"] } { diff --git a/gas/testsuite/gas/all/overflow.l b/gas/testsuite/gas/all/overflow.l new file mode 100644 index 0000000..9630957 --- /dev/null +++ b/gas/testsuite/gas/all/overflow.l @@ -0,0 +1,9 @@ +.*: Assembler messages: +.*:5: Warning: .* (0x)?100 truncated to (0x)?0 +.*:6: Warning: .* (0x)?101 truncated to (0x)?1 +.*:11: Warning: .* (0x)?f+00 truncated to (0x)?0 +.*:12: Warning: .* (0x)?f+eff truncated to (0x)?ff +.*:17: Error: .* (256|(0x)?100) too large .* +.*:18: Error: .* (257|(0x)?101) too large .* +.*:23: Error: .* (0x)?f+00 too large .* +.*:24: Error: .* (0x)?f+eff too large .* diff --git a/gas/testsuite/gas/all/overflow.s b/gas/testsuite/gas/all/overflow.s new file mode 100644 index 0000000..879f93a --- /dev/null +++ b/gas/testsuite/gas/all/overflow.s @@ -0,0 +1,26 @@ + .data + .dc.b +0x80 + .dc.b +0x81 + .dc.b +0xff + .dc.b +0x100 + .dc.b +0x101 + + .dc.b -0x80 + .dc.b -0x81 + .dc.b -0xff + .dc.b -0x100 + .dc.b -0x101 + + .dc.b zero+0x80 + .dc.b zero+0x81 + .dc.b zero+0xff + .dc.b zero+0x100 + .dc.b zero+0x101 + + .dc.b zero-0x80 + .dc.b zero-0x81 + .dc.b zero-0xff + .dc.b zero-0x100 + .dc.b zero-0x101 + + .equ zero, 0 |