From 88f8da118909aaa2500947585312b6c5ac7c2c87 Mon Sep 17 00:00:00 2001 From: Henny Sipma Date: Sun, 12 Oct 2025 21:54:38 -0700 Subject: [PATCH 1/2] ASTI: address missing reaching defs --- chb/app/CHVersion.py | 2 +- chb/astinterface/ASTICodeTransformer.py | 9 +++++++-- chb/astinterface/ASTIProvenance.py | 2 ++ chb/astinterface/ASTInterfaceBasicBlock.py | 7 +++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/chb/app/CHVersion.py b/chb/app/CHVersion.py index 94759afc..4f472907 100644 --- a/chb/app/CHVersion.py +++ b/chb/app/CHVersion.py @@ -1 +1 @@ -chbversion: str = "0.3.0-20251011" +chbversion: str = "0.3.0-20251012" diff --git a/chb/astinterface/ASTICodeTransformer.py b/chb/astinterface/ASTICodeTransformer.py index 76b94c2c..fa262604 100644 --- a/chb/astinterface/ASTICodeTransformer.py +++ b/chb/astinterface/ASTICodeTransformer.py @@ -72,8 +72,13 @@ def transform_block_stmt(self, stmt: AST.ASTBlock) -> AST.ASTStmt: for s in stmt.stmts: newstmt = s.transform(self) # prune empty blocks that may have been created by the pruning - # of redundant if statements - if newstmt.is_ast_block and len((cast(AST.ASTBlock, newstmt)).stmts) == 0: + # of redundant if statements. + # StmtLabels may be intermixed with statements, hence the check + # for is_stmt_label. + if ( + not newstmt.is_stmt_label + and newstmt.is_ast_block + and len((cast(AST.ASTBlock, newstmt)).stmts) == 0): continue newstmts.append(newstmt) diff --git a/chb/astinterface/ASTIProvenance.py b/chb/astinterface/ASTIProvenance.py index 838c7851..f06b49b9 100644 --- a/chb/astinterface/ASTIProvenance.py +++ b/chb/astinterface/ASTIProvenance.py @@ -426,6 +426,8 @@ def resolve_reaching_defs(self) -> None: for rd in rds: rd = cast("ReachingDefFact", rd) v = str(rd.variable) + if v == "PC": + continue addrs = [str(d) for d in rd.deflocations] for addr in addrs: if addr == "init": diff --git a/chb/astinterface/ASTInterfaceBasicBlock.py b/chb/astinterface/ASTInterfaceBasicBlock.py index 394babb6..f59181a7 100644 --- a/chb/astinterface/ASTInterfaceBasicBlock.py +++ b/chb/astinterface/ASTInterfaceBasicBlock.py @@ -542,6 +542,11 @@ def trampoline_takedown_ast(self, astree: "ASTInterface") -> AST.ASTStmt: raise UF.CHBError("Internal error") return self.trampoline_block_ast("fallthrough", astree) + def trampoline_continue_ast(self, astree: "ASTInterface") -> AST.ASTStmt: + if not self.is_trampoline: + raise UF.CHBError("Internal error") + return self.trampoline_block_ast("continuepath", astree) + def trampoline_ast(self, astree: "ASTInterface") -> AST.ASTStmt: stmts: List[AST.ASTStmt] = [] @@ -562,4 +567,6 @@ def trampoline_ast(self, astree: "ASTInterface") -> AST.ASTStmt: str(len(self.trampoline_payload_roles))) if "fallthrough" in self.trampoline: stmts.append(self.trampoline_takedown_ast(astree)) + if "continuepath" in self.trampoline: + stmts.append(self.trampoline_continue_ast(astree)) return astree.mk_block(stmts) From 493d3a24b1fdd8e65d24f7cf11d644b36e3770be Mon Sep 17 00:00:00 2001 From: Henny Sipma Date: Sun, 12 Oct 2025 23:35:28 -0700 Subject: [PATCH 2/2] ASTI: temporarily silence new warnings for payload addresses --- chb/astinterface/ASTIProvenance.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/chb/astinterface/ASTIProvenance.py b/chb/astinterface/ASTIProvenance.py index f06b49b9..511049f7 100644 --- a/chb/astinterface/ASTIProvenance.py +++ b/chb/astinterface/ASTIProvenance.py @@ -461,10 +461,12 @@ def resolve_reaching_defs(self) -> None: + "not found", str(v)) else: - chklogger.logger.warning( - "Reaching definition address %s for variable %s " - + " not found", - str(addr), str(v)) + # temporarily silence warnings for payload addresses + if not addr.startswith("F"): + chklogger.logger.warning( + "Reaching definition address %s for variable %s " + + " not found", + str(addr), str(v)) def resolve_flag_reaching_defs(self) -> None: