This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ubsan: moxie: left shift of negative value
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 11 Dec 2019 11:26:44 +1030
- Subject: ubsan: moxie: left shift of negative value
* moxie-dis.c (INST2OFFSET): Don't sign extend using shifts.
diff --git a/opcodes/moxie-dis.c b/opcodes/moxie-dis.c
index 3097fa0977..cbfcf95880 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",
--
Alan Modra
Australia Development Lab, IBM