about summary refs log tree commit diff stats
path: root/miasm2/jitter
diff options
context:
space:
mode:
Diffstat (limited to 'miasm2/jitter')
-rw-r--r--miasm2/jitter/codegen.py12
-rw-r--r--miasm2/jitter/emulatedsymbexec.py4
-rw-r--r--miasm2/jitter/jitcore.py153
-rw-r--r--miasm2/jitter/jitcore_cc_base.py6
-rw-r--r--miasm2/jitter/jitcore_llvm.py2
-rw-r--r--miasm2/jitter/jitcore_python.py16
-rw-r--r--miasm2/jitter/jitload.py2
-rw-r--r--miasm2/jitter/llvmconvert.py12
8 files changed, 103 insertions, 104 deletions
diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py
index 2503e104..9d005451 100644
--- a/miasm2/jitter/codegen.py
+++ b/miasm2/jitter/codegen.py
@@ -1,7 +1,7 @@
 import miasm2.expression.expression as m2_expr
-from miasm2.ir.ir import irbloc
+from miasm2.ir.ir import IRBlock
 from miasm2.ir.translators import Translator
-from miasm2.core.asmbloc import expr_is_label, asm_block_bad, asm_label
+from miasm2.core.asmblock import expr_is_label, AsmBlockBad, AsmLabel
 
 # Miasm to C translator
 translator = Translator.to_language("C")
@@ -134,7 +134,7 @@ class CGen(object):
                 instr.offset + instr.l,
                 self.ir_arch.IRDst.size)
 
-        return irbloc(self.ir_arch.get_instr_label(instr), [assignblk])
+        return IRBlock(self.ir_arch.get_instr_label(instr), [assignblk])
 
     def block2assignblks(self, block):
         irblocks_list = []
@@ -324,11 +324,11 @@ class CGen(object):
         return out
 
     def gen_goto_code(self, attrib, instr_offsets, dst):
-        if isinstance(dst, asm_label) and dst.offset is None:
+        if isinstance(dst, AsmLabel) 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:
+        if isinstance(dst, AsmLabel) and dst.offset is not None:
             offset = dst.offset
         elif isinstance(dst, (int, long)):
             offset = dst
@@ -545,7 +545,7 @@ class CGen(object):
         @log_regs: log registers
         """
 
-        if isinstance(block, asm_block_bad):
+        if isinstance(block, AsmBlockBad):
             return self.gen_bad_block()
         irblocks_list = self.block2assignblks(block)
 
diff --git a/miasm2/jitter/emulatedsymbexec.py b/miasm2/jitter/emulatedsymbexec.py
index 9ece5ff5..d4a67fe8 100644
--- a/miasm2/jitter/emulatedsymbexec.py
+++ b/miasm2/jitter/emulatedsymbexec.py
@@ -1,8 +1,8 @@
 import miasm2.expression.expression as m2_expr
-from miasm2.ir.symbexec import symbexec
+from miasm2.ir.symbexec import SymbolicExecutionEngine
 
 
-class EmulatedSymbExec(symbexec):
+class EmulatedSymbExec(SymbolicExecutionEngine):
     """Symbolic exec instance linked with a jitter"""
 
     cpuid = {
diff --git a/miasm2/jitter/jitcore.py b/miasm2/jitter/jitcore.py
index 7e831280..0ccbfcd7 100644
--- a/miasm2/jitter/jitcore.py
+++ b/miasm2/jitter/jitcore.py
@@ -15,7 +15,7 @@
 # with this program; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-from miasm2.core import asmbloc
+from miasm2.core import asmblock
 from miasm2.core.interval import interval
 from miasm2.core.utils import BoundedDict
 from miasm2.jitter.csts import *
@@ -55,13 +55,13 @@ class JitCore(object):
                         "max_exec_per_call": 0 # 0 means no limit
                         }
 
-        self.mdis = asmbloc.disasmEngine(ir_arch.arch, ir_arch.attrib, bs,
-                                         lines_wd=self.options["jit_maxline"],
-                                         symbol_pool=ir_arch.symbol_pool,
-                                         follow_call=False,
-                                         dontdis_retcall=False,
-                                         split_dis=self.split_dis,
-                                         dis_bloc_callback=self.disasm_cb)
+        self.mdis = asmblock.disasmEngine(ir_arch.arch, ir_arch.attrib, bs,
+                                          lines_wd=self.options["jit_maxline"],
+                                          symbol_pool=ir_arch.symbol_pool,
+                                          follow_call=False,
+                                          dontdis_retcall=False,
+                                          split_dis=self.split_dis,
+                                          dis_bloc_callback=self.disasm_cb)
 
 
     def set_options(self, **kwargs):
@@ -88,52 +88,52 @@ class JitCore(object):
         "Initialise the Jitter"
         raise NotImplementedError("Abstract class")
 
-    def get_bloc_min_max(self, cur_bloc):
-        "Update cur_bloc to set min/max address"
+    def get_bloc_min_max(self, cur_block):
+        "Update cur_block to set min/max address"
 
-        if cur_bloc.lines:
-            cur_bloc.ad_min = cur_bloc.lines[0].offset
-            cur_bloc.ad_max = cur_bloc.lines[-1].offset + cur_bloc.lines[-1].l
+        if cur_block.lines:
+            cur_block.ad_min = cur_block.lines[0].offset
+            cur_block.ad_max = cur_block.lines[-1].offset + cur_block.lines[-1].l
         else:
             # 1 byte block for unknown mnemonic
-            cur_bloc.ad_min = cur_bloc.label.offset
-            cur_bloc.ad_max = cur_bloc.label.offset+1
+            cur_block.ad_min = cur_block.label.offset
+            cur_block.ad_max = cur_block.label.offset+1
 
 
-    def add_bloc_to_mem_interval(self, vm, bloc):
-        "Update vm to include bloc addresses in its memory range"
+    def add_bloc_to_mem_interval(self, vm, block):
+        "Update vm to include block addresses in its memory range"
 
-        self.blocs_mem_interval += interval([(bloc.ad_min, bloc.ad_max - 1)])
+        self.blocs_mem_interval += interval([(block.ad_min, block.ad_max - 1)])
 
         vm.reset_code_bloc_pool()
         for a, b in self.blocs_mem_interval:
             vm.add_code_bloc(a, b + 1)
 
-    def jitirblocs(self, label, irblocs):
-        """JiT a group of irblocs.
-        @label: the label of the irblocs
-        @irblocs: a gorup of irblocs
+    def jitirblocs(self, label, irblocks):
+        """JiT a group of irblocks.
+        @label: the label of the irblocks
+        @irblocks: a gorup of irblocks
         """
 
         raise NotImplementedError("Abstract class")
 
-    def add_bloc(self, b):
-        """Add a bloc to JiT and JiT it.
-        @b: the bloc to add
+    def add_bloc(self, block):
+        """Add a block to JiT and JiT it.
+        @block: asm_bloc to add
         """
 
-        irblocs = self.ir_arch.add_bloc(b, gen_pc_updt = True)
-        b.irblocs = irblocs
-        self.jitirblocs(b.label, irblocs)
+        irblocks = self.ir_arch.add_bloc(block, gen_pc_updt = True)
+        block.blocks = irblocks
+        self.jitirblocs(block.label, irblocks)
 
     def disbloc(self, addr, vm):
-        """Disassemble a new bloc and JiT it
-        @addr: address of the block to disassemble (asm_label or int)
+        """Disassemble a new block and JiT it
+        @addr: address of the block to disassemble (AsmLabel or int)
         @vm: VmMngr instance
         """
 
-        # Get the bloc
-        if isinstance(addr, asmbloc.asm_label):
+        # Get the block
+        if isinstance(addr, asmblock.AsmLabel):
             addr = addr.offset
 
         # Prepare disassembler
@@ -143,30 +143,30 @@ class JitCore(object):
 
         # Disassemble it
         try:
-            cur_bloc = self.mdis.dis_bloc(addr)
+            cur_block = self.mdis.dis_bloc(addr)
         except IOError:
             # vm_exception_flag is set
             label = self.ir_arch.symbol_pool.getby_offset_create(addr)
-            cur_bloc = asmbloc.asm_block_bad(label)
+            cur_block = asmblock.AsmBlockBad(label)
 
         # Logging
         if self.log_newbloc:
-            print cur_bloc
+            print cur_block
 
-        # Update label -> bloc
-        self.lbl2bloc[cur_bloc.label] = cur_bloc
+        # Update label -> block
+        self.lbl2bloc[cur_block.label] = cur_block
 
-        # Store min/max bloc address needed in jit automod code
-        self.get_bloc_min_max(cur_bloc)
+        # Store min/max block address needed in jit automod code
+        self.get_bloc_min_max(cur_block)
 
         # JiT it
-        self.add_bloc(cur_bloc)
+        self.add_bloc(cur_block)
 
         # Update jitcode mem range
-        self.add_bloc_to_mem_interval(vm, cur_bloc)
+        self.add_bloc_to_mem_interval(vm, cur_block)
 
     def runbloc(self, cpu, lbl, breakpoints):
-        """Run the bloc starting at lbl.
+        """Run the block starting at lbl.
         @cpu: JitCpu instance
         @lbl: target label
         """
@@ -175,80 +175,79 @@ class JitCore(object):
             lbl = getattr(cpu, self.ir_arch.pc.name)
 
         if not lbl in self.lbl2jitbloc:
-            # Need to JiT the bloc
+            # Need to JiT the block
             self.disbloc(lbl, cpu.vmmngr)
 
-        # Run the bloc and update cpu/vmmngr state
+        # Run the block and update cpu/vmmngr state
         return self.exec_wrapper(lbl, cpu, self.lbl2jitbloc.data, breakpoints,
                                  self.options["max_exec_per_call"])
 
-    def blocs2memrange(self, blocs):
-        """Return an interval instance standing for blocs addresses
-        @blocs: list of asm_bloc instances
+    def blocs2memrange(self, blocks):
+        """Return an interval instance standing for blocks addresses
+        @blocks: list of asm_bloc instances
         """
 
         mem_range = interval()
 
-        for b in blocs:
-            mem_range += interval([(b.ad_min, b.ad_max - 1)])
+        for block in blocks:
+            mem_range += interval([(block.ad_min, block.ad_max - 1)])
 
         return mem_range
 
     def __updt_jitcode_mem_range(self, vm):
-        """Rebuild the VM blocs address memory range
+        """Rebuild the VM blocks address memory range
         @vm: VmMngr instance
         """
 
         # Reset the current pool
         vm.reset_code_bloc_pool()
 
-        # Add blocs in the pool
-        for a, b in self.blocs_mem_interval:
-            vm.add_code_bloc(a, b + 1)
+        # Add blocks in the pool
+        for start, stop in self.blocs_mem_interval:
+            vm.add_code_bloc(start, stop + 1)
 
     def del_bloc_in_range(self, ad1, ad2):
-        """Find and remove jitted bloc in range [ad1, ad2].
-        Return the list of bloc removed.
+        """Find and remove jitted block in range [ad1, ad2].
+        Return the list of block removed.
         @ad1: First address
         @ad2: Last address
         """
 
-        # Find concerned blocs
-        modified_blocs = set()
-        for b in self.lbl2bloc.values():
-            if not b.lines:
+        # Find concerned blocks
+        modified_blocks = set()
+        for block in self.lbl2bloc.values():
+            if not block.lines:
                 continue
-            if b.ad_max <= ad1 or b.ad_min >= ad2:
-                # Bloc not modified
+            if block.ad_max <= ad1 or block.ad_min >= ad2:
+                # Block not modified
                 pass
             else:
-                # Modified blocs
-                modified_blocs.add(b)
+                # Modified blocks
+                modified_blocks.add(block)
 
         # Generate interval to delete
-        del_interval = self.blocs2memrange(modified_blocs)
+        del_interval = self.blocs2memrange(modified_blocks)
 
         # Remove interval from monitored interval list
         self.blocs_mem_interval -= del_interval
 
-        # Remove modified blocs
-        for b in modified_blocs:
+        # Remove modified blocks
+        for block in modified_blocks:
             try:
-                for irbloc in b.irblocs:
-
-                    # Remove offset -> jitted bloc link
-                    if irbloc.label.offset in self.lbl2jitbloc:
-                        del(self.lbl2jitbloc[irbloc.label.offset])
+                for irblock in block.blocks:
+                    # Remove offset -> jitted block link
+                    if irblock.label.offset in self.lbl2jitbloc:
+                        del(self.lbl2jitbloc[irblock.label.offset])
 
             except AttributeError:
-                # The bloc has never been translated in IR
-                if b.label.offset in self.lbl2jitbloc:
-                    del(self.lbl2jitbloc[b.label.offset])
+                # The block has never been translated in IR
+                if block.label.offset in self.lbl2jitbloc:
+                    del(self.lbl2jitbloc[block.label.offset])
 
-            # Remove label -> bloc link
-            del(self.lbl2bloc[b.label])
+            # Remove label -> block link
+            del(self.lbl2bloc[block.label])
 
-        return modified_blocs
+        return modified_blocks
 
     def updt_automod_code_range(self, vm, mem_range):
         """Remove jitted code in range @mem_range
diff --git a/miasm2/jitter/jitcore_cc_base.py b/miasm2/jitter/jitcore_cc_base.py
index 2c2d3d52..ae8a5dc2 100644
--- a/miasm2/jitter/jitcore_cc_base.py
+++ b/miasm2/jitter/jitcore_cc_base.py
@@ -88,14 +88,14 @@ class JitCore_Cc_Base(JitCore):
     def label2fname(self, label):
         """
         Generate function name from @label
-        @label: asm_label instance
+        @label: AsmLabel instance
         """
         return "block_%s" % label.name
 
     def gen_c_code(self, label, block):
         """
         Return the C code corresponding to the @irblocks
-        @label: asm_label of the block to jit
+        @label: AsmLabel of the block to jit
         @irblocks: list of irblocks
         """
         f_name = self.label2fname(label)
@@ -113,7 +113,7 @@ class JitCore_Cc_Base(JitCore):
     def hash_block(self, block):
         """
         Build a hash of the block @block
-        @block: asmbloc
+        @block: asmblock
         """
         block_raw = "".join(line.b for line in block.lines)
         block_hash = md5("%X_%s_%s_%s" % (block.label.offset,
diff --git a/miasm2/jitter/jitcore_llvm.py b/miasm2/jitter/jitcore_llvm.py
index 8f58f1da..d082dd79 100644
--- a/miasm2/jitter/jitcore_llvm.py
+++ b/miasm2/jitter/jitcore_llvm.py
@@ -121,7 +121,7 @@ class JitCore_LLVM(jitcore.JitCore):
     def hash_block(self, block):
         """
         Build a hash of the block @block
-        @block: asmbloc
+        @block: asmblock
         """
         block_raw = "".join(line.b for line in block.lines)
         block_hash = md5("%X_%s_%s_%s" % (block.label.offset,
diff --git a/miasm2/jitter/jitcore_python.py b/miasm2/jitter/jitcore_python.py
index a8ecc3d6..cbd582ab 100644
--- a/miasm2/jitter/jitcore_python.py
+++ b/miasm2/jitter/jitcore_python.py
@@ -34,10 +34,10 @@ class JitCore_Python(jitcore.JitCore):
         "Preload symbols according to current architecture"
         self.symbexec.reset_regs()
 
-    def jitirblocs(self, label, irblocs):
-        """Create a python function corresponding to an irblocs' group.
-        @label: the label of the irblocs
-        @irblocs: a gorup of irblocs
+    def jitirblocs(self, label, irblocks):
+        """Create a python function corresponding to an irblocks' group.
+        @label: the label of the irblocks
+        @irblocks: a gorup of irblocks
         """
 
         def myfunc(cpu):
@@ -47,7 +47,7 @@ class JitCore_Python(jitcore.JitCore):
             # Get virtual memory handler
             vmmngr = cpu.vmmngr
 
-            # Keep current location in irblocs
+            # Keep current location in irblocks
             cur_label = label
 
             # Required to detect new instructions
@@ -57,15 +57,15 @@ class JitCore_Python(jitcore.JitCore):
             exec_engine = self.symbexec
             expr_simp = exec_engine.expr_simp
 
-            # For each irbloc inside irblocs
+            # For each irbloc inside irblocks
             while True:
 
                 # Get the current bloc
-                for irb in irblocs:
+                for irb in irblocks:
                     if irb.label == cur_label:
                         break
                 else:
-                    raise RuntimeError("Irblocs must end with returning an "
+                    raise RuntimeError("Irblocks must end with returning an "
                                        "ExprInt instance")
 
                 # Refresh CPU values according to @cpu instance
diff --git a/miasm2/jitter/jitload.py b/miasm2/jitter/jitload.py
index eaeae89a..693dd224 100644
--- a/miasm2/jitter/jitload.py
+++ b/miasm2/jitter/jitload.py
@@ -242,7 +242,7 @@ class jitter:
         "Add common exceptions handlers"
 
         def exception_automod(jitter):
-            "Tell the JiT backend to update blocs modified"
+            "Tell the JiT backend to update blocks modified"
 
             self.jit.updt_automod_code(jitter.vm)
             self.vm.set_exception(0)
diff --git a/miasm2/jitter/llvmconvert.py b/miasm2/jitter/llvmconvert.py
index 527dc733..226a1b8e 100644
--- a/miasm2/jitter/llvmconvert.py
+++ b/miasm2/jitter/llvmconvert.py
@@ -16,7 +16,7 @@ from llvmlite import binding as llvm
 from llvmlite import ir as llvm_ir
 import miasm2.expression.expression as m2_expr
 import miasm2.jitter.csts as m2_csts
-import miasm2.core.asmbloc as m2_asmbloc
+import miasm2.core.asmblock as m2_asmblock
 from miasm2.jitter.codegen import CGen
 from miasm2.expression.expression_helper import possible_values
 
@@ -508,9 +508,9 @@ class LLVMFunction():
         @label: str or asmlabel instance"""
         if isinstance(label, str):
             return label
-        elif isinstance(label, m2_asmbloc.asm_label):
+        elif isinstance(label, m2_asmblock.AsmLabel):
             return "label_%s" % label.name
-        elif m2_asmbloc.expr_is_label(label):
+        elif m2_asmblock.expr_is_label(label):
             return "label_%s" % label.name.name
         else:
             raise ValueError("label must either be str or asmlabel")
@@ -1038,7 +1038,7 @@ class LLVMFunction():
             index = dst2case.get(value, i)
             to_eval = to_eval.replace_expr({value: m2_expr.ExprInt(index, value.size)})
             dst2case[value] = index
-            if m2_asmbloc.expr_is_int_or_label(value):
+            if m2_asmblock.expr_is_int_or_label(value):
                 case2dst[i] = value
             else:
                 case2dst[i] = self.add_ir(value)
@@ -1068,7 +1068,7 @@ class LLVMFunction():
             dst = m2_expr.ExprId(self.llvm_context.ir_arch.symbol_pool.getby_offset_create(int(dst)),
                                  dst.size)
 
-        if m2_asmbloc.expr_is_label(dst):
+        if m2_asmblock.expr_is_label(dst):
             bbl = self.get_basic_bloc_by_label(dst)
             offset = dst.name.offset
             if bbl is not None:
@@ -1276,7 +1276,7 @@ class LLVMFunction():
         self.init_fc()
         self.local_vars_pointers["status"] = self.local_vars["status"]
 
-        if isinstance(asmblock, m2_asmbloc.asm_block_bad):
+        if isinstance(asmblock, m2_asmblock.AsmBlockBad):
             self.gen_bad_block(asmblock)
             return