Skip to content

Commit 3418169

Browse files
committed
ASTI: use c conditions in trampoline
1 parent 593f825 commit 3418169

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

chb/arm/ARMInstruction.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,12 @@ def has_condition_block_condition(self) -> bool:
264264
def get_instruction_condition(self) -> XXpr:
265265
return self.xdata.get_instruction_condition()
266266

267+
def has_valid_instruction_c_condition(self) -> bool:
268+
return self.xdata.has_valid_instruction_c_condition()
269+
270+
def get_instruction_c_condition(self) -> XXpr:
271+
return self.xdata.get_instruction_c_condition()
272+
267273
@property
268274
def memory_accesses(self) -> Sequence[MemoryAccess]:
269275
return self.opcode.memory_accesses(self.xdata)

chb/astinterface/ASTInterfaceBasicBlock.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,12 @@ def trampoline_payload_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
341341

342342
# case 1
343343
if chkinstr2.mnemonic_stem == "MOV":
344+
chkinstr2 = cast("ARMInstruction", chkinstr2)
344345
if chkinstr2.has_instruction_condition():
345-
condition = chkinstr2.get_instruction_condition()
346+
if chkinstr2.has_valid_instruction_c_condition():
347+
condition = chkinstr2.get_instruction_c_condition()
348+
else:
349+
condition = chkinstr2.get_instruction_condition()
346350
rstmt = astree.mk_return_stmt(None)
347351
estmt = astree.mk_instr_sequence([])
348352
cc = XU.xxpr_to_ast_def_expr(condition,
@@ -360,7 +364,10 @@ def trampoline_payload_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
360364
if (
361365
chkinstr3.has_instruction_condition()
362366
and chkinstr4.has_instruction_condition()):
363-
condition = chkinstr3.get_instruction_condition()
367+
if chkinstr3.has_valid_instruction_c_condition():
368+
condition = chkinstr3.get_instruction_c_condition()
369+
else:
370+
condition = chkinstr3.get_instruction_condition()
364371
rstmt = astree.mk_return_stmt(None)
365372
estmt = astree.mk_instr_sequence([])
366373
cc = XU.xxpr_to_ast_def_expr(condition,
@@ -382,7 +389,10 @@ def trampoline_payload_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
382389
chkinstr3 = cast("ARMInstruction", chkinstr3)
383390
if chkinstr3.mnemonic_stem == "MOV":
384391
if chkinstr3.has_instruction_condition():
385-
condition = chkinstr3.get_instruction_condition()
392+
if chkinstr3.has_valid_instruction_c_condition():
393+
condition = chkinstr3.get_instruction_c_condition()
394+
else:
395+
condition = chkinstr3.get_instruction_condition()
386396
chkopc2 = chkinstr2.opcode
387397
chkopc2 = cast("ARMLogicalShiftLeft", chkopc2)
388398
lslxdata = chkopc2.lsl_xdata(chkinstr2.xdata)

0 commit comments

Comments
 (0)