diff options
| -rw-r--r-- | miasm/analysis/data_flow.py | 27 | ||||
| -rw-r--r-- | miasm/analysis/dse.py | 2 | ||||
| -rw-r--r-- | miasm/arch/mips32/arch.py | 7 | ||||
| -rw-r--r-- | miasm/core/asmblock.py | 1 |
4 files changed, 16 insertions, 21 deletions
diff --git a/miasm/analysis/data_flow.py b/miasm/analysis/data_flow.py index 5202fbd9..ef8a8cb0 100644 --- a/miasm/analysis/data_flow.py +++ b/miasm/analysis/data_flow.py @@ -723,19 +723,6 @@ class SSADefUse(DiGraph): - -def expr_test_visit(expr, test): - result = set() - expr.visit( - lambda expr: expr, - lambda expr: test(expr, result) - ) - if result: - return True - else: - return False - - def expr_has_mem(expr): """ Return True if expr contains at least one memory access @@ -1055,7 +1042,11 @@ def visitor_get_stack_accesses(ir_arch_a, expr, stack_vars): def get_stack_accesses(ir_arch_a, expr): result = set() - expr.visit(lambda expr:visitor_get_stack_accesses(ir_arch_a, expr, result)) + def get_stack(expr_to_test): + visitor_get_stack_accesses(ir_arch_a, expr_to_test, result) + return None + visitor = ExprWalk(get_stack) + visitor.visit(expr) return result @@ -1201,11 +1192,13 @@ def memlookup_test(expr, bs, is_addr_ro_variable, result): def memlookup_visit(expr, bs, is_addr_ro_variable): result = set() - expr.visit(lambda expr: expr, - lambda expr: memlookup_test(expr, bs, is_addr_ro_variable, result)) + def retrieve_memlookup(expr_to_test): + memlookup_test(expr_to_test, bs, is_addr_ro_variable, result) + return None + visitor = ExprWalk(retrieve_memlookup) + visitor.visit(expr) return result - def get_memlookup(expr, bs, is_addr_ro_variable): return memlookup_visit(expr, bs, is_addr_ro_variable) diff --git a/miasm/analysis/dse.py b/miasm/analysis/dse.py index ec76e60b..9cc342c7 100644 --- a/miasm/analysis/dse.py +++ b/miasm/analysis/dse.py @@ -258,7 +258,7 @@ class DSEEngine(object): # lambda cannot contain statement def default_func(dse): - fname = b"%s_symb" % libimp.fad2cname[dse.jitter.pc] + fname = b"%s_symb" % force_bytes(libimp.fad2cname[dse.jitter.pc]) raise RuntimeError("Symbolic stub '%s' not found" % fname) for addr, fname in viewitems(libimp.fad2cname): diff --git a/miasm/arch/mips32/arch.py b/miasm/arch/mips32/arch.py index d0403ba0..f1e52585 100644 --- a/miasm/arch/mips32/arch.py +++ b/miasm/arch/mips32/arch.py @@ -95,8 +95,9 @@ class instruction_mips32(cpu.instruction): def dstflow2label(self, loc_db): if self.name in ["J", 'JAL']: - expr = int(self.args[0]) - addr = (self.offset & (0xFFFFFFFF ^ ((1<< 28)-1))) + expr + expr = self.args[0] + offset = int(expr) + addr = ((self.offset & (0xFFFFFFFF ^ ((1<< 28)-1))) + offset) & int(expr.mask) loc_key = loc_db.get_or_create_offset_location(addr) self.args[0] = ExprLoc(loc_key, expr.size) return @@ -106,7 +107,7 @@ class instruction_mips32(cpu.instruction): if not isinstance(expr, ExprInt): return - addr = int(expr) + self.offset + addr = (int(expr) + self.offset) & int(expr.mask) loc_key = loc_db.get_or_create_offset_location(addr) self.args[ndx] = ExprLoc(loc_key, expr.size) diff --git a/miasm/core/asmblock.py b/miasm/core/asmblock.py index abd2b2c6..93ad6b13 100644 --- a/miasm/core/asmblock.py +++ b/miasm/core/asmblock.py @@ -628,6 +628,7 @@ class AsmCFG(DiGraph): This method should be called if a block's '.bto' in nodes have been modified without notifying this instance to resynchronize edges. """ + self._pendings = {} for block in self.blocks: edges = [] # Rebuild edges from bto |