diff options
| author | serpilliere <serpilliere@users.noreply.github.com> | 2016-12-22 14:11:30 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-22 14:11:30 +0100 |
| commit | 00b27c5a291e201e65987c54899f547e802177e4 (patch) | |
| tree | c42b56704bb109d86265963a1e53914ad0826f82 /miasm2/ir/symbexec.py | |
| parent | 5f8ba4cb1b84d3af4ebed46c6a9b3120eb50233e (diff) | |
| parent | c72b9052db4bb1ee596ee3d05ef49f9f7d71f5c1 (diff) | |
| download | miasm-00b27c5a291e201e65987c54899f547e802177e4.tar.gz miasm-00b27c5a291e201e65987c54899f547e802177e4.zip | |
Merge pull request #457 from commial/feature/apply_change
Regression test for apply_expr/apply_change/eval_ir
Diffstat (limited to '')
| -rw-r--r-- | miasm2/ir/symbexec.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/miasm2/ir/symbexec.py b/miasm2/ir/symbexec.py index db3eacdc..2bb99e5d 100644 --- a/miasm2/ir/symbexec.py +++ b/miasm2/ir/symbexec.py @@ -392,6 +392,28 @@ class symbexec(object): return pool_out.iteritems() + def apply_change(self, dst, src): + """ + Apply @dst = @src on the current state WITHOUT evaluating both side + @dst: Expr, destination + @src: Expr, source + """ + if isinstance(dst, m2_expr.ExprMem): + mem_overlap = self.get_mem_overlapping(dst) + for _, base in mem_overlap: + diff_mem = self.substract_mems(base, dst) + del self.symbols[base] + for new_mem, new_val in diff_mem: + self.symbols[new_mem] = new_val + src_o = self.expr_simp(src) + self.symbols[dst] = src_o + if dst == src_o: + del self.symbols[dst] + if isinstance(dst, m2_expr.ExprMem): + if self.func_write and isinstance(dst.arg, m2_expr.ExprInt): + self.func_write(self, dst, src_o) + del self.symbols[dst] + def eval_ir(self, assignblk): """ Apply an AssignBlock on the current state @@ -400,21 +422,8 @@ class symbexec(object): mem_dst = [] src_dst = self.eval_ir_expr(assignblk) for dst, src in src_dst: + self.apply_change(dst, src) if isinstance(dst, m2_expr.ExprMem): - mem_overlap = self.get_mem_overlapping(dst) - for _, base in mem_overlap: - diff_mem = self.substract_mems(base, dst) - del self.symbols[base] - for new_mem, new_val in diff_mem: - self.symbols[new_mem] = new_val - src_o = self.expr_simp(src) - self.symbols[dst] = src_o - if dst == src_o: - del self.symbols[dst] - if isinstance(dst, m2_expr.ExprMem): - if self.func_write and isinstance(dst.arg, m2_expr.ExprInt): - self.func_write(self, dst, src_o) - del self.symbols[dst] mem_dst.append(dst) return mem_dst |