]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit - gas/write.c
gas: fix overflow diagnostics
authorJan Beulich <jbeulich@suse.com>
Wed, 16 Jun 2021 06:55:20 +0000 (08:55 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 16 Jun 2021 06:55:20 +0000 (08:55 +0200)
commit4504a6346777d544a144683bd2a534b686fbac41
tree65f18b24a6c7df5caaf8eec8bd7ba25f7f466875
parentb80d4475804d5f3c4e9d996229e1569b7b3c8426
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.
gas/ChangeLog
gas/read.c
gas/testsuite/gas/all/gas.exp
gas/testsuite/gas/all/overflow.l [new file with mode: 0644]
gas/testsuite/gas/all/overflow.s [new file with mode: 0644]
gas/write.c