diff options
author | Alan Modra <amodra@gmail.com> | 2019-12-26 15:56:25 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-12-26 17:49:03 +1030 |
commit | 6c2ca6c25dbefd7192dac52e7fd156ae0f299f1f (patch) | |
tree | 1b260d12aa91ad05906469919e1bef7e637ba1f2 /opcodes | |
parent | e5af216040aba59952c99d6479ba5279cee6825d (diff) | |
download | gdb-6c2ca6c25dbefd7192dac52e7fd156ae0f299f1f.zip gdb-6c2ca6c25dbefd7192dac52e7fd156ae0f299f1f.tar.gz gdb-6c2ca6c25dbefd7192dac52e7fd156ae0f299f1f.tar.bz2 |
ubsan: v850: left shift cannot be represented in type 'int'
Another 1 << 31 complaint.
* v850-dis.c (disassemble): Avoid signed overflow. Don't use
long vars when unsigned int will do.
Diffstat (limited to 'opcodes')
-rw-r--r-- | opcodes/ChangeLog | 5 | ||||
-rw-r--r-- | opcodes/v850-dis.c | 14 |
2 files changed, 12 insertions, 7 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index bdbb5f7..07f30e2 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2019-12-26 Alan Modra <amodra@gmail.com> + + * v850-dis.c (disassemble): Avoid signed overflow. Don't use + long vars when unsigned int will do. + 2019-12-24 Alan Modra <amodra@gmail.com> * arm-dis.c (print_insn_arm): Don't shift by 32 on unsigned int var. diff --git a/opcodes/v850-dis.c b/opcodes/v850-dis.c index 45e6c65..df2c2a5 100644 --- a/opcodes/v850-dis.c +++ b/opcodes/v850-dis.c @@ -499,7 +499,7 @@ disassemble (bfd_vma memaddr, 0, 0, 0, 0, 0, 31, 29, 28, 23, 22, 21, 20, 27, 26, 25, 24 }; int *regs; int i; - unsigned long int mask = 0; + unsigned int mask = 0; int pc = 0; switch (operand->shift) @@ -514,12 +514,12 @@ disassemble (bfd_vma memaddr, for (i = 0; i < 32; i++) { - if (value & (1 << i)) + if (value & (1u << i)) { switch (regs[ i ]) { default: - mask |= (1 << regs[ i ]); + mask |= (1u << regs[ i ]); break; case 0: /* xgettext:c-format */ @@ -543,10 +543,10 @@ disassemble (bfd_vma memaddr, int shown_one = 0; for (bit = 0; bit < 32; bit++) - if (mask & (1 << bit)) + if (mask & (1u << bit)) { - unsigned long int first = bit; - unsigned long int last; + unsigned int first = bit; + unsigned int last; if (shown_one) info->fprintf_func (info->stream, ", "); @@ -556,7 +556,7 @@ disassemble (bfd_vma memaddr, info->fprintf_func (info->stream, "%s", get_v850_reg_name (first)); for (bit++; bit < 32; bit++) - if ((mask & (1 << bit)) == 0) + if ((mask & (1u << bit)) == 0) break; last = bit; |