ubsan: arm: shift exponent 32 is too large for 32-bit type 'unsigned int'

Message ID 20191224035032.GG18153@bubble.grove.modra.org
State New
Headers show
Series
  • ubsan: arm: shift exponent 32 is too large for 32-bit type 'unsigned int'
Related show

Commit Message

Alan Modra Dec. 24, 2019, 3:50 a.m.
* arm-dis.c (print_insn_arm): Don't shift by 32 on unsigned int var.


-- 
Alan Modra
Australia Development Lab, IBM

Patch

diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 12eae61bb5..d7e21f99e1 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -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)