This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
ubsan: iq2000: left shift of negative value
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Mon, 23 Dec 2019 18:03:25 +1030
- Subject: ubsan: iq2000: left shift of negative value
cpu/
* iq2000.cpu (f-offset): Avoid left shift of negative values.
opcodes/
* iq2000-ibld.c: Regenerate.
diff --git a/cpu/iq2000.cpu b/cpu/iq2000.cpu
index e25ba69392..cb9cfae1d4 100644
--- a/cpu/iq2000.cpu
+++ b/cpu/iq2000.cpu
@@ -207,7 +207,7 @@
(df f-offset "pc offset field" (PCREL-ADDR) 15 16 INT
; Actually, this is relative to the address of the delay slot.
((value pc) (sra SI (sub SI value pc) 2))
- ((value pc) (add SI (sll SI value 2) (add pc 4))))
+ ((value pc) (add SI (mul SI value 4) (add pc 4))))
; Instruction fields that scarcely appear in instructions.
diff --git a/opcodes/iq2000-ibld.c b/opcodes/iq2000-ibld.c
index 34482b366a..3059fe167a 100644
--- a/opcodes/iq2000-ibld.c
+++ b/opcodes/iq2000-ibld.c
@@ -838,7 +838,7 @@ iq2000_cgen_extract_operand (CGEN_CPU_DESC cd,
{
long value;
length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, pc, & value);
- value = ((((value) << (2))) + (((pc) + (4))));
+ value = ((((value) * (4))) + (((pc) + (4))));
fields->f_offset = value;
}
break;
--
Alan Modra
Australia Development Lab, IBM