def target_expr_ast(self, astree: AbstractSyntaxTree, xdata: InstrXData) -> ASTExpr: calltarget = xdata.call_target(self.ixd) tgtname = calltarget.name if calltarget.is_app_target: apptgt = cast("AppTarget", calltarget) return astree.mk_global_variable_expr(tgtname, globaladdress=int( str(apptgt.address), 16)) else: return astree.mk_global_variable_expr(tgtname)
def ast_rvalue( self, astree: AbstractSyntaxTree ) -> Tuple[AST.ASTExpr, List[AST.ASTInstruction], List[AST.ASTInstruction]]: gvname = "gv_" + self.address.get_hex() gv = astree.mk_global_variable_expr( gvname, globaladdress=self.address.get_int()) return (gv, [], [])
def assembly_ast(self, astree: AbstractSyntaxTree, iaddr: str, bytestring: str, xdata: InstrXData) -> List[ASTInstruction]: lhs = astree.mk_register_variable_lval("R0") tgt = self.operands[0] if tgt.is_absolute: tgtaddr = cast(ARMAbsoluteOp, tgt.opkind) if self.app.has_function_name(tgtaddr.address.get_hex()): faddr = tgtaddr.address.get_hex() fnsymbol = self.app.function_name(faddr) tgtxpr: ASTExpr = astree.mk_global_variable_expr( fnsymbol, globaladdress=int(str(tgtaddr.address), 16)) else: (tgtxpr, _, _) = self.operands[0].ast_rvalue(astree) else: (tgtxpr, _, _) = self.operands[0].ast_rvalue(astree) call = astree.mk_call(lhs, tgtxpr, []) astree.add_instruction_span(call.id, iaddr, bytestring) return [call]