diff options
Diffstat (limited to 'miasm2/jitter/emulatedsymbexec.py')
| -rw-r--r-- | miasm2/jitter/emulatedsymbexec.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/miasm2/jitter/emulatedsymbexec.py b/miasm2/jitter/emulatedsymbexec.py index a5e4d340..f7c48227 100644 --- a/miasm2/jitter/emulatedsymbexec.py +++ b/miasm2/jitter/emulatedsymbexec.py @@ -81,3 +81,22 @@ class EmulatedSymbExec(symbexec): self.symbols.symbols_id[symbol] = value else: raise NotImplementedError("Type not handled: %s" % symbol) + + # CPU specific simplifications + def _simp_handle_segm(self, e_s, expr): + """Handle 'segm' operation""" + if expr.op != "segm": + return expr + segm_nb = int(expr.args[0].arg) + segmaddr = self.cpu.get_segm_base(segm_nb) + return e_s(m2_expr.ExprOp("+", + m2_expr.ExprInt(segmaddr, expr.size), + expr.args[1])) + + def enable_emulated_simplifications(self): + """Enable simplifications needing a CPU instance on associated + ExpressionSimplifier + """ + self.expr_simp.enable_passes({ + m2_expr.ExprOp: [self._simp_handle_segm] + }) |