[binutils-gdb] ubsan: bfin-dis.c:160 shift exponent 32 is too large

Alan Modra amodra@sourceware.org
Wed Sep 2 08:46:54 GMT 2020


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

commit 427202d96790f1b659e0fa9485b8128c95dc48db
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Sep 2 10:33:07 2020 +0930

    ubsan: bfin-dis.c:160 shift exponent 32 is too large
    
            * bfin-dis.c (MASKBITS): Use SIGNBIT.

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

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 8481a13e08b..1c7e4cb12d3 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,7 @@
+2020-09-02  Alan Modra  <amodra@gmail.com>
+
+	* bfin-dis.c (MASKBITS): Use SIGNBIT.
+
 2020-09-02  Cooper Qu  <cooper.qu@linux.alibaba.com>
 
 	* csky-opc.h (csky_v2_opcodes): Move divul and divsl
diff --git a/opcodes/bfin-dis.c b/opcodes/bfin-dis.c
index 4f66f12e3cb..3eb6087a3c8 100644
--- a/opcodes/bfin-dis.c
+++ b/opcodes/bfin-dis.c
@@ -34,7 +34,7 @@
 typedef long TIword;
 
 #define SIGNBIT(bits)       (1ul << ((bits) - 1))
-#define MASKBITS(val, bits) ((val) & ((1ul << (bits)) - 1))
+#define MASKBITS(val, bits) ((val) & ((SIGNBIT (bits) << 1) - 1))
 #define SIGNEXTEND(v, n)    ((MASKBITS (v, n) ^ SIGNBIT (n)) - SIGNBIT (n))
 
 #include "disassemble.h"


More information about the Binutils-cvs mailing list