aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-01-11 12:23:47 +1030
committerAlan Modra <amodra@gmail.com>2020-01-13 12:12:05 +1030
commit7ef412cf72a197d68e532604cc1fa21351adc858 (patch)
tree8175e2bb61b520a3e7ff837845ffc2cb9872b3de
parentaa1f7fb133a5a4f95af8286f58b689d6ae131488 (diff)
downloadfsf-binutils-gdb-7ef412cf72a197d68e532604cc1fa21351adc858.zip
fsf-binutils-gdb-7ef412cf72a197d68e532604cc1fa21351adc858.tar.gz
fsf-binutils-gdb-7ef412cf72a197d68e532604cc1fa21351adc858.tar.bz2
ubsan: xgate: left shift of negative value
* xgate-dis.c (print_insn): Don't left shift signed value. (ripBits): Formatting, use 1u.
-rw-r--r--opcodes/ChangeLog5
-rw-r--r--opcodes/xgate-dis.c16
2 files changed, 13 insertions, 8 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 68538bd..e2e9b10 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2020-01-13 Alan Modra <amodra@gmail.com>
+
+ * xgate-dis.c (print_insn): Don't left shift signed value.
+ (ripBits): Formatting, use 1u.
+
2020-01-10 Alan Modra <amodra@gmail.com>
* tilepro-opc.c (parse_insn_tilepro): Make opval unsigned.
diff --git a/opcodes/xgate-dis.c b/opcodes/xgate-dis.c
index 9d84431..61eeb99 100644
--- a/opcodes/xgate-dis.c
+++ b/opcodes/xgate-dis.c
@@ -193,12 +193,12 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info)
relAddr = XGATE_NINE_BITS >> 1; /* Clip sign bit. */
relAddr = ~relAddr; /* Make signed. */
relAddr |= (raw_code & 0xFF) + 1; /* Apply our value. */
- relAddr <<= 1; /* Multiply by two as per processor docs. */
+ relAddr *= 2; /* Multiply by two as per processor docs. */
}
else
{
relAddr = raw_code & 0xff;
- relAddr = (relAddr << 1) + 2;
+ relAddr = relAddr * 2 + 2;
}
(*info->fprintf_func)(info->stream, " *%d", relAddr);
(*info->fprintf_func)(info->stream, " Abs* 0x");
@@ -212,12 +212,12 @@ print_insn (bfd_vma memaddr, struct disassemble_info* info)
relAddr = XGATE_TEN_BITS >> 1; /* Clip sign bit. */
relAddr = ~relAddr; /* Make signed. */
relAddr |= (raw_code & 0x1FF) + 1; /* Apply our value. */
- relAddr <<= 1; /* Multiply by two as per processor docs. */
+ relAddr *= 2; /* Multiply by two as per processor docs. */
}
else
{
relAddr = raw_code & 0x1FF;
- relAddr = (relAddr << 1) + 2;
+ relAddr = relAddr * 2 + 2;
}
(*info->fprintf_func)(info->stream, " *%d", relAddr);
(*info->fprintf_func)(info->stream, " Abs* 0x");
@@ -299,12 +299,12 @@ ripBits (unsigned int *operandBitsRemaining,
unsigned int memory)
{
unsigned int currentBit;
- int operand;
+ unsigned int operand = 0;
int numBitsFound;
- for (operand = 0, numBitsFound = 0, currentBit = 1
- << ((opcodePTR->size * 8) - 1);
- (numBitsFound < numBitsRequested) && currentBit; currentBit >>= 1)
+ for (numBitsFound = 0, currentBit = 1u << ((opcodePTR->size * 8) - 1);
+ numBitsFound < numBitsRequested && currentBit != 0;
+ currentBit >>= 1)
{
if (currentBit & *operandBitsRemaining)
{