pyvex 9.2.189__cp311-cp311-macosx_11_0_arm64.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.

Potentially problematic release.


This version of pyvex might be problematic. Click here for more details.

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.189.dist-info/METADATA +181 -0
  54. pyvex-9.2.189.dist-info/RECORD +59 -0
  55. pyvex-9.2.189.dist-info/WHEEL +6 -0
  56. pyvex-9.2.189.dist-info/licenses/LICENSE +24 -0
  57. pyvex-9.2.189.dist-info/licenses/pyvex_c/LICENSE +339 -0
  58. pyvex-9.2.189.dist-info/licenses/vex/LICENSE.GPL +340 -0
  59. pyvex-9.2.189.dist-info/licenses/vex/LICENSE.README +23 -0
pyvex/types.py ADDED
@@ -0,0 +1,48 @@
1
+ from typing import TYPE_CHECKING, Any, Protocol, Union, runtime_checkable
2
+
3
+ from cffi.api import FFI
4
+
5
+
6
+ class Register(Protocol):
7
+ """
8
+ A register. Pyvex should probably not have this dependency.
9
+ """
10
+
11
+ name: str
12
+
13
+
14
+ class Arch(Protocol):
15
+ """
16
+ An architecture description.
17
+ """
18
+
19
+ name: str
20
+ ip_offset: int
21
+ bits: int
22
+ instruction_endness: str
23
+ memory_endness: str
24
+ byte_width: int
25
+ register_list: list[Register]
26
+ registers: dict[str, tuple[int, int]]
27
+
28
+ def translate_register_name(self, offset: int, size: int | None = None) -> str | None: ...
29
+
30
+ def get_register_offset(self, name: str) -> int: ...
31
+
32
+
33
+ @runtime_checkable
34
+ class LibvexArch(Protocol):
35
+ """
36
+ The description for an architecture that is usable with libvex
37
+ """
38
+
39
+ vex_arch: str
40
+ vex_archinfo: dict[str, Any]
41
+
42
+
43
+ PyLiftSource = Union[bytes, bytearray, memoryview]
44
+ if TYPE_CHECKING:
45
+ CLiftSource = FFI.CData
46
+ else:
47
+ CLiftSource = None
48
+ LiftSource = Union[PyLiftSource, CLiftSource]
pyvex/utils.py ADDED
@@ -0,0 +1,63 @@
1
+ import struct
2
+ from collections.abc import Callable
3
+ from typing import Any
4
+
5
+ try:
6
+ import _md5 as md5lib
7
+ except ImportError:
8
+ import hashlib as md5lib
9
+
10
+
11
+ md5_unpacker = struct.Struct("4I")
12
+
13
+
14
+ def stable_hash(t: tuple) -> int:
15
+ cnt = _dump_tuple(t)
16
+ hd = md5lib.md5(cnt).digest()
17
+ return md5_unpacker.unpack(hd)[0] # 32 bits
18
+
19
+
20
+ def _dump_tuple(t: tuple) -> bytes:
21
+ cnt = b""
22
+ for item in t:
23
+ if item is not None:
24
+ type_ = type(item)
25
+ if type_ in _DUMP_BY_TYPE:
26
+ cnt += _DUMP_BY_TYPE[type_](item)
27
+ else:
28
+ cnt += struct.pack("<Q", hash(item) & 0xFFFF_FFFF_FFFF_FFFF)
29
+ cnt += b"\xf0"
30
+ return cnt
31
+
32
+
33
+ def _dump_str(t: str) -> bytes:
34
+ return t.encode("ascii")
35
+
36
+
37
+ def _dump_int(t: int) -> bytes:
38
+ prefix = b"" if t >= 0 else b"-"
39
+ t = abs(t)
40
+ if t <= 0xFFFF:
41
+ return prefix + struct.pack("<H", t)
42
+ elif t <= 0xFFFF_FFFF:
43
+ return prefix + struct.pack("<I", t)
44
+ elif t <= 0xFFFF_FFFF_FFFF_FFFF:
45
+ return prefix + struct.pack("<Q", t)
46
+ else:
47
+ cnt = b""
48
+ while t > 0:
49
+ cnt += _dump_int(t & 0xFFFF_FFFF_FFFF_FFFF)
50
+ t >>= 64
51
+ return prefix + cnt
52
+
53
+
54
+ def _dump_type(t: type) -> bytes:
55
+ return t.__name__.encode("ascii")
56
+
57
+
58
+ _DUMP_BY_TYPE: dict[type, Callable[[Any], bytes]] = {
59
+ tuple: _dump_tuple,
60
+ str: _dump_str,
61
+ int: _dump_int,
62
+ type: _dump_type,
63
+ }