aboutsummaryrefslogtreecommitdiff
path: root/opcodes/tilegx-opc.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-01-10 08:27:33 +1030
committerAlan Modra <amodra@gmail.com>2020-01-10 17:32:33 +1030
commit7f578b959c3d4b4a1756c66aec4426743b82c6b8 (patch)
tree96b17e2e3cc3d4f33f80bd6b42c4d6da50b94986 /opcodes/tilegx-opc.c
parent441af85bd9c68dbc0c2a1dbe23bf07c6cb3c3f5d (diff)
downloadgdb-7f578b959c3d4b4a1756c66aec4426743b82c6b8.zip
gdb-7f578b959c3d4b4a1756c66aec4426743b82c6b8.tar.gz
gdb-7f578b959c3d4b4a1756c66aec4426743b82c6b8.tar.bz2
ubsan: tilepro: signed integer overflow
* tilepro-opc.c (parse_insn_tilepro): Make opval unsigned. * tilegx-opc.c (parse_insn_tilegx): Likewise. Delete raw_opval.
Diffstat (limited to 'opcodes/tilegx-opc.c')
-rw-r--r--opcodes/tilegx-opc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/opcodes/tilegx-opc.c b/opcodes/tilegx-opc.c
index f49dae5..a122f49 100644
--- a/opcodes/tilegx-opc.c
+++ b/opcodes/tilegx-opc.c
@@ -8096,21 +8096,18 @@ parse_insn_tilegx (tilegx_bundle_bits bits,
{
const struct tilegx_operand *op =
&tilegx_operands[opc->operands[pipe][i]];
- int raw_opval = op->extract (bits);
- long long opval;
+ unsigned int opval = op->extract (bits);
if (op->is_signed)
{
/* Sign-extend the operand. */
unsigned int sign = 1u << (op->num_bits - 1);
- raw_opval = ((raw_opval & (sign + sign - 1)) ^ sign) - sign;
+ opval = ((opval & (sign + sign - 1)) ^ sign) - sign;
}
/* Adjust PC-relative scaled branch offsets. */
if (op->type == TILEGX_OP_TYPE_ADDRESS)
- opval = (raw_opval * TILEGX_BUNDLE_SIZE_IN_BYTES) + pc;
- else
- opval = raw_opval;
+ opval = opval * TILEGX_BUNDLE_SIZE_IN_BYTES + pc;
/* Record the final value. */
d->operands[i] = op;