about summary refs log tree commit diff stats
path: root/miasm2/ir/symbexec.py
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2016-02-16 16:36:43 +0100
committerserpilliere <serpilliere@users.noreply.github.com>2016-02-16 16:36:43 +0100
commit91e9abd906c0a9f5b43bad5b9789ffa1b054f6fe (patch)
tree30f32695bc995a4cd56f902313aad3a1d4a411f4 /miasm2/ir/symbexec.py
parent2cf69707481ba4b0dd163b49d99bc9a021162944 (diff)
parent052c02757c8c7aecabb9d86c30dfd672e46ccfa4 (diff)
downloadmiasm-91e9abd906c0a9f5b43bad5b9789ffa1b054f6fe.tar.gz
miasm-91e9abd906c0a9f5b43bad5b9789ffa1b054f6fe.zip
Merge pull request #325 from commial/jitter-symbexec
Eval_Expr in jitter context
Diffstat (limited to 'miasm2/ir/symbexec.py')
-rw-r--r--miasm2/ir/symbexec.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/miasm2/ir/symbexec.py b/miasm2/ir/symbexec.py
index 9ac79b1f..ba19ccf7 100644
--- a/miasm2/ir/symbexec.py
+++ b/miasm2/ir/symbexec.py
@@ -336,7 +336,6 @@ class symbexec(object):
                 val = self.symbols[a][ptr_diff * 8 + b.size:a.size]
                 out.append((m2_expr.ExprMem(ex, val.size), val))
         return out
-
     # give mem stored overlapping requested mem ptr
     def get_mem_overlapping(self, e, eval_cache=None):
         if eval_cache is None:
@@ -452,3 +451,16 @@ class symbexec(object):
             if m.arg == 1:
                 del self.symbols[mem]
 
+    def apply_expr(self, expr):
+        """Evaluate @expr and apply side effect if needed (ie. if expr is an
+        assignment). Return the evaluated value"""
+
+        # Eval expression
+        to_eval = expr.src if isinstance(expr, m2_expr.ExprAff) else expr
+        ret = self.expr_simp(self.eval_expr(to_eval))
+
+        # Update value if needed
+        if isinstance(expr, m2_expr.ExprAff):
+            self.eval_ir([m2_expr.ExprAff(expr.dst, ret)])
+
+        return ret