aboutsummaryrefslogtreecommitdiff
path: root/opcodes/epiphany-ibld.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2019-12-10 18:06:09 +1030
committerAlan Modra <amodra@gmail.com>2019-12-11 11:34:33 +1030
commitb8e61daa1ad56330fd8931c8a53bfa16d8e4a47a (patch)
treeba543454bcef55c770165f89c0430044b063c24e /opcodes/epiphany-ibld.c
parent8ff23dba80b80a9f47d75dd43812e041f6674763 (diff)
downloadbinutils-b8e61daa1ad56330fd8931c8a53bfa16d8e4a47a.zip
binutils-b8e61daa1ad56330fd8931c8a53bfa16d8e4a47a.tar.gz
binutils-b8e61daa1ad56330fd8931c8a53bfa16d8e4a47a.tar.bz2
ubsan: epiphany: left shift of negative value
Two places in epiphany_cgen_extract_operand, "value" is a long. value = ((((value) << (1))) + (pc)); cpu/ * epiphany.cpu (f-simm8, f-simm24): Use multiply rather than shift left to avoid UB on left shift of negative values. opcodes/ * epiphany-ibld.c: Regenerate.
Diffstat (limited to 'opcodes/epiphany-ibld.c')
-rw-r--r--opcodes/epiphany-ibld.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/opcodes/epiphany-ibld.c b/opcodes/epiphany-ibld.c
index 83cfaf3..6e6fd7b 100644
--- a/opcodes/epiphany-ibld.c
+++ b/opcodes/epiphany-ibld.c
@@ -1100,7 +1100,7 @@ epiphany_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_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 31, 24, 32, total_length, pc, & value);
- value = ((((value) << (1))) + (pc));
+ value = ((((value) * (2))) + (pc));
fields->f_simm24 = value;
}
break;
@@ -1111,7 +1111,7 @@ epiphany_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_RELOC)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 8, 32, total_length, pc, & value);
- value = ((((value) << (1))) + (pc));
+ value = ((((value) * (2))) + (pc));
fields->f_simm8 = value;
}
break;