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.
Files changed (59) hide show
  1. pyvex/__init__.py +92 -0
  2. pyvex/_register_info.py +1800 -0
  3. pyvex/arches.py +94 -0
  4. pyvex/block.py +697 -0
  5. pyvex/const.py +426 -0
  6. pyvex/const_val.py +26 -0
  7. pyvex/data_ref.py +55 -0
  8. pyvex/enums.py +156 -0
  9. pyvex/errors.py +31 -0
  10. pyvex/expr.py +974 -0
  11. pyvex/include/libvex.h +1029 -0
  12. pyvex/include/libvex_basictypes.h +236 -0
  13. pyvex/include/libvex_emnote.h +142 -0
  14. pyvex/include/libvex_guest_amd64.h +252 -0
  15. pyvex/include/libvex_guest_arm.h +224 -0
  16. pyvex/include/libvex_guest_arm64.h +203 -0
  17. pyvex/include/libvex_guest_mips32.h +175 -0
  18. pyvex/include/libvex_guest_mips64.h +173 -0
  19. pyvex/include/libvex_guest_offsets.h +941 -0
  20. pyvex/include/libvex_guest_ppc32.h +298 -0
  21. pyvex/include/libvex_guest_ppc64.h +343 -0
  22. pyvex/include/libvex_guest_riscv64.h +148 -0
  23. pyvex/include/libvex_guest_s390x.h +201 -0
  24. pyvex/include/libvex_guest_tilegx.h +149 -0
  25. pyvex/include/libvex_guest_x86.h +322 -0
  26. pyvex/include/libvex_ir.h +3113 -0
  27. pyvex/include/libvex_s390x_common.h +123 -0
  28. pyvex/include/libvex_trc_values.h +99 -0
  29. pyvex/include/pyvex.h +96 -0
  30. pyvex/lib/libpyvex.dylib +0 -0
  31. pyvex/lifting/__init__.py +18 -0
  32. pyvex/lifting/gym/README.md +7 -0
  33. pyvex/lifting/gym/__init__.py +5 -0
  34. pyvex/lifting/gym/aarch64_spotter.py +40 -0
  35. pyvex/lifting/gym/arm_spotter.py +427 -0
  36. pyvex/lifting/gym/x86_spotter.py +129 -0
  37. pyvex/lifting/libvex.py +117 -0
  38. pyvex/lifting/lift_function.py +304 -0
  39. pyvex/lifting/lifter.py +124 -0
  40. pyvex/lifting/post_processor.py +16 -0
  41. pyvex/lifting/util/__init__.py +14 -0
  42. pyvex/lifting/util/instr_helper.py +422 -0
  43. pyvex/lifting/util/lifter_helper.py +154 -0
  44. pyvex/lifting/util/syntax_wrapper.py +312 -0
  45. pyvex/lifting/util/vex_helper.py +301 -0
  46. pyvex/lifting/zerodivision.py +71 -0
  47. pyvex/native.py +63 -0
  48. pyvex/py.typed +1 -0
  49. pyvex/stmt.py +740 -0
  50. pyvex/types.py +48 -0
  51. pyvex/utils.py +63 -0
  52. pyvex/vex_ffi.py +1453 -0
  53. pyvex-9.2.193.dist-info/METADATA +181 -0
  54. pyvex-9.2.193.dist-info/RECORD +59 -0
  55. pyvex-9.2.193.dist-info/WHEEL +6 -0
  56. pyvex-9.2.193.dist-info/licenses/LICENSE +24 -0
  57. pyvex-9.2.193.dist-info/licenses/pyvex_c/LICENSE +339 -0
  58. pyvex-9.2.193.dist-info/licenses/vex/LICENSE.GPL +340 -0
  59. 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