From 45a674447579e350cf380dbacba5c5f6360c5ac1 Mon Sep 17 00:00:00 2001 From: Galen Williamson Date: Tue, 12 Mar 2024 13:26:16 -0400 Subject: moved over from https://github.com/Vector35/arch-armv7/pull/81 --- arch/armv7/il.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'arch/armv7/il.cpp') diff --git a/arch/armv7/il.cpp b/arch/armv7/il.cpp index d946e77c..5fbbb729 100644 --- a/arch/armv7/il.cpp +++ b/arch/armv7/il.cpp @@ -312,8 +312,20 @@ static void Load( memValue = il.ZeroExtend(dstSize, memValue); } - il.AddInstruction(SetRegisterOrBranch(il, dst.reg, memValue)); - il.AddInstruction(SetRegisterOrBranch(il, src.reg, value)); + if (dst.reg == REG_PC) + { + // don't update Rd, update Rs, jump to pre-updated Rs + il.AddInstruction(il.SetRegister(4, LLIL_TEMP(0), memValue)); + il.AddInstruction(SetRegisterOrBranch(il, src.reg, value)); + il.AddInstruction(il.Jump(il.Register(4, LLIL_TEMP(0)))); + } + else + { + // set Rd, update Rs, don't jump + il.AddInstruction(il.SetRegister(get_register_size(dst.reg), dst.reg, memValue)); + il.AddInstruction(SetRegisterOrBranch(il, src.reg, value)); + } + break; case MEM_IMM: case LABEL: -- cgit v1.3.1