Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chb/app/CHVersion.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
chbversion: str = "0.3.0-20250819"
chbversion: str = "0.3.0-20250821"
6 changes: 6 additions & 0 deletions chb/arm/ARMInstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ def has_condition_block_condition(self) -> bool:
def get_instruction_condition(self) -> XXpr:
return self.xdata.get_instruction_condition()

def has_valid_instruction_c_condition(self) -> bool:
return self.xdata.has_valid_instruction_c_condition()

def get_instruction_c_condition(self) -> XXpr:
return self.xdata.get_instruction_c_condition()

@property
def memory_accesses(self) -> Sequence[MemoryAccess]:
return self.opcode.memory_accesses(self.xdata)
Expand Down
5 changes: 4 additions & 1 deletion chb/ast/ASTViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def visit_block_stmt(self, stmt: AST.ASTBlock) -> None:
self.add_edge(name, self.label_name(label))
label.accept(self)
for s in stmt.stmts:
self.add_edge(name, self.stmt_name(s))
if s.is_stmt_label:
print("DEBUG: stmt-label in list of stmts at location: " + str(s.locationid))
else:
self.add_edge(name, self.stmt_name(s))
s.accept(self)

def visit_loop_stmt(self, stmt: AST.ASTLoop) -> None:
Expand Down
6 changes: 3 additions & 3 deletions chb/ast/pirinspector
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def parse() -> argparse.Namespace:
"--fileformat",
help="desired format for output file (default is pdf)",
choices=["pdf", "png"],
default=["pdf"]
default="pdf"
)
viewastcmd.add_argument(
"-o",
Expand All @@ -114,7 +114,7 @@ def parse() -> argparse.Namespace:
"--fileformat",
help="desired format for output file (default is pdf)",
choices=["pdf", "png"],
default=["pdf"]
default="pdf"
)
viewstmtcmd.add_argument(
"-o", "--output",
Expand All @@ -139,7 +139,7 @@ def parse() -> argparse.Namespace:
"--fileformat",
help="desired format for output file (default is pdf)",
choices=["pdf", "png"],
default=["pdf"]
default="pdf"
)
viewinstrcmd.add_argument(
"-o",
Expand Down
16 changes: 13 additions & 3 deletions chb/astinterface/ASTInterfaceBasicBlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,12 @@ def trampoline_payload_ast(self, astree: "ASTInterface") -> AST.ASTStmt:

# case 1
if chkinstr2.mnemonic_stem == "MOV":
chkinstr2 = cast("ARMInstruction", chkinstr2)
if chkinstr2.has_instruction_condition():
condition = chkinstr2.get_instruction_condition()
if chkinstr2.has_valid_instruction_c_condition():
condition = chkinstr2.get_instruction_c_condition()
else:
condition = chkinstr2.get_instruction_condition()
rstmt = astree.mk_return_stmt(None)
estmt = astree.mk_instr_sequence([])
cc = XU.xxpr_to_ast_def_expr(condition,
Expand All @@ -360,7 +364,10 @@ def trampoline_payload_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
if (
chkinstr3.has_instruction_condition()
and chkinstr4.has_instruction_condition()):
condition = chkinstr3.get_instruction_condition()
if chkinstr3.has_valid_instruction_c_condition():
condition = chkinstr3.get_instruction_c_condition()
else:
condition = chkinstr3.get_instruction_condition()
rstmt = astree.mk_return_stmt(None)
estmt = astree.mk_instr_sequence([])
cc = XU.xxpr_to_ast_def_expr(condition,
Expand All @@ -382,7 +389,10 @@ def trampoline_payload_ast(self, astree: "ASTInterface") -> AST.ASTStmt:
chkinstr3 = cast("ARMInstruction", chkinstr3)
if chkinstr3.mnemonic_stem == "MOV":
if chkinstr3.has_instruction_condition():
condition = chkinstr3.get_instruction_condition()
if chkinstr3.has_valid_instruction_c_condition():
condition = chkinstr3.get_instruction_c_condition()
else:
condition = chkinstr3.get_instruction_condition()
chkopc2 = chkinstr2.opcode
chkopc2 = cast("ARMLogicalShiftLeft", chkopc2)
lslxdata = chkopc2.lsl_xdata(chkinstr2.xdata)
Expand Down