summaryrefslogtreecommitdiff
path: root/arch/riscv/src
diff options
context:
space:
mode:
authorMitchell Johnson <ehntoo@ehntoo.org>2024-11-29 23:12:58 -0500
committerMitchell Johnson <ehntoo@ehntoo.org>2024-11-29 23:17:00 -0500
commit395fd8e15f68db2ecd921c9b93babfc70f74da5b (patch)
treead1abf234e59fc18438713936e122586d8042918 /arch/riscv/src
parentd2ab9e53453273b31a195aa3d64b10fb44d9d18b (diff)
Fix RISC-V JALR lift when rs1==rd
Diffstat (limited to 'arch/riscv/src')
-rw-r--r--arch/riscv/src/lib.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/riscv/src/lib.rs b/arch/riscv/src/lib.rs
index 8970cd3f..342e7af9 100644
--- a/arch/riscv/src/lib.rs
+++ b/arch/riscv/src/lib.rs
@@ -1242,6 +1242,8 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
(1, _, _) => il.call(target).append(), // indirect call
(0, _, _) => il.jump(target).append(), // indirect jump
(_, _, _) => {
+ // store the target in a temporary register so we don't clobber it when rd == rs1
+ il.set_reg(max_width, llil::Register::Temp(0), target).append();
// indirect jump with storage of next address to non-`ra` register
il.set_reg(
max_width,
@@ -1249,7 +1251,7 @@ impl<D: 'static + RiscVDisassembler + Send + Sync> architecture::Architecture fo
il.const_ptr(addr.wrapping_add(inst_len)),
)
.append();
- il.jump(target).append();
+ il.jump(il.reg(max_width, llil::Register::Temp(0))).append();
}
}
}