about summary refs log tree commit diff stats
path: root/miasm2/jitter/codegen.py
diff options
context:
space:
mode:
Diffstat (limited to 'miasm2/jitter/codegen.py')
-rw-r--r--miasm2/jitter/codegen.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py
index fff707e5..2503e104 100644
--- a/miasm2/jitter/codegen.py
+++ b/miasm2/jitter/codegen.py
@@ -324,10 +324,20 @@ class CGen(object):
         return out
 
     def gen_goto_code(self, attrib, instr_offsets, dst):
+        if isinstance(dst, asm_label) and dst.offset is None:
+            # Generate goto for local labels
+            return ['goto %s;' % dst.name]
+        offset = None
+        if isinstance(dst, asm_label) and dst.offset is not None:
+            offset = dst.offset
+        elif isinstance(dst, (int, long)):
+            offset = dst
         out = []
-        if isinstance(dst, asm_label):
-            out.append('goto %s;' % dst.name)
-        elif dst in instr_offsets:
+        if (offset is not None and
+            offset > attrib.instr.offset and
+            offset in instr_offsets):
+            # Only generate goto for next instructions.
+            # (consecutive instructions)
             lbl = self.ir_arch.symbol_pool.getby_offset_create(dst)
             out += self.gen_post_code(attrib)
             out += self.gen_post_instr_checks(attrib, dst)