pyvex 9.2.193__cp310-cp310-macosx_10_12_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyvex/__init__.py +92 -0
- pyvex/_register_info.py +1800 -0
- pyvex/arches.py +94 -0
- pyvex/block.py +697 -0
- pyvex/const.py +426 -0
- pyvex/const_val.py +26 -0
- pyvex/data_ref.py +55 -0
- pyvex/enums.py +156 -0
- pyvex/errors.py +31 -0
- pyvex/expr.py +974 -0
- pyvex/include/libvex.h +1029 -0
- pyvex/include/libvex_basictypes.h +236 -0
- pyvex/include/libvex_emnote.h +142 -0
- pyvex/include/libvex_guest_amd64.h +252 -0
- pyvex/include/libvex_guest_arm.h +224 -0
- pyvex/include/libvex_guest_arm64.h +203 -0
- pyvex/include/libvex_guest_mips32.h +175 -0
- pyvex/include/libvex_guest_mips64.h +173 -0
- pyvex/include/libvex_guest_offsets.h +941 -0
- pyvex/include/libvex_guest_ppc32.h +298 -0
- pyvex/include/libvex_guest_ppc64.h +343 -0
- pyvex/include/libvex_guest_riscv64.h +148 -0
- pyvex/include/libvex_guest_s390x.h +201 -0
- pyvex/include/libvex_guest_tilegx.h +149 -0
- pyvex/include/libvex_guest_x86.h +322 -0
- pyvex/include/libvex_ir.h +3113 -0
- pyvex/include/libvex_s390x_common.h +123 -0
- pyvex/include/libvex_trc_values.h +99 -0
- pyvex/include/pyvex.h +96 -0
- pyvex/lib/libpyvex.dylib +0 -0
- pyvex/lifting/__init__.py +18 -0
- pyvex/lifting/gym/README.md +7 -0
- pyvex/lifting/gym/__init__.py +5 -0
- pyvex/lifting/gym/aarch64_spotter.py +40 -0
- pyvex/lifting/gym/arm_spotter.py +427 -0
- pyvex/lifting/gym/x86_spotter.py +129 -0
- pyvex/lifting/libvex.py +117 -0
- pyvex/lifting/lift_function.py +304 -0
- pyvex/lifting/lifter.py +124 -0
- pyvex/lifting/post_processor.py +16 -0
- pyvex/lifting/util/__init__.py +14 -0
- pyvex/lifting/util/instr_helper.py +422 -0
- pyvex/lifting/util/lifter_helper.py +154 -0
- pyvex/lifting/util/syntax_wrapper.py +312 -0
- pyvex/lifting/util/vex_helper.py +301 -0
- pyvex/lifting/zerodivision.py +71 -0
- pyvex/native.py +63 -0
- pyvex/py.typed +1 -0
- pyvex/stmt.py +740 -0
- pyvex/types.py +48 -0
- pyvex/utils.py +63 -0
- pyvex/vex_ffi.py +1453 -0
- pyvex-9.2.193.dist-info/METADATA +181 -0
- pyvex-9.2.193.dist-info/RECORD +59 -0
- pyvex-9.2.193.dist-info/WHEEL +6 -0
- pyvex-9.2.193.dist-info/licenses/LICENSE +24 -0
- pyvex-9.2.193.dist-info/licenses/pyvex_c/LICENSE +339 -0
- pyvex-9.2.193.dist-info/licenses/vex/LICENSE.GPL +340 -0
- pyvex-9.2.193.dist-info/licenses/vex/LICENSE.README +23 -0
pyvex/native.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import getpass
|
|
2
|
+
import hashlib
|
|
3
|
+
import importlib.resources
|
|
4
|
+
import os
|
|
5
|
+
import pickle
|
|
6
|
+
import sys
|
|
7
|
+
import tempfile
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
import cffi
|
|
11
|
+
|
|
12
|
+
from .vex_ffi import ffi_str as _ffi_str
|
|
13
|
+
|
|
14
|
+
ffi = cffi.FFI()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _parse_ffi_str():
|
|
18
|
+
hash_ = hashlib.md5(_ffi_str.encode("utf-8")).hexdigest()
|
|
19
|
+
cache_location = os.path.join(tempfile.gettempdir(), f"pyvex_ffi_parser_cache.{getpass.getuser()}.{hash_}")
|
|
20
|
+
|
|
21
|
+
if os.path.isfile(cache_location):
|
|
22
|
+
# load the cache
|
|
23
|
+
with open(cache_location, "rb") as f:
|
|
24
|
+
cache = pickle.loads(f.read())
|
|
25
|
+
ffi._parser._declarations = cache["_declarations"]
|
|
26
|
+
ffi._parser._int_constants = cache["_int_constants"]
|
|
27
|
+
else:
|
|
28
|
+
ffi.cdef(_ffi_str)
|
|
29
|
+
# cache the result
|
|
30
|
+
cache = {
|
|
31
|
+
"_declarations": ffi._parser._declarations,
|
|
32
|
+
"_int_constants": ffi._parser._int_constants,
|
|
33
|
+
}
|
|
34
|
+
# atomically write cache
|
|
35
|
+
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
|
36
|
+
temp_file.write(pickle.dumps(cache))
|
|
37
|
+
temp_file_name = temp_file.name
|
|
38
|
+
os.replace(temp_file_name, cache_location)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _find_c_lib():
|
|
42
|
+
# Load the c library for calling into VEX
|
|
43
|
+
if sys.platform in ("win32", "cygwin"):
|
|
44
|
+
library_file = "pyvex.dll"
|
|
45
|
+
elif sys.platform == "darwin":
|
|
46
|
+
library_file = "libpyvex.dylib"
|
|
47
|
+
else:
|
|
48
|
+
library_file = "libpyvex.so"
|
|
49
|
+
|
|
50
|
+
pyvex_path = str(importlib.resources.files("pyvex") / "lib" / library_file)
|
|
51
|
+
# parse _ffi_str and use cache if possible
|
|
52
|
+
_parse_ffi_str()
|
|
53
|
+
# RTLD_GLOBAL used for sim_unicorn.so
|
|
54
|
+
lib = ffi.dlopen(pyvex_path)
|
|
55
|
+
|
|
56
|
+
if not lib.vex_init():
|
|
57
|
+
raise ImportError("libvex failed to initialize")
|
|
58
|
+
# this looks up all the definitions (wtf)
|
|
59
|
+
dir(lib)
|
|
60
|
+
return lib
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
pvc: Any = _find_c_lib() # This should be properly typed, but this seems non trivial
|
pyvex/py.typed
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
partial
|