[binutils-gdb] ubsan: moxie: left shift of negative value
Alan Modra
amodra@sourceware.org
Wed Dec 11 01:13:00 GMT 2019
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=8c9b4171877df495a55b75365203258785da0041
commit 8c9b4171877df495a55b75365203258785da0041
Author: Alan Modra <amodra@gmail.com>
Date: Wed Dec 11 08:26:58 2019 +1030
ubsan: moxie: left shift of negative value
* moxie-dis.c (INST2OFFSET): Don't sign extend using shifts.
Diff:
---
opcodes/ChangeLog | 4 ++++
opcodes/moxie-dis.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index ffe57a4..60dfe76 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,9 @@
2019-12-11 Alan Modra <amodra@gmail.com>
+ * moxie-dis.c (INST2OFFSET): Don't sign extend using shifts.
+
+2019-12-11 Alan Modra <amodra@gmail.com>
+
* m68k-dis.c (COERCE32): Cast value first.
(NEXTLONG, NEXTULONG): Avoid signed overflow.
diff --git a/opcodes/moxie-dis.c b/opcodes/moxie-dis.c
index 3097fa0..cbfcf95 100644
--- a/opcodes/moxie-dis.c
+++ b/opcodes/moxie-dis.c
@@ -33,7 +33,7 @@ static void *stream;
/* Macros to extract operands from the instruction word. */
#define OP_A(i) ((i >> 4) & 0xf)
#define OP_B(i) (i & 0xf)
-#define INST2OFFSET(o) ((((signed short)((o & ((1<<10)-1))<<6))>>6)<<1)
+#define INST2OFFSET(o) (((((o) & 0x3ff) ^ 0x200) - 0x200) << 1)
static const char * reg_names[16] =
{ "$fp", "$sp", "$r0", "$r1", "$r2", "$r3", "$r4", "$r5",
More information about the Binutils-cvs
mailing list