diff options
Diffstat (limited to 'miasm2/jitter/jitcore_llvm.py')
| -rw-r--r-- | miasm2/jitter/jitcore_llvm.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/miasm2/jitter/jitcore_llvm.py b/miasm2/jitter/jitcore_llvm.py index 452b6d84..ea4f20ec 100644 --- a/miasm2/jitter/jitcore_llvm.py +++ b/miasm2/jitter/jitcore_llvm.py @@ -8,7 +8,6 @@ import Jitllvm class JitCore_LLVM(jitcore.JitCore): - "JiT management, using LLVM as backend" # Architecture dependant libraries @@ -20,8 +19,8 @@ class JitCore_LLVM(jitcore.JitCore): "ppc32": "JitCore_ppc32.so", } - def __init__(self, ir_arch, bs=None): - super(JitCore_LLVM, self).__init__(ir_arch, bs) + def __init__(self, ir_arch, bin_stream): + super(JitCore_LLVM, self).__init__(ir_arch, bin_stream) self.options.update({"safe_mode": True, # Verify each function "optimise": True, # Optimise functions @@ -29,7 +28,7 @@ class JitCore_LLVM(jitcore.JitCore): "log_assembly": False, # Print assembly executed }) - self.exec_wrapper = Jitllvm.llvm_exec_bloc + self.exec_wrapper = Jitllvm.llvm_exec_block self.ir_arch = ir_arch # Cache temporary dir @@ -74,16 +73,17 @@ class JitCore_LLVM(jitcore.JitCore): # Enable caching self.context.enable_cache() - def add_bloc(self, block): + def add_block(self, block): """Add a block to JiT and JiT it. @block: the block to add """ + block_hash = self.hash_block(block) fname_out = os.path.join(self.tempdir, "%s.bc" % block_hash) if not os.access(fname_out, os.R_OK): # Build a function in the context - func = LLVMFunction(self.context, LLVMFunction.canonize_label_name(block.label)) + func = LLVMFunction(self.context, self.FUNCNAME) # Set log level func.log_regs = self.log_regs @@ -114,7 +114,9 @@ class JitCore_LLVM(jitcore.JitCore): else: # The cache file exists: function can be loaded from cache - ptr = self.context.get_ptr_from_cache(fname_out, LLVMFunction.canonize_label_name(block.label)) + ptr = self.context.get_ptr_from_cache(fname_out, self.FUNCNAME) # Store a pointer on the function jitted code - self.lbl2jitbloc[block.label.offset] = ptr + loc_key = block.loc_key + offset = self.ir_arch.loc_db.get_location_offset(loc_key) + self.offset_to_jitted_func[offset] = ptr |