Skip to content

Commit 8b8d2dd

Browse files
yrp604zznop
authored andcommitted
fix ldrsw lift to sign extend in certain encodings
1 parent ece7511 commit 8b8d2dd

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

arch/arm64/arm64test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12125,6 +12125,10 @@
1212512125
'LLIL_INTRINSIC([v23],vmull_high_laneq_u32,[LLIL_REG.o(v12),LLIL_REG.o(v26),LLIL_CONST.b(0x1)])'),
1212612126
]
1212712127

12128+
tests_ldrsw = [
12129+
(b'\x06\x01\x00\x98', 'LLIL_SET_REG.q(x6,LLIL_SX.q(LLIL_LOAD.d(LLIL_CONST.q(0x20))))'),
12130+
]
12131+
1212812132
tests_grab_bag = [
1212912133
# some vectors loads/stores that do not fill the entire register
1213012134
# shl v19.2d, v21.2d, #0x2
@@ -12774,6 +12778,7 @@
1277412778
tests_raddhn_rshrn + \
1277512779
tests_ngc_sbc + \
1277612780
tests_vmul + \
12781+
tests_ldrsw + \
1277712782
tests_grab_bag
1277812783

1277912784
def il2str(il):

arch/arm64/il.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,8 +1082,14 @@ static void LoadStoreOperandSize(LowLevelILFunction& il, bool load, bool sign_ex
10821082
il.AddInstruction(ILSETREG_O(operand1, tmp));
10831083
break;
10841084
case LABEL:
1085-
il.AddInstruction(ILSETREG_O(
1086-
operand1, il.Operand(1, il.Load(size, il.ConstPointer(8, IMM_O(operand2))))));
1085+
tmp = il.Operand(1, il.Load(size, il.ConstPointer(8, IMM_O(operand2))));
1086+
1087+
if (sign_extend)
1088+
tmp = il.SignExtend(extendSize, tmp);
1089+
else
1090+
tmp = il.ZeroExtend(extendSize, tmp);
1091+
1092+
il.AddInstruction(ILSETREG_O(operand1, tmp));
10871093
break;
10881094
default:
10891095
il.AddInstruction(il.Unimplemented());

0 commit comments

Comments
 (0)