ubsan: arm: undefined shift
authorAlan Modra <amodra@gmail.com>
Tue, 26 Oct 2021 09:09:12 +0000 (19:39 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 27 Oct 2021 21:10:49 +0000 (07:40 +1030)
left shift of 2 by 31 places cannot be represented in type 'int'

* arm-dis.c (print_insn_thumb16): Avoid undefined behaviour.

opcodes/arm-dis.c

index 78efb815147df2c5dc30077ec9b89681e0d34a21..5252d36b1beb55d26e6299aa544868a01df9577a 100644 (file)
@@ -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)
                          {