about summary refs log tree commit diff stats
path: root/miasm2/jitter/jitcore_python.py
diff options
context:
space:
mode:
authorajax <devnull@localhost>2014-06-16 19:08:20 +0200
committerajax <devnull@localhost>2014-06-16 19:08:20 +0200
commit192120822e63f7aef18bd8bd4542b315e29565b4 (patch)
tree64d4f292375a944089c9c4e76e9ea6dc1196dfba /miasm2/jitter/jitcore_python.py
parentb757efa9d13ede65938049dcfc4f46a642ce2f44 (diff)
downloadfocaccia-miasm-192120822e63f7aef18bd8bd4542b315e29565b4.tar.gz
focaccia-miasm-192120822e63f7aef18bd8bd4542b315e29565b4.zip
Jitter Python: check all memory exceptions only on new instruction (in assembly)
Diffstat (limited to 'miasm2/jitter/jitcore_python.py')
-rw-r--r--miasm2/jitter/jitcore_python.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/miasm2/jitter/jitcore_python.py b/miasm2/jitter/jitcore_python.py
index 7dc0b710..90c8bace 100644
--- a/miasm2/jitter/jitcore_python.py
+++ b/miasm2/jitter/jitcore_python.py
@@ -114,6 +114,9 @@ class JitCore_Python(jitcore.JitCore):
             cur_label = label
             loop = True
 
+            # Required to detect new instructions
+            offsets_jitted = set()
+
             # Get exec engine
             exec_engine = self.symbexec
 
@@ -135,12 +138,17 @@ class JitCore_Python(jitcore.JitCore):
 
                 # Execute current ir bloc
                 for ir, line in zip(irb.irs, irb.lines):
-                    # Check for memory exception
-                    if (vmmngr.vm_get_exception() != 0):
-                        update_cpu_from_engine(cpu, exec_engine)
-                        return line.offset
 
-                    # Eval current instruction
+                    # For each new instruction (in assembly)
+                    if line.offset not in offsets_jitted:
+                        offsets_jitted.add(line.offset)
+
+                        # Check for memory exception
+                        if (vmmngr.vm_get_exception() != 0):
+                            update_cpu_from_engine(cpu, exec_engine)
+                            return line.offset
+
+                    # Eval current instruction (in IR)
                     exec_engine.eval_ir(ir)
 
                     # Check for memory exception which do not update PC