45 lines
1.2 KiB
Diff
45 lines
1.2 KiB
Diff
|
|
From 8ff23dba80b80a9f47d75dd43812e041f6674763 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Alan Modra <amodra@gmail.com>
|
||
|
|
Date: Tue, 10 Dec 2019 17:57:14 +1030
|
||
|
|
Subject: [PATCH] ubsan: ia64: left shift of negative value
|
||
|
|
|
||
|
|
Here, since val is signed:
|
||
|
|
*valuep = (val << scale);
|
||
|
|
|
||
|
|
* cpu-ia64-opc.c (ext_imms_scaled): Avoid undefined left shift
|
||
|
|
of negative values by using unsigned vars.
|
||
|
|
---
|
||
|
|
bfd/ChangeLog | 5 +++++
|
||
|
|
bfd/cpu-ia64-opc.c | 6 +++---
|
||
|
|
2 files changed, 8 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/bfd/cpu-ia64-opc.c b/bfd/cpu-ia64-opc.c
|
||
|
|
index 84ee0e2..8df90be 100644
|
||
|
|
--- a/bfd/cpu-ia64-opc.c
|
||
|
|
+++ b/bfd/cpu-ia64-opc.c
|
||
|
|
@@ -186,7 +186,7 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code,
|
||
|
|
ia64_insn *valuep, int scale)
|
||
|
|
{
|
||
|
|
int i, bits = 0, total = 0;
|
||
|
|
- BFD_HOST_64_BIT val = 0, sign;
|
||
|
|
+ BFD_HOST_U_64_BIT val = 0, sign;
|
||
|
|
|
||
|
|
for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i)
|
||
|
|
{
|
||
|
|
@@ -196,10 +196,10 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code,
|
||
|
|
total += bits;
|
||
|
|
}
|
||
|
|
/* sign extend: */
|
||
|
|
- sign = (BFD_HOST_64_BIT) 1 << (total - 1);
|
||
|
|
+ sign = (BFD_HOST_U_64_BIT) 1 << (total - 1);
|
||
|
|
val = (val ^ sign) - sign;
|
||
|
|
|
||
|
|
- *valuep = (val << scale);
|
||
|
|
+ *valuep = val << scale;
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
--
|
||
|
|
2.9.3
|
||
|
|
|