ubsan: microblaze: left shift cannot be represented in type 'int'
authorAlan Modra <amodra@gmail.com>
Sun, 15 Dec 2019 23:29:23 +0000 (09:59 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 16 Dec 2019 07:05:13 +0000 (17:35 +1030)
* microblaze-dis.c (read_insn_microblaze): Avoid signed overflow.

opcodes/ChangeLog
opcodes/microblaze-dis.c

index 113fd09264a4fbf2dd4f3b2a2b88fafa771f8ff2..d33c7a17d004d280c98e0a04ff79a20383a2dfd6 100644 (file)
@@ -1,3 +1,7 @@
+2019-12-16  Alan Modra  <amodra@gmail.com>
+
+       * microblaze-dis.c (read_insn_microblaze): Avoid signed overflow.
+
 2019-12-16  Alan Modra  <amodra@gmail.com>
 
        * nios2-dis.c (nios2_print_insn_arg): Avoid signed overflow
index 2b3aa8e078601d0853852d01be196bfa2bb71527..5df7ae497e9899dc17359c1f9dcf448d0d57a8e1 100644 (file)
@@ -200,9 +200,11 @@ read_insn_microblaze (bfd_vma memaddr,
     }
 
   if (info->endian == BFD_ENDIAN_BIG)
-    inst = (ibytes[0] << 24) | (ibytes[1] << 16) | (ibytes[2] << 8) | ibytes[3];
+    inst = (((unsigned) ibytes[0] << 24) | (ibytes[1] << 16)
+           | (ibytes[2] << 8) | ibytes[3]);
   else if (info->endian == BFD_ENDIAN_LITTLE)
-    inst = (ibytes[3] << 24) | (ibytes[2] << 16) | (ibytes[1] << 8) | ibytes[0];
+    inst = (((unsigned) ibytes[3] << 24) | (ibytes[2] << 16)
+           | (ibytes[1] << 8) | ibytes[0]);
   else
     abort ();
 
This page took 0.026417 seconds and 4 git commands to generate.