[binutils-gdb] ubsan: crx: left shift cannot be represented in type 'int'

Alan Modra amodra@sourceware.org
Sat Jan 4 08:54:00 GMT 2020


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2c5c119630be063c97872428084fff51a858dfd3

commit 2c5c119630be063c97872428084fff51a858dfd3
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jan 3 07:07:17 2020 +1030

    ubsan: crx: left shift cannot be represented in type 'int'
    
    	* crx-dis.c (match_opcode): Avoid shift left of signed value.

Diff:
---
 opcodes/ChangeLog | 4 ++++
 opcodes/crx-dis.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 52ebe86..514466e 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,9 @@
 2020-01-04  Alan Modra  <amodra@gmail.com>
 
+	* crx-dis.c (match_opcode): Avoid shift left of signed value.
+
+2020-01-04  Alan Modra  <amodra@gmail.com>
+
 	* d30v-dis.c (print_insn): Avoid signed overflow in left shift.
 
 2020-01-03  Jan Beulich  <jbeulich@suse.com>
diff --git a/opcodes/crx-dis.c b/opcodes/crx-dis.c
index 18b6c6d..011cd68 100644
--- a/opcodes/crx-dis.c
+++ b/opcodes/crx-dis.c
@@ -337,7 +337,7 @@ match_opcode (void)
   unsigned int mask;
 
   /* The instruction 'constant' opcode doewsn't exceed 32 bits.  */
-  unsigned int doubleWord = (words[1] + (words[0] << 16)) & 0xffffffff;
+  unsigned int doubleWord = words[1] + ((unsigned) words[0] << 16);
 
   /* Start searching from end of instruction table.  */
   instruction = &crx_instruction[NUMOPCODES - 2];



More information about the Binutils-cvs mailing list