ubsan: arc: shift exponent 32 is too large for 32-bit type 'int'
Alan Modra
amodra@gmail.com
Wed Dec 11 00:50:00 GMT 2019
When operand->bits is 32, the following results in UB.
value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
* arc-dis.c (find_format_from_table): Use ull constant when
shifting by up to 32.
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
index 3c88c33428..a038fa0ca2 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -295,7 +295,7 @@ find_format_from_table (struct disassemble_info *info,
if (operand->extract)
value = (*operand->extract) (insn, &invalid);
else
- value = (insn >> operand->shift) & ((1 << operand->bits) - 1);
+ value = (insn >> operand->shift) & ((1ull << operand->bits) - 1);
/* Check for LIMM indicator. If it is there, then make sure
we pick the right format. */
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list