pyvex 9.2.189__cp312-cp312-win_amd64.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 (60) 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/pyvex.dll +0 -0
  31. pyvex/lib/pyvex.lib +0 -0
  32. pyvex/lifting/__init__.py +18 -0
  33. pyvex/lifting/gym/README.md +7 -0
  34. pyvex/lifting/gym/__init__.py +5 -0
  35. pyvex/lifting/gym/aarch64_spotter.py +40 -0
  36. pyvex/lifting/gym/arm_spotter.py +427 -0
  37. pyvex/lifting/gym/x86_spotter.py +129 -0
  38. pyvex/lifting/libvex.py +117 -0
  39. pyvex/lifting/lift_function.py +304 -0
  40. pyvex/lifting/lifter.py +124 -0
  41. pyvex/lifting/post_processor.py +16 -0
  42. pyvex/lifting/util/__init__.py +14 -0
  43. pyvex/lifting/util/instr_helper.py +422 -0
  44. pyvex/lifting/util/lifter_helper.py +154 -0
  45. pyvex/lifting/util/syntax_wrapper.py +312 -0
  46. pyvex/lifting/util/vex_helper.py +301 -0
  47. pyvex/lifting/zerodivision.py +71 -0
  48. pyvex/native.py +63 -0
  49. pyvex/py.typed +1 -0
  50. pyvex/stmt.py +740 -0
  51. pyvex/types.py +48 -0
  52. pyvex/utils.py +63 -0
  53. pyvex/vex_ffi.py +1452 -0
  54. pyvex-9.2.189.dist-info/METADATA +181 -0
  55. pyvex-9.2.189.dist-info/RECORD +60 -0
  56. pyvex-9.2.189.dist-info/WHEEL +5 -0
  57. pyvex-9.2.189.dist-info/licenses/LICENSE +24 -0
  58. pyvex-9.2.189.dist-info/licenses/pyvex_c/LICENSE +339 -0
  59. pyvex-9.2.189.dist-info/licenses/vex/LICENSE.GPL +340 -0
  60. pyvex-9.2.189.dist-info/licenses/vex/LICENSE.README +23 -0
@@ -0,0 +1,123 @@
1
+ /* -*- mode: C; c-basic-offset: 3; -*- */
2
+
3
+ /*--------------------------------------------------------------------*/
4
+ /*--- Common defs for s390x libvex_s390x_common.h ---*/
5
+ /*--------------------------------------------------------------------*/
6
+
7
+ /*
8
+ This file is part of Valgrind, a dynamic binary instrumentation
9
+ framework.
10
+
11
+ Copyright IBM Corp. 2010-2017
12
+
13
+ This program is free software; you can redistribute it and/or
14
+ modify it under the terms of the GNU General Public License as
15
+ published by the Free Software Foundation; either version 2 of the
16
+ License, or (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful, but
19
+ WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26
+ 02110-1301, USA.
27
+
28
+ The GNU General Public License is contained in the file COPYING.
29
+ */
30
+
31
+ #ifndef __LIBVEX_PUB_S390X_H
32
+ #define __LIBVEX_PUB_S390X_H
33
+
34
+ /* This file includes definitions for s390.
35
+
36
+ It must be suitable for inclusion in assembler source files. */
37
+
38
+
39
+ /*--------------------------------------------------------------*/
40
+ /*--- Dedicated registers ---*/
41
+ /*--------------------------------------------------------------*/
42
+
43
+ #define S390_REGNO_RETURN_VALUE 2
44
+ #define S390_REGNO_TCHAIN_SCRATCH 12
45
+ #define S390_REGNO_GUEST_STATE_POINTER 13
46
+ #define S390_REGNO_LINK_REGISTER 14
47
+ #define S390_REGNO_STACK_POINTER 15
48
+
49
+
50
+ /*--------------------------------------------------------------*/
51
+ /*--- Offsets in the stack frame allocated by the dispatcher ---*/
52
+ /*--------------------------------------------------------------*/
53
+
54
+ /* Dispatcher will save 8 FPRs at offsets 160 + 0 ... 160 + 56 */
55
+
56
+ /* Where the dispatcher saves the r2 contents. */
57
+ #define S390_OFFSET_SAVED_R2 160+80
58
+
59
+ /* Where client's FPC register is saved. */
60
+ #define S390_OFFSET_SAVED_FPC_C 160+72
61
+
62
+ /* Where valgrind's FPC register is saved. */
63
+ #define S390_OFFSET_SAVED_FPC_V 160+64
64
+
65
+ /* Size of frame allocated by VG_(disp_run_translations)
66
+ Need size for
67
+ 8 FPRs
68
+ + 1 GPR (SAVED_R2)
69
+ + 2 FPCs (SAVED_FPC_C and SAVED_FPC_V).
70
+
71
+ Additionally, we need a standard frame for helper functions being called
72
+ from client code. (See figure 1-16 in zSeries ABI) */
73
+ #define S390_INNERLOOP_FRAME_SIZE ((8+1+2)*8 + 160)
74
+
75
+
76
+ /*--------------------------------------------------------------*/
77
+ /*--- Facility bits ---*/
78
+ /*--------------------------------------------------------------*/
79
+
80
+ /* The value of the macro is the number of the facility bit as per POP. */
81
+ #define S390_FAC_MSA 17 // message-security-assist
82
+ #define S390_FAC_LDISP 18 // long displacement
83
+ #define S390_FAC_HFPMAS 20 // HFP multiply-and-add-subtract
84
+ #define S390_FAC_EIMM 21 // extended immediate
85
+ #define S390_FAC_HFPUNX 23 // HFP unnormalized extension
86
+ #define S390_FAC_ETF2 24 // ETF2-enhancement
87
+ #define S390_FAC_STCKF 25 // store clock fast insn
88
+ #define S390_FAC_PENH 26 // parsing-enhancement
89
+ #define S390_FAC_ETF3 30 // ETF3-enhancement
90
+ #define S390_FAC_XCPUT 31 // extract-CPU-time
91
+ #define S390_FAC_GIE 34 // general insn extension
92
+ #define S390_FAC_EXEXT 35 // execute extension
93
+ #define S390_FAC_FPEXT 37 // floating-point extension
94
+ #define S390_FAC_FPSE 41 // floating-point support enhancement
95
+ #define S390_FAC_DFP 42 // decimal floating point
96
+ #define S390_FAC_PFPO 44 // perform floating point operation insn
97
+ #define S390_FAC_HIGHW 45 // high-word extension
98
+ #define S390_FAC_LSC 45 // load/store on condition
99
+ #define S390_FAC_DFPZC 48 // DFP zoned-conversion
100
+ #define S390_FAC_MISC 49 // miscellaneous insn
101
+ #define S390_FAC_CTREXE 50 // constrained transactional execution
102
+ #define S390_FAC_LSC2 53 // load/store on condition 2 and load and zero rightmost byte
103
+ #define S390_FAC_MSA5 57 // message-security-assist 5
104
+ #define S390_FAC_TREXE 73 // transactional execution
105
+ #define S390_FAC_MSA4 77 // message-security-assist 4
106
+ #define S390_FAC_VX 129 // vector facility
107
+
108
+
109
+ /*--------------------------------------------------------------*/
110
+ /*--- Miscellaneous ---*/
111
+ /*--------------------------------------------------------------*/
112
+
113
+ /* Number of arguments that can be passed in registers */
114
+ #define S390_NUM_GPRPARMS 5
115
+
116
+ /* Number of double words needed to store all facility bits. */
117
+ #define S390_NUM_FACILITY_DW 3
118
+
119
+ #endif /* __LIBVEX_PUB_S390X_H */
120
+
121
+ /*--------------------------------------------------------------------*/
122
+ /*--- end libvex_s390x_common.h ---*/
123
+ /*--------------------------------------------------------------------*/
@@ -0,0 +1,99 @@
1
+
2
+ /*---------------------------------------------------------------*/
3
+ /*--- begin libvex_trc_values.h ---*/
4
+ /*---------------------------------------------------------------*/
5
+
6
+ /*
7
+ This file is part of Valgrind, a dynamic binary instrumentation
8
+ framework.
9
+
10
+ Copyright (C) 2004-2015 OpenWorks LLP
11
+ info@open-works.net
12
+
13
+ This program is free software; you can redistribute it and/or
14
+ modify it under the terms of the GNU General Public License as
15
+ published by the Free Software Foundation; either version 2 of the
16
+ License, or (at your option) any later version.
17
+
18
+ This program is distributed in the hope that it will be useful, but
19
+ WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ General Public License for more details.
22
+
23
+ You should have received a copy of the GNU General Public License
24
+ along with this program; if not, write to the Free Software
25
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26
+ 02110-1301, USA.
27
+
28
+ The GNU General Public License is contained in the file COPYING.
29
+
30
+ Neither the names of the U.S. Department of Energy nor the
31
+ University of California nor the names of its contributors may be
32
+ used to endorse or promote products derived from this software
33
+ without prior written permission.
34
+ */
35
+
36
+ #ifndef __LIBVEX_TRC_VALUES_H
37
+ #define __LIBVEX_TRC_VALUES_H
38
+
39
+
40
+ /* Magic values that the guest state pointer might be set to when
41
+ returning to the dispatcher. The only other legitimate value is to
42
+ point to the start of the thread's VEX guest state.
43
+
44
+ This file may get included in assembly code, so do not put
45
+ C-specific constructs in it.
46
+
47
+ These values should be 61 or above so as not to conflict
48
+ with Valgrind's VG_TRC_ values, which are 60 or below.
49
+ */
50
+
51
+ #define VEX_TRC_JMP_INVALICACHE 61 /* invalidate icache (translations)
52
+ before continuing */
53
+ #define VEX_TRC_JMP_FLUSHDCACHE 103 /* flush dcache before continuing */
54
+
55
+ #define VEX_TRC_JMP_NOREDIR 81 /* jump to undirected guest addr */
56
+ #define VEX_TRC_JMP_SIGTRAP 85 /* deliver trap (SIGTRAP) before
57
+ continuing */
58
+ #define VEX_TRC_JMP_SIGSEGV 87 /* deliver segv (SIGSEGV) before
59
+ continuing */
60
+ #define VEX_TRC_JMP_SIGBUS 93 /* deliver SIGBUS before continuing */
61
+ #define VEX_TRC_JMP_SIGFPE 105 /* deliver SIGFPE before continuing */
62
+
63
+ #define VEX_TRC_JMP_SIGFPE_INTDIV 97 /* deliver SIGFPE (integer divide
64
+ by zero) before continuing */
65
+
66
+ #define VEX_TRC_JMP_SIGFPE_INTOVF 99 /* deliver SIGFPE (integer overflow)
67
+ before continuing */
68
+
69
+ #define VEX_TRC_JMP_SIGILL 101 /* deliver SIGILL (Illegal instruction)
70
+ before continuing */
71
+
72
+ #define VEX_TRC_JMP_EMWARN 63 /* deliver emulation warning before
73
+ continuing */
74
+ #define VEX_TRC_JMP_EMFAIL 83 /* emulation fatal error; abort system */
75
+
76
+ #define VEX_TRC_JMP_CLIENTREQ 65 /* do a client req before continuing */
77
+ #define VEX_TRC_JMP_YIELD 67 /* yield to thread sched
78
+ before continuing */
79
+ #define VEX_TRC_JMP_NODECODE 69 /* next instruction is not decodable */
80
+ #define VEX_TRC_JMP_MAPFAIL 71 /* address translation failed */
81
+
82
+ #define VEX_TRC_JMP_SYS_SYSCALL 73 /* do syscall before continuing */
83
+ #define VEX_TRC_JMP_SYS_INT32 75 /* do syscall before continuing */
84
+ #define VEX_TRC_JMP_SYS_INT128 77 /* do syscall before continuing */
85
+ #define VEX_TRC_JMP_SYS_INT129 89 /* do syscall before continuing */
86
+ #define VEX_TRC_JMP_SYS_INT130 91 /* do syscall before continuing */
87
+ #define VEX_TRC_JMP_SYS_INT145 111 /* do syscall before continuing */
88
+ #define VEX_TRC_JMP_SYS_INT210 113 /* do syscall before continuing */
89
+
90
+ #define VEX_TRC_JMP_SYS_SYSENTER 79 /* do syscall before continuing */
91
+
92
+ #define VEX_TRC_JMP_BORING 95 /* return to sched, but just
93
+ keep going; no special action */
94
+
95
+ #endif /* ndef __LIBVEX_TRC_VALUES_H */
96
+
97
+ /*---------------------------------------------------------------*/
98
+ /*--- libvex_trc_values.h ---*/
99
+ /*---------------------------------------------------------------*/
pyvex/include/pyvex.h ADDED
@@ -0,0 +1,96 @@
1
+ // This code is GPLed by Yan Shoshitaishvili
2
+
3
+ #ifndef __VEXIR_H
4
+ #define __VEXIR_H
5
+
6
+ #include <libvex.h>
7
+
8
+ // Some info required for translation
9
+ extern int log_level;
10
+ extern VexTranslateArgs vta;
11
+
12
+ extern char *msg_buffer;
13
+ extern size_t msg_current_size;
14
+ void clear_log(void);
15
+
16
+ //
17
+ // Initializes VEX. This function must be called before vex_lift
18
+ // can be used.
19
+ //
20
+ int vex_init(void);
21
+
22
+ typedef struct _ExitInfo {
23
+ Int stmt_idx;
24
+ Addr ins_addr;
25
+ IRStmt *stmt;
26
+ } ExitInfo;
27
+
28
+ typedef enum {
29
+ Dt_Unknown = 0x9000,
30
+ Dt_Integer,
31
+ Dt_FP,
32
+ Dt_StoreInteger
33
+ } DataRefTypes;
34
+
35
+ typedef struct _DataRef {
36
+ Addr data_addr;
37
+ Int size;
38
+ DataRefTypes data_type;
39
+ Int stmt_idx;
40
+ Addr ins_addr;
41
+ } DataRef;
42
+
43
+ typedef struct _ConstVal {
44
+ Int tmp;
45
+ Int stmt_idx;
46
+ ULong value; // 64-bit max
47
+ } ConstVal;
48
+
49
+ #define MAX_EXITS 400
50
+ #define MAX_DATA_REFS 2000
51
+ #define MAX_CONST_VALS 1000
52
+
53
+ typedef struct _VEXLiftResult {
54
+ IRSB* irsb;
55
+ Int size;
56
+ Bool is_noop_block;
57
+ // Conditional exits
58
+ Int exit_count;
59
+ ExitInfo exits[MAX_EXITS];
60
+ // The default exit
61
+ Int is_default_exit_constant;
62
+ Addr default_exit;
63
+ // Instruction addresses
64
+ Int insts;
65
+ Addr inst_addrs[200];
66
+ // Data references
67
+ Int data_ref_count;
68
+ DataRef data_refs[MAX_DATA_REFS];
69
+ // Constant propagation
70
+ Int const_val_count;
71
+ ConstVal const_vals[MAX_CONST_VALS];
72
+ } VEXLiftResult;
73
+
74
+ VEXLiftResult *vex_lift(
75
+ VexArch guest,
76
+ VexArchInfo archinfo,
77
+ unsigned char *insn_start,
78
+ unsigned long long insn_addr,
79
+ unsigned int max_insns,
80
+ unsigned int max_bytes,
81
+ int opt_level,
82
+ int traceflags,
83
+ int allow_arch_optimizations,
84
+ int strict_block_end,
85
+ int collect_data_refs,
86
+ int load_from_ro_regions,
87
+ int const_prop,
88
+ VexRegisterUpdates px_control,
89
+ unsigned int lookback_amount);
90
+
91
+ Bool register_readonly_region(ULong start, ULong size, unsigned char* content);
92
+ void deregister_all_readonly_regions();
93
+ Bool register_initial_register_value(UInt offset, UInt size, ULong value);
94
+ Bool reset_initial_register_values();
95
+
96
+ #endif
pyvex/lib/pyvex.dll ADDED
Binary file
pyvex/lib/pyvex.lib ADDED
Binary file
@@ -0,0 +1,18 @@
1
+ from .gym import AARCH64Spotter, AMD64Spotter, ARMSpotter, X86Spotter
2
+ from .libvex import LIBVEX_SUPPORTED_ARCHES, LibVEXLifter
3
+ from .lift_function import lift, lifters, register
4
+ from .lifter import Lifter
5
+ from .post_processor import Postprocessor
6
+ from .zerodivision import ZeroDivisionPostProcessor
7
+
8
+ for arch in LIBVEX_SUPPORTED_ARCHES:
9
+ register(LibVEXLifter, arch)
10
+ register(AARCH64Spotter, "AARCH64")
11
+ register(ARMSpotter, "ARM")
12
+ register(ARMSpotter, "ARMEL")
13
+ register(ARMSpotter, "ARMHF")
14
+ register(ARMSpotter, "ARMCortexM")
15
+ register(AMD64Spotter, "AMD64")
16
+ register(X86Spotter, "X86")
17
+
18
+ __all__ = ["Lifter", "Postprocessor", "lift", "register", "lifters", "ZeroDivisionPostProcessor"]
@@ -0,0 +1,7 @@
1
+ # The Gym
2
+
3
+ This is where we're putting non-libvex lifters that we feel should be included with the pyvex distribution.
4
+
5
+ These will probably be mostly "spotters", which correct for gaps in libvex's instruction support.
6
+
7
+
@@ -0,0 +1,5 @@
1
+ from .aarch64_spotter import AARCH64Spotter
2
+ from .arm_spotter import ARMSpotter
3
+ from .x86_spotter import AMD64Spotter, X86Spotter
4
+
5
+ __all__ = ("ARMSpotter", "AARCH64Spotter", "X86Spotter", "AMD64Spotter")
@@ -0,0 +1,40 @@
1
+ import logging
2
+
3
+ from pyvex.lifting.util.instr_helper import Instruction
4
+ from pyvex.lifting.util.lifter_helper import GymratLifter
5
+
6
+ log = logging.getLogger(__name__)
7
+
8
+
9
+ class Aarch64Instruction(Instruction): # pylint: disable=abstract-method
10
+ # NOTE: WARNING: There is no MRS, MSR, SYSL in VEX's ARM implementation
11
+ # You must use straight nasty hacks instead.
12
+ pass
13
+
14
+
15
+ class Instruction_SYSL(Aarch64Instruction):
16
+ name = "SYSL"
17
+ bin_format = "1101010100101qqqnnnnmmmmppprrrrr"
18
+
19
+ def compute_result(self): # pylint: disable=arguments-differ
20
+ log.debug("Ignoring SYSL instruction at %#x.", self.addr)
21
+
22
+
23
+ class Instruction_MSR(Aarch64Instruction):
24
+ name = "MSR"
25
+ bin_format = "11010101000ioqqqnnnnmmmmppprrrrr"
26
+
27
+ def compute_result(self): # pylint: disable=arguments-differ
28
+ log.debug("Ignoring MSR instruction at %#x.", self.addr)
29
+
30
+
31
+ class Instruction_MRS(Aarch64Instruction):
32
+ name = "MRS"
33
+ bin_format = "110101010011opppnnnnmmmmppprrrrr"
34
+
35
+ def compute_result(self): # pylint: disable=arguments-differ
36
+ log.debug("Ignoring MRS instruction at %#x.", self.addr)
37
+
38
+
39
+ class AARCH64Spotter(GymratLifter):
40
+ instrs = [Instruction_MRS, Instruction_MSR, Instruction_SYSL]