summaryrefslogtreecommitdiff
path: root/opcodes/moxie-dis.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-11 08:26:58 +1030
committerAlan Modra <amodra@gmail.com>2019-12-11 11:40:00 +1030
commit8c9b4171877df495a55b75365203258785da0041 (patch)
tree0615a088ef27ad70643f620cd3b15ecc0f3ddab6 /opcodes/moxie-dis.c
parent334175b693a1cbab8850f5faa6937e7c6ca3db7d (diff)
downloadbinutils-gdb-8c9b4171877df495a55b75365203258785da0041.tar.gz
ubsan: moxie: left shift of negative value
* moxie-dis.c (INST2OFFSET): Don't sign extend using shifts.
Diffstat (limited to 'opcodes/moxie-dis.c')
-rw-r--r--opcodes/moxie-dis.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/opcodes/moxie-dis.c b/opcodes/moxie-dis.c
index 3097fa09778..cbfcf958806 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",