about summary refs log tree commit diff stats
path: root/miasm2/jitter/codegen.py
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2017-04-18 16:03:04 +0200
committerCamille Mougey <commial@gmail.com>2017-04-18 16:03:04 +0200
commit2580f884fcbaaf29ae235f0f10d5ed62f6ffdf22 (patch)
tree9c77991accffe970a7bca66128f6b13334e03905 /miasm2/jitter/codegen.py
parent66914aadcef60d590468f39a44d710aa28b0b772 (diff)
downloadmiasm-2580f884fcbaaf29ae235f0f10d5ed62f6ffdf22.tar.gz
miasm-2580f884fcbaaf29ae235f0f10d5ed62f6ffdf22.zip
Jitter: fix symb cache name (#525)
Diffstat (limited to 'miasm2/jitter/codegen.py')
-rw-r--r--miasm2/jitter/codegen.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py
index 9158aeba..09a6fecf 100644
--- a/miasm2/jitter/codegen.py
+++ b/miasm2/jitter/codegen.py
@@ -106,6 +106,11 @@ class CGen(object):
 
         self.C_PC = self.id_to_c(self.PC)
 
+    @staticmethod
+    def label_to_jitlabel(lbl):
+        assert lbl.offset is not None
+        return "jitblock_%X" % lbl.offset
+
     def dst_to_c(self, src):
         if not isinstance(src, m2_expr.Expr):
             src = m2_expr.ExprInt(src, self.PC.size)
@@ -340,7 +345,7 @@ class CGen(object):
             lbl = self.ir_arch.symbol_pool.getby_offset_create(dst)
             out += self.gen_post_code(attrib)
             out += self.gen_post_instr_checks(attrib)
-            out.append('goto %s;' % lbl.name)
+            out.append('goto %s;' % self.label_to_jitlabel(lbl))
         else:
             out += self.gen_post_code(attrib)
             out.append('BlockDst->address = DST_value;')
@@ -496,7 +501,7 @@ class CGen(object):
         instr_offsets = [line.offset for line in block.lines]
         instr_offsets.append(self.get_block_post_label(block).offset)
         lbl_start = self.ir_arch.symbol_pool.getby_offset_create(instr_offsets[0])
-        return (self.CODE_INIT % lbl_start.name).split("\n"), instr_offsets
+        return (self.CODE_INIT % self.label_to_jitlabel(lbl_start)).split("\n"), instr_offsets
 
     def gen_irblock(self, attrib, instr_offsets, instr, irblock):
         """
@@ -534,7 +539,7 @@ class CGen(object):
 
         lbl = self.get_block_post_label(block)
         dst = self.dst_to_c(lbl.offset)
-        code = self.CODE_RETURN_NO_EXCEPTION % (lbl.name, self.C_PC, dst, dst)
+        code = self.CODE_RETURN_NO_EXCEPTION % (self.label_to_jitlabel(lbl), self.C_PC, dst, dst)
         return code.split('\n')
 
     def gen_c(self, block, log_mn=False, log_regs=False):
@@ -557,8 +562,12 @@ class CGen(object):
                 self.ir_arch.irbloc_fix_regs_for_mode(
                     irblock, self.ir_arch.attrib)
 
-                out.append("%-40s // %.16X %s" %
-                           (str(irblock.label.name) + ":", instr.offset, instr))
+                if irblock.label.offset is None:
+                    out.append("%-40s // %.16X %s" %
+                               (str(irblock.label.name) + ":", instr.offset, instr))
+                else:
+                    out.append("%-40s // %.16X %s" %
+                               (self.label_to_jitlabel(irblock.label) + ":", instr.offset, instr))
                 if index == 0:
                     out += self.gen_pre_code(attrib)
                 out += self.gen_irblock(attrib, instr_offsets, instr, irblock)