ubsan: arc: shift exponent 32 is too large for 32-bit type 'int'
authorAlan Modra <amodra@gmail.com>
Tue, 10 Dec 2019 08:39:47 +0000 (19:09 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Dec 2019 01:07:25 +0000 (11:37 +1030)
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.

opcodes/ChangeLog
opcodes/arc-dis.c

index 3460b3e2d605e7a8eceabe44afb4c4beecf046b5..d3f1e69940668d92601a1eeb5fa39accd8457519 100644 (file)
@@ -1,3 +1,8 @@
+2019-12-11  Alan Modra  <amodra@gmail.com>
+
+       * arc-dis.c (find_format_from_table): Use ull constant when
+       shifting by up to 32.
+
 2019-12-11  Alan Modra  <amodra@gmail.com>
 
        PR 25270
index 3c88c334283717103d100d31782e6da4a83388f9..a038fa0ca27f26445f886f8cb87b8313dcce412a 100644 (file)
@@ -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.  */
This page took 0.025988 seconds and 4 git commands to generate.