summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authoryrp <yrp604@protonmail.com>2025-08-19 23:04:48 -0700
committerBrandon Miller <bkmiller89@icloud.com>2025-09-18 07:20:00 -0400
commit8b8d2dd0d39a7c19e6476810ff39a32fc099409e (patch)
treedeba2d509f2609dd31bf57754ab62fef7d88f7e4 /arch
parentece75114e87b6ad80bc21f1825ac96293272951f (diff)
fix ldrsw lift to sign extend in certain encodings
Diffstat (limited to 'arch')
-rwxr-xr-xarch/arm64/arm64test.py5
-rw-r--r--arch/arm64/il.cpp10
2 files changed, 13 insertions, 2 deletions
diff --git a/arch/arm64/arm64test.py b/arch/arm64/arm64test.py
index 447c45f3..90d088c9 100755
--- a/arch/arm64/arm64test.py
+++ b/arch/arm64/arm64test.py
@@ -12125,6 +12125,10 @@ tests_vmul = [
'LLIL_INTRINSIC([v23],vmull_high_laneq_u32,[LLIL_REG.o(v12),LLIL_REG.o(v26),LLIL_CONST.b(0x1)])'),
]
+tests_ldrsw = [
+ (b'\x06\x01\x00\x98', 'LLIL_SET_REG.q(x6,LLIL_SX.q(LLIL_LOAD.d(LLIL_CONST.q(0x20))))'),
+]
+
tests_grab_bag = [
# some vectors loads/stores that do not fill the entire register
# shl v19.2d, v21.2d, #0x2
@@ -12774,6 +12778,7 @@ test_cases = \
tests_raddhn_rshrn + \
tests_ngc_sbc + \
tests_vmul + \
+ tests_ldrsw + \
tests_grab_bag
def il2str(il):
diff --git a/arch/arm64/il.cpp b/arch/arm64/il.cpp
index 22b45a95..85bc98b2 100644
--- a/arch/arm64/il.cpp
+++ b/arch/arm64/il.cpp
@@ -1082,8 +1082,14 @@ static void LoadStoreOperandSize(LowLevelILFunction& il, bool load, bool sign_ex
il.AddInstruction(ILSETREG_O(operand1, tmp));
break;
case LABEL:
- il.AddInstruction(ILSETREG_O(
- operand1, il.Operand(1, il.Load(size, il.ConstPointer(8, IMM_O(operand2))))));
+ tmp = il.Operand(1, il.Load(size, il.ConstPointer(8, IMM_O(operand2))));
+
+ if (sign_extend)
+ tmp = il.SignExtend(extendSize, tmp);
+ else
+ tmp = il.ZeroExtend(extendSize, tmp);
+
+ il.AddInstruction(ILSETREG_O(operand1, tmp));
break;
default:
il.AddInstruction(il.Unimplemented());