This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ubsan: tic6x: shift left of int


	* tic6x-dis.c (tic6x_extract_32): Avoid signed overflow.

diff --git a/opcodes/tic6x-dis.c b/opcodes/tic6x-dis.c
index 36075da115..45a1e98f2a 100644
--- a/opcodes/tic6x-dis.c
+++ b/opcodes/tic6x-dis.c
@@ -163,9 +163,9 @@ static unsigned int
 tic6x_extract_32 (unsigned char *p, struct disassemble_info *info)
 {
   if (info->endian == BFD_ENDIAN_LITTLE)
-    return (p[0]) | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
+    return p[0] | (p[1] << 8) | (p[2] << 16) | ((unsigned) p[3] << 24);
   else
-    return (p[3]) | (p[2] << 8) | (p[1] << 16) | (p[0] << 24);
+    return p[3] | (p[2] << 8) | (p[1] << 16) | ((unsigned) p[0] << 24);
 }
 
 /* Extract a 16-bit value read from the instruction stream.  */

-- 
Alan Modra
Australia Development Lab, IBM


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]