From: Alan Modra Date: Fri, 20 Dec 2019 04:07:44 +0000 (+1030) Subject: ubsan: or1k: left shift of negative value X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bcd9f578a96b9776e34e5cec963928f5a96b80e7;p=binutils-gdb.git ubsan: or1k: left shift of negative value cpu/ * or1korbis.cpu (f-disp26, f-disp21): Don't left shift negative values. opcodes/ * or1k-ibld.c: Regenerate. --- diff --git a/cpu/ChangeLog b/cpu/ChangeLog index 8755ee70a4d..1729efd266c 100644 --- a/cpu/ChangeLog +++ b/cpu/ChangeLog @@ -1,3 +1,7 @@ +2019-12-20 Alan Modra + + * or1korbis.cpu (f-disp26, f-disp21): Don't left shift negative values. + 2019-12-17 Alan Modra * bpf.cpu (f-imm64): Avoid signed overflow. diff --git a/cpu/or1korbis.cpu b/cpu/or1korbis.cpu index 3741d4c8f7d..a8002a37185 100644 --- a/cpu/or1korbis.cpu +++ b/cpu/or1korbis.cpu @@ -76,7 +76,7 @@ 26 INT ((value pc) (sra IAI (sub IAI value pc) (const 2))) - ((value pc) (add IAI (sll IAI value (const 2)) pc)) + ((value pc) (add IAI (mul IAI value (const 4)) pc)) ) ; PC relative, 21-bit, 13 shifted to right, aligned. @@ -91,7 +91,7 @@ ((value pc) (sub IAI (sra IAI value (const 13)) (sra IAI pc (const 13)))) ((value pc) - (sll IAI (add IAI value (sra IAI pc (const 13))) (const 13))) + (mul IAI (add IAI value (sra IAI pc (const 13))) (const 8192))) ) ; Immediates. diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index e0d2fab410b..377f548e9cf 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,7 @@ +2019-12-20 Alan Modra + + * or1k-ibld.c: Regenerate. + 2019-12-20 Alan Modra * hppa-dis.c (extract_16, extract_21, print_insn_hppa): Use diff --git a/opcodes/or1k-ibld.c b/opcodes/or1k-ibld.c index 6271f5c6d11..57eeb522a62 100644 --- a/opcodes/or1k-ibld.c +++ b/opcodes/or1k-ibld.c @@ -783,7 +783,7 @@ or1k_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0|(1<> (13))))) << (13)); + value = ((((value) + (((DI) (pc) >> (13))))) * (MAKEDI (0, 8192))); fields->f_disp21 = value; } break; @@ -791,7 +791,7 @@ or1k_cgen_extract_operand (CGEN_CPU_DESC cd, { long value; length = extract_normal (cd, ex_info, insn_value, 0|(1<f_disp26 = value; } break;