diff options
| author | Ajax <commial@gmail.com> | 2016-06-23 17:11:18 +0200 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2016-06-23 17:11:18 +0200 |
| commit | 6ba0ebc7bb13f7aa9311f21fd3e860c4687ff993 (patch) | |
| tree | e86017d4bdc45a6ccf431465658c4bcd6487d008 /miasm2/jitter/jitcore_gcc.py | |
| parent | fc97ad6e01f46dde14919e63a9274e7832624f0c (diff) | |
| download | miasm-6ba0ebc7bb13f7aa9311f21fd3e860c4687ff993.tar.gz miasm-6ba0ebc7bb13f7aa9311f21fd3e860c4687ff993.zip | |
DLclose loaded libraries to free the memory on JiT block deletion event
Diffstat (limited to 'miasm2/jitter/jitcore_gcc.py')
| -rw-r--r-- | miasm2/jitter/jitcore_gcc.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/miasm2/jitter/jitcore_gcc.py b/miasm2/jitter/jitcore_gcc.py index db0b7880..a633f935 100644 --- a/miasm2/jitter/jitcore_gcc.py +++ b/miasm2/jitter/jitcore_gcc.py @@ -4,6 +4,7 @@ import os import tempfile import ctypes +import _ctypes from distutils.sysconfig import get_python_inc from subprocess import check_call from hashlib import md5 @@ -79,7 +80,11 @@ class JitCore_Gcc(jitcore.JitCore): self.include_files = None def deleteCB(self, offset): - pass + """Free the state associated to @offset and delete it + @offset: gcc state offset + """ + _ctypes.dlclose(self.gcc_states[offset]._handle) + del self.gcc_states[offset] def load(self): lib_dir = os.path.dirname(os.path.realpath(__file__)) @@ -105,7 +110,7 @@ class JitCore_Gcc(jitcore.JitCore): func = getattr(lib, f_name) addr = ctypes.cast(func, ctypes.c_void_p).value self.lbl2jitbloc[label.offset] = addr - self.gcc_states[label.offset] = None + self.gcc_states[label.offset] = lib def gen_c_code(self, label, irblocks): """ |