ubsan: arm: shift exponent 32 is too large for 32-bit type 'unsigned int'
authorAlan Modra <amodra@gmail.com>
Mon, 23 Dec 2019 23:41:40 +0000 (10:11 +1030)
committerAlan Modra <amodra@gmail.com>
Tue, 24 Dec 2019 01:31:42 +0000 (12:01 +1030)
* arm-dis.c (print_insn_arm): Don't shift by 32 on unsigned int var.

opcodes/ChangeLog
opcodes/arm-dis.c

index 979ca97b4b164046178ce4bd87db3ca4e09940fd..bdbb5f74b1f05e4b07b0b775e23f73f53700f3b6 100644 (file)
@@ -1,3 +1,7 @@
+2019-12-24  Alan Modra  <amodra@gmail.com>
+
+       * arm-dis.c (print_insn_arm): Don't shift by 32 on unsigned int var.
+
 2019-12-23  Jan Beulich  <jbeulich@suse.com>
 
        * ppc-dis.c (print_insn_powerpc): Rename local variable "spaces"
index 12eae61bb5957e67375b52b32d10de927289a08c..d7e21f99e1731314cc91d7c894d7de8a40d9ea91 100644 (file)
@@ -9927,12 +9927,12 @@ print_insn_arm (bfd_vma pc, struct disassemble_info *info, long given)
                          unsigned int immed = (given & 0xff);
                          unsigned int a, i;
 
-                         a = (((immed << (32 - rotate))
-                               | (immed >> rotate)) & 0xffffffff);
+                         a = (immed << ((32 - rotate) & 31)
+                              | immed >> rotate) & 0xffffffff;
                          /* If there is another encoding with smaller rotate,
                             the rotate should be specified directly.  */
                          for (i = 0; i < 32; i += 2)
-                           if ((a << i | a >> (32 - i)) <= 0xff)
+                           if ((a << i | a >> ((32 - i) & 31)) <= 0xff)
                              break;
 
                          if (i != rotate)