ubsan: arm: undefined shift
Alan Modra
amodra@gmail.com
Wed Oct 27 22:36:03 GMT 2021
left shift of 2 by 31 places cannot be represented in type 'int'
* arm-dis.c (print_insn_thumb16): Avoid undefined behaviour.
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 78efb815147..5252d36b1be 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -10714,7 +10714,7 @@ print_insn_thumb16 (bfd_vma pc, struct disassemble_info *info, long given)
if (!bitend)
abort ();
reg = given >> bitstart;
- reg &= (2 << (bitend - bitstart)) - 1;
+ reg &= ((bfd_vma) 2 << (bitend - bitstart)) - 1;
switch (*c)
{
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list