Skip to content

Commit a872917

Browse files
committed
[RISC-V] Fix lift of JAL by setting return register
1 parent e8a3449 commit a872917

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

arch/riscv/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,16 @@ impl<D: RiscVDisassembler> Architecture for RiscVArch<D> {
12551255
Op::Jal(j) => {
12561256
let target = addr.wrapping_add(j.imm() as i64 as u64);
12571257

1258+
if j.rd().id() != 0 && j.rd().id() != 1 {
1259+
// Return address stored in non-ra
1260+
il.set_reg(
1261+
max_width,
1262+
Register::from(j.rd()),
1263+
il.const_ptr(addr.wrapping_add(inst_len)),
1264+
)
1265+
.append();
1266+
}
1267+
12581268
match (j.rd().id(), il.label_for_address(target)) {
12591269
(0, Some(mut l)) => il.goto(&mut l),
12601270
(0, None) => il.jump(il.const_ptr(target)),

0 commit comments

Comments
 (0)