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

Alan Modra amodra@sourceware.org
Wed Dec 11 01:14:00 GMT 2019


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

commit 5c05618a0a1f94565001a19da28595ce1dc537f8
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Dec 11 08:57:45 2019 +1030

    ubsan: vax: left shift cannot be represented in type 'int'
    
    	* vax-dis.c (NEXTLONG): Avoid signed overflow.

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

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 2ad26cb..c1fce7f 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,9 @@
 2019-12-11  Alan Modra  <amodra@gmail.com>
 
+	* vax-dis.c (NEXTLONG): Avoid signed overflow.
+
+2019-12-11  Alan Modra  <amodra@gmail.com>
+
 	* v850-dis.c (get_operand_value): Use unsigned arithmetic.  Don't
 	sign extend using shifts.
 
diff --git a/opcodes/vax-dis.c b/opcodes/vax-dis.c
index 2c02c29..3bdfa15 100644
--- a/opcodes/vax-dis.c
+++ b/opcodes/vax-dis.c
@@ -64,7 +64,7 @@ static char *entry_mask_bit[] =
 #define COERCE32(x) ((int) (((x) ^ 0x80000000) - 0x80000000))
 #define NEXTLONG(p)  \
   (p += 4, FETCH_DATA (info, p), \
-   (COERCE32 ((((((p[-1] << 8) + p[-2]) << 8) + p[-3]) << 8) + p[-4])))
+   (COERCE32 (((((((unsigned) p[-1] << 8) + p[-2]) << 8) + p[-3]) << 8) + p[-4])))
 
 /* Maximum length of an instruction.  */
 #define MAXLEN 25



More information about the Binutils-cvs mailing list