diff options
author | Alan Modra <amodra@gmail.com> | 2020-08-31 14:31:55 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-08-31 20:28:11 +0930 |
commit | 7a5dd76f3c0ed63883726e8758856a226551e873 (patch) | |
tree | c0ab26f799a493027fedc82067f3bf664cfddf52 | |
parent | 169ec512592ee81a392c8c80d54e99d1b057229f (diff) | |
download | gdb-7a5dd76f3c0ed63883726e8758856a226551e873.zip gdb-7a5dd76f3c0ed63883726e8758856a226551e873.tar.gz gdb-7a5dd76f3c0ed63883726e8758856a226551e873.tar.bz2 |
PR26468 UBSAN: tc-mep.c:1684 left shift of negative value
PR 26468
* config/tc-mep.c (md_convert_frag): Use uint32_t for addend and
other variables.
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/config/tc-mep.c | 4 |
2 files changed, 8 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 9336a61..7b6b28d 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,11 @@ 2020-08-31 Alan Modra <amodra@gmail.com> + PR 26468 + * config/tc-mep.c (md_convert_frag): Use uint32_t for addend and + other variables. + +2020-08-31 Alan Modra <amodra@gmail.com> + PR 26493 * config/tc-riscv.c (riscv_ip): Cast X_add_number passed to VALID_* macros to unsigned. diff --git a/gas/config/tc-mep.c b/gas/config/tc-mep.c index 6b52841..e588a30 100644 --- a/gas/config/tc-mep.c +++ b/gas/config/tc-mep.c @@ -1617,7 +1617,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT seg ATTRIBUTE_UNUSED, fragS *fragP) { - int addend, rn, bit = 0; + uint32_t addend, rn, bit = 0; int operand; int where = fragP->fr_opcode - fragP->fr_literal; int e = target_big_endian ? 0 : 1; @@ -1697,7 +1697,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, /* The default relax_frag doesn't change the state if there is no growth, so we must manually handle converting out-of-range BEQ instructions to JMP. */ - if (addend <= 65535 && addend >= -65536) + if (addend + 65536 < 131071) { if (core_mode) fragP->fr_fix += 2; |