angr 9.2.131__py3-none-manylinux2014_aarch64.whl → 9.2.133__py3-none-manylinux2014_aarch64.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 angr might be problematic. Click here for more details.

Files changed (264) hide show
  1. angr/__init__.py +128 -128
  2. angr/analyses/__init__.py +38 -38
  3. angr/analyses/analysis.py +6 -2
  4. angr/analyses/backward_slice.py +3 -4
  5. angr/analyses/binary_optimizer.py +5 -12
  6. angr/analyses/bindiff.py +3 -6
  7. angr/analyses/calling_convention.py +3 -4
  8. angr/analyses/cfg/__init__.py +3 -3
  9. angr/analyses/cfg/cfg_base.py +1 -1
  10. angr/analyses/cfg/cfg_emulated.py +5 -5
  11. angr/analyses/cfg/cfg_fast.py +19 -17
  12. angr/analyses/cfg/indirect_jump_resolvers/__init__.py +5 -5
  13. angr/analyses/cfg/indirect_jump_resolvers/amd64_elf_got.py +1 -1
  14. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +148 -101
  15. angr/analyses/cfg/indirect_jump_resolvers/x86_elf_pic_plt.py +1 -1
  16. angr/analyses/data_dep/__init__.py +4 -4
  17. angr/analyses/datagraph_meta.py +1 -1
  18. angr/analyses/ddg.py +16 -17
  19. angr/analyses/decompiler/__init__.py +12 -12
  20. angr/analyses/decompiler/ail_simplifier.py +24 -12
  21. angr/analyses/decompiler/block_similarity.py +2 -4
  22. angr/analyses/decompiler/block_simplifier.py +10 -21
  23. angr/analyses/decompiler/callsite_maker.py +1 -1
  24. angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +1 -1
  25. angr/analyses/decompiler/clinic.py +122 -41
  26. angr/analyses/decompiler/condition_processor.py +57 -39
  27. angr/analyses/decompiler/counters/__init__.py +3 -3
  28. angr/analyses/decompiler/decompilation_cache.py +7 -7
  29. angr/analyses/decompiler/dephication/__init__.py +1 -1
  30. angr/analyses/decompiler/dephication/graph_rewriting.py +1 -1
  31. angr/analyses/decompiler/dephication/graph_vvar_mapping.py +11 -3
  32. angr/analyses/decompiler/dephication/rewriting_engine.py +169 -45
  33. angr/analyses/decompiler/dephication/seqnode_dephication.py +5 -4
  34. angr/analyses/decompiler/expression_narrower.py +1 -1
  35. angr/analyses/decompiler/graph_region.py +8 -8
  36. angr/analyses/decompiler/optimization_passes/__init__.py +20 -20
  37. angr/analyses/decompiler/optimization_passes/const_derefs.py +1 -0
  38. angr/analyses/decompiler/optimization_passes/deadblock_remover.py +1 -2
  39. angr/analyses/decompiler/optimization_passes/div_simplifier.py +41 -16
  40. angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +8 -7
  41. angr/analyses/decompiler/optimization_passes/duplication_reverter/utils.py +1 -3
  42. angr/analyses/decompiler/optimization_passes/engine_base.py +262 -84
  43. angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +175 -39
  44. angr/analyses/decompiler/optimization_passes/ite_region_converter.py +2 -5
  45. angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +5 -5
  46. angr/analyses/decompiler/optimization_passes/mod_simplifier.py +12 -3
  47. angr/analyses/decompiler/optimization_passes/optimization_pass.py +42 -19
  48. angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +9 -5
  49. angr/analyses/decompiler/peephole_optimizations/__init__.py +1 -1
  50. angr/analyses/decompiler/peephole_optimizations/base.py +6 -6
  51. angr/analyses/decompiler/peephole_optimizations/remove_noop_conversions.py +2 -0
  52. angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +1 -1
  53. angr/analyses/decompiler/presets/__init__.py +1 -1
  54. angr/analyses/decompiler/region_simplifiers/expr_folding.py +3 -3
  55. angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +8 -12
  56. angr/analyses/decompiler/ssailification/rewriting.py +1 -2
  57. angr/analyses/decompiler/ssailification/rewriting_engine.py +139 -56
  58. angr/analyses/decompiler/ssailification/ssailification.py +2 -1
  59. angr/analyses/decompiler/ssailification/traversal.py +4 -6
  60. angr/analyses/decompiler/ssailification/traversal_engine.py +125 -42
  61. angr/analyses/decompiler/structured_codegen/__init__.py +5 -5
  62. angr/analyses/decompiler/structured_codegen/base.py +3 -3
  63. angr/analyses/decompiler/structured_codegen/c.py +39 -40
  64. angr/analyses/decompiler/structuring/__init__.py +3 -3
  65. angr/analyses/decompiler/structuring/phoenix.py +45 -29
  66. angr/analyses/decompiler/structuring/structurer_base.py +2 -2
  67. angr/analyses/decompiler/structuring/structurer_nodes.py +23 -14
  68. angr/analyses/deobfuscator/__init__.py +3 -3
  69. angr/analyses/deobfuscator/irsb_reg_collector.py +29 -60
  70. angr/analyses/deobfuscator/string_obf_finder.py +2 -2
  71. angr/analyses/deobfuscator/string_obf_opt_passes.py +1 -1
  72. angr/analyses/disassembly.py +4 -4
  73. angr/analyses/forward_analysis/__init__.py +1 -1
  74. angr/analyses/forward_analysis/visitors/graph.py +6 -6
  75. angr/analyses/init_finder.py +47 -22
  76. angr/analyses/loop_analysis.py +1 -1
  77. angr/analyses/loopfinder.py +1 -1
  78. angr/analyses/propagator/engine_base.py +21 -14
  79. angr/analyses/propagator/engine_vex.py +149 -179
  80. angr/analyses/propagator/outdated_definition_walker.py +12 -6
  81. angr/analyses/propagator/propagator.py +10 -28
  82. angr/analyses/propagator/top_checker_mixin.py +211 -5
  83. angr/analyses/propagator/vex_vars.py +4 -4
  84. angr/analyses/reaching_definitions/__init__.py +9 -9
  85. angr/analyses/reaching_definitions/call_trace.py +2 -2
  86. angr/analyses/reaching_definitions/dep_graph.py +1 -1
  87. angr/analyses/reaching_definitions/engine_ail.py +304 -329
  88. angr/analyses/reaching_definitions/engine_vex.py +243 -229
  89. angr/analyses/reaching_definitions/function_handler.py +3 -3
  90. angr/analyses/reaching_definitions/function_handler_library/__init__.py +1 -1
  91. angr/analyses/reaching_definitions/rd_state.py +47 -42
  92. angr/analyses/reassembler.py +26 -31
  93. angr/analyses/s_liveness.py +8 -0
  94. angr/analyses/s_propagator.py +18 -3
  95. angr/analyses/s_reaching_definitions/s_rda_view.py +2 -5
  96. angr/analyses/s_reaching_definitions/s_reaching_definitions.py +9 -5
  97. angr/analyses/stack_pointer_tracker.py +4 -4
  98. angr/analyses/typehoon/simple_solver.py +14 -14
  99. angr/analyses/typehoon/translator.py +10 -2
  100. angr/analyses/typehoon/typeconsts.py +11 -3
  101. angr/analyses/typehoon/typevars.py +26 -26
  102. angr/analyses/unpacker/__init__.py +1 -1
  103. angr/analyses/variable_recovery/engine_ail.py +299 -259
  104. angr/analyses/variable_recovery/engine_base.py +138 -121
  105. angr/analyses/variable_recovery/engine_vex.py +175 -185
  106. angr/analyses/variable_recovery/irsb_scanner.py +49 -38
  107. angr/analyses/variable_recovery/variable_recovery.py +28 -5
  108. angr/analyses/variable_recovery/variable_recovery_base.py +33 -34
  109. angr/analyses/variable_recovery/variable_recovery_fast.py +4 -8
  110. angr/analyses/veritesting.py +2 -2
  111. angr/analyses/vfg.py +5 -5
  112. angr/analyses/xrefs.py +46 -19
  113. angr/angrdb/serializers/__init__.py +1 -1
  114. angr/annocfg.py +20 -15
  115. angr/blade.py +2 -2
  116. angr/block.py +20 -25
  117. angr/calling_conventions.py +12 -14
  118. angr/code_location.py +6 -10
  119. angr/codenode.py +3 -3
  120. angr/engines/__init__.py +12 -14
  121. angr/engines/engine.py +24 -61
  122. angr/engines/light/__init__.py +13 -5
  123. angr/engines/light/data.py +1 -1
  124. angr/engines/light/engine.py +1003 -1185
  125. angr/engines/pcode/__init__.py +1 -1
  126. angr/engines/pcode/behavior.py +1 -1
  127. angr/engines/pcode/cc.py +2 -0
  128. angr/engines/pcode/lifter.py +13 -15
  129. angr/engines/soot/expressions/__init__.py +12 -12
  130. angr/engines/soot/statements/__init__.py +6 -6
  131. angr/engines/soot/values/__init__.py +6 -6
  132. angr/engines/soot/values/arrayref.py +2 -2
  133. angr/engines/soot/values/constants.py +1 -1
  134. angr/engines/soot/values/instancefieldref.py +1 -1
  135. angr/engines/soot/values/paramref.py +1 -1
  136. angr/engines/soot/values/staticfieldref.py +1 -1
  137. angr/engines/successors.py +15 -14
  138. angr/engines/vex/__init__.py +5 -5
  139. angr/engines/vex/claripy/ccall.py +2 -2
  140. angr/engines/vex/claripy/datalayer.py +1 -1
  141. angr/engines/vex/claripy/irop.py +19 -19
  142. angr/engines/vex/heavy/__init__.py +2 -2
  143. angr/engines/vex/heavy/actions.py +1 -3
  144. angr/engines/vex/heavy/heavy.py +4 -6
  145. angr/engines/vex/lifter.py +2 -4
  146. angr/engines/vex/light/light.py +0 -2
  147. angr/engines/vex/light/slicing.py +5 -5
  148. angr/exploration_techniques/__init__.py +19 -142
  149. angr/exploration_techniques/base.py +126 -0
  150. angr/exploration_techniques/bucketizer.py +1 -1
  151. angr/exploration_techniques/dfs.py +3 -1
  152. angr/exploration_techniques/director.py +2 -3
  153. angr/exploration_techniques/driller_core.py +1 -1
  154. angr/exploration_techniques/explorer.py +4 -2
  155. angr/exploration_techniques/lengthlimiter.py +2 -1
  156. angr/exploration_techniques/local_loop_seer.py +2 -1
  157. angr/exploration_techniques/loop_seer.py +5 -5
  158. angr/exploration_techniques/manual_mergepoint.py +2 -1
  159. angr/exploration_techniques/memory_watcher.py +3 -1
  160. angr/exploration_techniques/oppologist.py +4 -5
  161. angr/exploration_techniques/slicecutor.py +4 -2
  162. angr/exploration_techniques/spiller.py +1 -1
  163. angr/exploration_techniques/stochastic.py +2 -1
  164. angr/exploration_techniques/stub_stasher.py +2 -1
  165. angr/exploration_techniques/suggestions.py +3 -1
  166. angr/exploration_techniques/symbion.py +3 -1
  167. angr/exploration_techniques/tech_builder.py +2 -1
  168. angr/exploration_techniques/threading.py +2 -11
  169. angr/exploration_techniques/timeout.py +4 -2
  170. angr/exploration_techniques/tracer.py +4 -3
  171. angr/exploration_techniques/unique.py +3 -2
  172. angr/exploration_techniques/veritesting.py +1 -1
  173. angr/factory.py +36 -6
  174. angr/keyed_region.py +4 -4
  175. angr/knowledge_base.py +1 -1
  176. angr/knowledge_plugins/__init__.py +11 -11
  177. angr/knowledge_plugins/cfg/__init__.py +5 -5
  178. angr/knowledge_plugins/cfg/cfg_manager.py +2 -2
  179. angr/knowledge_plugins/cfg/cfg_model.py +8 -8
  180. angr/knowledge_plugins/cfg/cfg_node.py +19 -19
  181. angr/knowledge_plugins/cfg/indirect_jump.py +6 -6
  182. angr/knowledge_plugins/cfg/memory_data.py +5 -7
  183. angr/knowledge_plugins/functions/function.py +48 -52
  184. angr/knowledge_plugins/functions/function_parser.py +4 -4
  185. angr/knowledge_plugins/key_definitions/__init__.py +3 -3
  186. angr/knowledge_plugins/key_definitions/atoms.py +8 -8
  187. angr/knowledge_plugins/key_definitions/definition.py +1 -1
  188. angr/knowledge_plugins/key_definitions/live_definitions.py +30 -27
  189. angr/knowledge_plugins/labels.py +1 -1
  190. angr/knowledge_plugins/propagations/__init__.py +1 -1
  191. angr/knowledge_plugins/propagations/prop_value.py +2 -2
  192. angr/knowledge_plugins/propagations/propagation_model.py +7 -8
  193. angr/knowledge_plugins/propagations/states.py +44 -39
  194. angr/knowledge_plugins/variables/variable_access.py +2 -2
  195. angr/knowledge_plugins/variables/variable_manager.py +24 -10
  196. angr/knowledge_plugins/xrefs/xref.py +5 -8
  197. angr/misc/__init__.py +4 -4
  198. angr/misc/hookset.py +4 -5
  199. angr/misc/loggers.py +2 -2
  200. angr/misc/telemetry.py +1 -1
  201. angr/procedures/__init__.py +1 -1
  202. angr/procedures/cgc/fdwait.py +2 -2
  203. angr/procedures/definitions/__init__.py +2 -2
  204. angr/procedures/definitions/linux_kernel.py +0 -1
  205. angr/procedures/definitions/parse_syscalls_from_local_system.py +1 -1
  206. angr/procedures/definitions/parse_win32json.py +0 -1
  207. angr/procedures/ntdll/exceptions.py +1 -1
  208. angr/procedures/stubs/format_parser.py +3 -3
  209. angr/procedures/win32/dynamic_loading.py +1 -1
  210. angr/protos/__init__.py +3 -3
  211. angr/sim_manager.py +3 -5
  212. angr/sim_state.py +40 -42
  213. angr/sim_state_options.py +3 -3
  214. angr/sim_type.py +15 -14
  215. angr/sim_variable.py +42 -45
  216. angr/simos/__init__.py +4 -4
  217. angr/simos/cgc.py +1 -1
  218. angr/simos/simos.py +1 -1
  219. angr/simos/userland.py +1 -1
  220. angr/slicer.py +4 -7
  221. angr/state_plugins/__init__.py +34 -34
  222. angr/state_plugins/callstack.py +5 -12
  223. angr/state_plugins/heap/__init__.py +2 -2
  224. angr/state_plugins/heap/heap_brk.py +2 -4
  225. angr/state_plugins/heap/heap_ptmalloc.py +1 -1
  226. angr/state_plugins/jni_references.py +3 -2
  227. angr/state_plugins/scratch.py +1 -1
  228. angr/state_plugins/sim_action.py +1 -4
  229. angr/state_plugins/sim_event.py +1 -1
  230. angr/state_plugins/solver.py +7 -9
  231. angr/state_plugins/uc_manager.py +1 -1
  232. angr/state_plugins/view.py +2 -2
  233. angr/storage/__init__.py +1 -1
  234. angr/storage/file.py +10 -10
  235. angr/storage/memory_mixins/__init__.py +46 -46
  236. angr/storage/memory_mixins/default_filler_mixin.py +1 -3
  237. angr/storage/memory_mixins/javavm_memory_mixin.py +2 -2
  238. angr/storage/memory_mixins/name_resolution_mixin.py +2 -2
  239. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -3
  240. angr/storage/memory_mixins/paged_memory/pages/__init__.py +6 -6
  241. angr/storage/memory_mixins/paged_memory/pages/list_page.py +1 -1
  242. angr/storage/memory_mixins/paged_memory/pages/multi_values.py +1 -1
  243. angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +1 -1
  244. angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +2 -4
  245. angr/storage/memory_mixins/regioned_memory/__init__.py +3 -3
  246. angr/storage/memory_mixins/regioned_memory/region_data.py +5 -5
  247. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +7 -9
  248. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +4 -4
  249. angr/storage/memory_object.py +4 -4
  250. angr/utils/__init__.py +3 -3
  251. angr/utils/bits.py +12 -0
  252. angr/utils/dynamic_dictlist.py +1 -1
  253. angr/utils/graph.py +1 -1
  254. angr/utils/orderedset.py +4 -1
  255. angr/utils/segment_list.py +2 -2
  256. angr/utils/ssa/__init__.py +33 -8
  257. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/METADATA +6 -6
  258. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/RECORD +262 -263
  259. angr/analyses/propagator/engine_ail.py +0 -1562
  260. angr/storage/memory_mixins/__init__.pyi +0 -48
  261. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/LICENSE +0 -0
  262. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/WHEEL +0 -0
  263. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/entry_points.txt +0 -0
  264. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/top_level.txt +0 -0
@@ -1,15 +1,16 @@
1
1
  # pylint:disable=unused-argument
2
2
  from __future__ import annotations
3
- from typing import TYPE_CHECKING
3
+ from typing import cast, TYPE_CHECKING
4
4
 
5
5
  import claripy
6
6
  import pyvex
7
7
  from archinfo.arch_arm import is_arm_arch
8
8
 
9
+ from angr.block import Block
9
10
  from angr.errors import SimMemoryMissingError
10
11
  from angr.calling_conventions import SimRegArg, SimStackArg, default_cc
11
12
  from angr.engines.vex.claripy.datalayer import value as claripy_value
12
- from angr.engines.light import SimEngineLightVEXMixin
13
+ from angr.engines.light import SimEngineNostmtVEX
13
14
  from angr.knowledge_plugins import Function
14
15
  from angr.storage.memory_mixins.paged_memory.pages.multi_values import MultiValues
15
16
  from angr.analyses.typehoon import typevars, typeconsts
@@ -17,43 +18,49 @@ from .engine_base import SimEngineVRBase, RichR
17
18
  from .irsb_scanner import VEXIRSBScanner
18
19
 
19
20
  if TYPE_CHECKING:
20
- from .variable_recovery_base import VariableRecoveryStateBase
21
+ pass
22
+
23
+ binop_handler = SimEngineNostmtVEX[
24
+ "VariableRecoveryFastState", RichR[claripy.ast.BV | claripy.ast.FP], None
25
+ ].binop_handler
21
26
 
22
27
 
23
28
  class SimEngineVRVEX(
24
- SimEngineLightVEXMixin,
25
- SimEngineVRBase,
29
+ SimEngineNostmtVEX["VariableRecoveryFastState", RichR[claripy.ast.BV | claripy.ast.FP], None],
30
+ SimEngineVRBase["VariableRecoveryFastState", Block],
26
31
  ):
27
32
  """
28
33
  Implements the VEX engine for variable recovery analysis.
29
34
  """
30
35
 
31
- state: VariableRecoveryStateBase
36
+ reg_read_stmts_to_ignore: set[int]
37
+ stmts_to_lower: set[int]
32
38
 
33
39
  def __init__(self, *args, call_info=None, **kwargs):
34
40
  super().__init__(*args, **kwargs)
35
41
 
36
42
  self.call_info = call_info or {}
37
- self.stmts_to_lower = None
38
- self.reg_read_stmts_to_ignore = None
39
43
 
40
44
  # Statement handlers
41
45
 
42
46
  def _is_top(self, expr: RichR) -> bool:
43
47
  return self.state.is_top(expr)
44
48
 
45
- def _top(self, size: int) -> RichR:
46
- return RichR(self.state.top(size))
49
+ def _top(self, bits: int) -> RichR[claripy.ast.BV]:
50
+ return RichR(self.state.top(bits))
47
51
 
48
- def _process_Stmt(self, whitelist=None):
49
- scanner = VEXIRSBScanner(logger=self.l)
50
- scanner._process(None, None, block=self.block)
52
+ def _process_block(self, whitelist=None):
53
+ scanner = VEXIRSBScanner(self.project, logger=self.l)
54
+ scanner._process(None, block=self.block)
51
55
  self.stmts_to_lower = scanner.stmts_to_lower
52
56
  self.reg_read_stmts_to_ignore = scanner.reg_read_stmts_to_ignore
53
57
 
54
- super()._process_Stmt(whitelist=whitelist)
58
+ return super()._process_block(whitelist=whitelist)
59
+
60
+ def _handle_stmt_WrTmp(self, stmt):
61
+ self.tmps[stmt.tmp] = self._expr(stmt.data)
55
62
 
56
- def _handle_Put(self, stmt):
63
+ def _handle_stmt_Put(self, stmt):
57
64
  offset = stmt.offset
58
65
  r = self._expr(stmt.data)
59
66
  size = stmt.data.result_size(self.tyenv) // 8
@@ -62,47 +69,45 @@ class SimEngineVRVEX(
62
69
  return
63
70
  self._assign_to_register(offset, r, size)
64
71
 
65
- def _handle_PutI(self, stmt):
66
- pass
67
-
68
- def _handle_Store(self, stmt):
69
- addr_r = self._expr(stmt.addr)
72
+ def _handle_stmt_Store(self, stmt):
73
+ addr_r = self._expr_bv(stmt.addr)
70
74
  size = stmt.data.result_size(self.tyenv) // 8
71
75
  r = self._expr(stmt.data)
72
76
 
73
77
  self._store(addr_r, r, size, stmt=stmt)
74
78
 
75
- def _handle_StoreG(self, stmt):
79
+ def _handle_stmt_StoreG(self, stmt):
76
80
  guard = self._expr(stmt.guard)
77
81
  if guard is True:
78
- addr = self._expr(stmt.addr)
82
+ addr = self._expr_bv(stmt.addr)
79
83
  size = stmt.data.result_size(self.tyenv) // 8
80
84
  data = self._expr(stmt.data)
81
85
  self._store(addr, data, size, stmt=stmt)
82
86
 
83
- def _handle_LoadG(self, stmt):
87
+ def _handle_stmt_LoadG(self, stmt):
84
88
  guard = self._expr(stmt.guard)
85
89
  if guard is True:
86
- addr = self._expr(stmt.addr)
90
+ addr = self._expr_bv(stmt.addr)
87
91
  if addr is not None:
88
92
  self.tmps[stmt.dst] = self._load(addr, self.tyenv.sizeof(stmt.dst) // 8)
89
93
  elif guard is False:
90
94
  data = self._expr(stmt.alt)
91
95
  self.tmps[stmt.dst] = data
92
96
  else:
93
- self.tmps[stmt.dst] = None
97
+ self.tmps[stmt.dst] = self._top(pyvex.get_type_size(self.tyenv.lookup(stmt.dst)))
94
98
 
95
- def _handle_LLSC(self, stmt: pyvex.IRStmt.LLSC):
99
+ def _handle_stmt_LLSC(self, stmt: pyvex.IRStmt.LLSC):
96
100
  if stmt.storedata is None:
97
101
  # load-link
98
- addr = self._expr(stmt.addr)
102
+ addr = self._expr_bv(stmt.addr)
99
103
  size = self.tyenv.sizeof(stmt.result) // self.arch.byte_width
100
104
  data = self._load(addr, size)
101
105
  self.tmps[stmt.result] = data
102
106
  else:
103
107
  # store-conditional
108
+ assert isinstance(stmt.storedata, pyvex.expr.RdTmp)
104
109
  storedata = self._expr(stmt.storedata)
105
- addr = self._expr(stmt.addr)
110
+ addr = self._expr_bv(stmt.addr)
106
111
  size = self.tyenv.sizeof(stmt.storedata.tmp) // self.arch.byte_width
107
112
 
108
113
  self._store(addr, storedata, size)
@@ -110,26 +115,19 @@ class SimEngineVRVEX(
110
115
  result_size = self.tyenv.sizeof(stmt.result)
111
116
  self.tmps[stmt.result] = RichR(claripy.BVV(1, result_size))
112
117
 
113
- def _handle_NoOp(self, stmt):
114
- pass
115
-
116
118
  # Expression handlers
117
119
 
118
- def _expr(self, expr) -> RichR:
119
- """
120
+ def _expr_bv(self, expr) -> RichR[claripy.ast.BV]:
121
+ result = self._expr(expr)
122
+ assert isinstance(result.data, claripy.ast.BV)
123
+ return cast(RichR[claripy.ast.BV], result)
120
124
 
121
- :param expr:
122
- :return:
123
- :rtype: RichR
124
- """
125
+ def _expr_fp(self, expr) -> RichR[claripy.ast.FP]:
126
+ result = self._expr(expr)
127
+ assert isinstance(result.data, claripy.ast.FP)
128
+ return cast(RichR[claripy.ast.FP], result)
125
129
 
126
- r = super()._expr(expr)
127
- if r is None:
128
- bits = expr.result_size(self.tyenv)
129
- return RichR(self.state.top(bits))
130
- return r
131
-
132
- def _handle_Get(self, expr):
130
+ def _handle_expr_Get(self, expr):
133
131
  reg_offset = expr.offset
134
132
  reg_size = expr.result_size(self.tyenv) // 8
135
133
 
@@ -161,22 +159,31 @@ class SimEngineVRVEX(
161
159
  create_variable=self.stmt_idx not in self.reg_read_stmts_to_ignore,
162
160
  )
163
161
 
164
- def _handle_GetI(self, expr: pyvex.IRExpr.GetI):
165
- return RichR(self.state.top(expr.result_size(self.tyenv)))
162
+ def _handle_expr_GetI(self, expr):
163
+ return self._top(expr.result_size(self.tyenv))
164
+
165
+ def _handle_expr_ITE(self, expr):
166
+ return self._top(expr.result_size(self.tyenv))
166
167
 
167
- def _handle_Load(self, expr: pyvex.IRExpr.Load) -> RichR:
168
- addr = self._expr(expr.addr)
168
+ def _handle_expr_GSPTR(self, expr):
169
+ return self._top(expr.result_size(self.tyenv))
170
+
171
+ def _handle_expr_VECRET(self, expr):
172
+ return self._top(expr.result_size(self.tyenv))
173
+
174
+ def _handle_expr_Load(self, expr: pyvex.IRExpr.Load) -> RichR:
175
+ addr = self._expr_bv(expr.addr)
169
176
  size = expr.result_size(self.tyenv) // 8
170
177
 
171
178
  return self._load(addr, size)
172
179
 
173
- def _handle_CCall(self, expr): # pylint:disable=useless-return
180
+ def _handle_expr_CCall(self, expr): # pylint:disable=useless-return
174
181
  # ccalls don't matter
175
182
  return RichR(self.state.top(expr.result_size(self.tyenv)))
176
183
 
177
- def _handle_Conversion(self, expr: pyvex.IRExpr.Unop) -> RichR:
178
- _ = self._expr(expr.args[0])
179
- return RichR(self.state.top(expr.result_size(self.tyenv)))
184
+ def _handle_conversion(self, from_size, to_size, signed, operand) -> RichR:
185
+ _ = self._expr(operand)
186
+ return RichR(self.state.top(to_size))
180
187
 
181
188
  # Function handlers
182
189
 
@@ -208,7 +215,7 @@ class SimEngineVRVEX(
208
215
  addr = RichR(loc.stack_offset + one_sp)
209
216
  self._load(addr, loc.size)
210
217
 
211
- def _process_block_end(self):
218
+ def _process_block_end(self, stmt_result, whitelist):
212
219
  # handles block-end calls
213
220
  current_addr = self.state.block_addr
214
221
  for target_func in self.call_info.get(current_addr, []):
@@ -235,7 +242,9 @@ class SimEngineVRVEX(
235
242
  # TODO: Handle multiple return registers
236
243
  cc = self.state.function.calling_convention
237
244
  if cc is None:
238
- cc = default_cc(self.arch.name, platform=self.project.simos.name)(self.arch)
245
+ cc_cls = default_cc(self.arch.name, platform=self.project.simos.name)
246
+ assert cc_cls is not None
247
+ cc = cc_cls(self.arch)
239
248
  if isinstance(cc.RETURN_VAL, SimRegArg):
240
249
  ret_val_size = 0
241
250
  reg_offset = cc.RETURN_VAL.check_offset(self.arch)
@@ -249,27 +258,40 @@ class SimEngineVRVEX(
249
258
  ret_val_size if self.state.ret_val_size is None else max(self.state.ret_val_size, ret_val_size)
250
259
  )
251
260
 
252
- def _handle_Const(self, expr):
261
+ def _handle_expr_Const(self, expr):
253
262
  return RichR(
254
263
  claripy_value(expr.con.type, expr.con.value, size=expr.con.size), typevar=typeconsts.int_type(expr.con.size)
255
264
  )
256
265
 
257
- def _handle_Add(self, expr):
258
- arg0, arg1 = expr.args
266
+ def _handle_expr_RdTmp(self, expr):
267
+ try:
268
+ return self.tmps[expr.tmp]
269
+ except KeyError:
270
+ return self._top(expr.result_size(self.tyenv))
271
+
272
+ def _expr_pair(
273
+ self, arg0: pyvex.expr.IRExpr, arg1: pyvex.expr.IRExpr
274
+ ) -> tuple[RichR[claripy.ast.BV], RichR[claripy.ast.BV]] | tuple[RichR[claripy.ast.FP], RichR[claripy.ast.FP]]:
259
275
  r0 = self._expr(arg0)
260
276
  r1 = self._expr(arg1)
277
+ assert type(r0) is type(r1)
278
+ return r0, r1 # type: ignore
279
+
280
+ @binop_handler
281
+ def _handle_binop_Add(self, expr):
282
+ r0, r1 = self._expr_pair(expr.args[0], expr.args[1])
283
+ sum_ = r0.data + r1.data # type: ignore
261
284
 
262
285
  result_size = expr.result_size(self.tyenv)
263
286
  if r0.data.concrete and r1.data.concrete:
264
287
  # constants
265
- return RichR(r0.data + r1.data, typevar=typeconsts.int_type(result_size), type_constraints=None)
288
+ return RichR(sum_, typevar=typeconsts.int_type(result_size), type_constraints=None)
266
289
 
267
290
  typevar = None
268
291
  if r0.typevar is not None and r1.data.concrete:
269
292
  typevar = typevars.DerivedTypeVariable(r0.typevar, typevars.AddN(r1.data.concrete_value))
270
293
 
271
- sum_ = r0.data + r1.data
272
- tc = set()
294
+ tc: set[typevars.TypeConstraint] = set()
273
295
  if r0.typevar is not None and r1.typevar is not None:
274
296
  tc.add(typevars.Subtype(r0.typevar, r1.typevar))
275
297
  return RichR(
@@ -278,32 +300,30 @@ class SimEngineVRVEX(
278
300
  type_constraints=tc,
279
301
  )
280
302
 
281
- def _handle_Sub(self, expr):
282
- arg0, arg1 = expr.args
283
- r0 = self._expr(arg0)
284
- r1 = self._expr(arg1)
303
+ @binop_handler
304
+ def _handle_binop_Sub(self, expr):
305
+ r0, r1 = self._expr_pair(expr.args[0], expr.args[1])
306
+ diff = r0.data - r1.data # type: ignore
285
307
 
286
308
  result_size = expr.result_size(self.tyenv)
287
309
  if r0.data.concrete and r1.data.concrete:
288
310
  # constants
289
- return RichR(r0.data - r1.data, typevar=typeconsts.int_type(result_size), type_constraints=None)
311
+ return RichR(diff, typevar=typeconsts.int_type(result_size), type_constraints=None)
290
312
 
291
313
  typevar = None
292
314
  if r0.typevar is not None and r1.data.concrete:
293
315
  typevar = typevars.DerivedTypeVariable(r0.typevar, typevars.SubN(r1.data.concrete_value))
294
316
 
295
- diff = r0.data - r1.data
296
317
  return RichR(
297
318
  diff,
298
319
  typevar=typevar,
299
320
  )
300
321
 
301
- def _handle_And(self, expr):
302
- arg0, arg1 = expr.args
303
- r0 = self._expr(arg0)
304
- r1 = self._expr(arg1)
322
+ @binop_handler
323
+ def _handle_binop_And(self, expr):
324
+ r0 = self._expr_bv(expr.args[0])
325
+ r1 = self._expr_bv(expr.args[1])
305
326
 
306
- result_size = expr.result_size(self.tyenv)
307
327
  if r0.data.concrete and r1.data.concrete:
308
328
  # constants
309
329
  return RichR(r0.data & r1.data)
@@ -313,38 +333,40 @@ class SimEngineVRVEX(
313
333
  elif self.state.is_stack_address(r1.data):
314
334
  r = r1.data
315
335
  else:
336
+ result_size = expr.result_size(self.tyenv)
316
337
  r = self.state.top(result_size)
317
338
  return RichR(r)
318
339
 
319
- def _handle_Xor(self, expr):
320
- arg0, arg1 = expr.args
321
- r0 = self._expr(arg0)
322
- r1 = self._expr(arg1)
340
+ @binop_handler
341
+ def _handle_binop_Xor(self, expr):
342
+ r0 = self._expr_bv(expr.args[0])
343
+ r1 = self._expr_bv(expr.args[1])
323
344
 
324
- result_size = expr.result_size(self.tyenv)
325
345
  if r0.data.concrete and r1.data.concrete:
326
346
  # constants
327
347
  return RichR(r0.data ^ r1.data)
328
348
 
349
+ result_size = expr.result_size(self.tyenv)
329
350
  r = self.state.top(result_size)
330
351
  return RichR(r)
331
352
 
332
- def _handle_Or(self, expr):
333
- arg0, arg1 = expr.args
334
- r0 = self._expr(arg0)
335
- r1 = self._expr(arg1)
353
+ @binop_handler
354
+ def _handle_binop_Or(self, expr):
355
+ r0 = self._expr_bv(expr.args[0])
356
+ r1 = self._expr_bv(expr.args[1])
336
357
 
337
- result_size = expr.result_size(self.tyenv)
338
358
  if r0.data.concrete and r1.data.concrete:
339
359
  # constants
340
360
  return RichR(r0.data | r1.data)
341
361
 
362
+ result_size = expr.result_size(self.tyenv)
342
363
  r = self.state.top(result_size)
343
364
  return RichR(r)
344
365
 
345
- def _handle_Not(self, expr):
366
+ @binop_handler
367
+ def _handle_binop_Not(self, expr):
346
368
  arg = expr.args[0]
347
- r0 = self._expr(arg)
369
+ r0 = self._expr_bv(arg)
348
370
 
349
371
  result_size = expr.result_size(self.tyenv)
350
372
  if r0.data.concrete:
@@ -354,25 +376,53 @@ class SimEngineVRVEX(
354
376
  r = self.state.top(result_size)
355
377
  return RichR(r)
356
378
 
357
- def _handle_Mul(self, expr):
358
- arg0, arg1 = expr.args
359
- r0 = self._expr(arg0)
360
- r1 = self._expr(arg1)
379
+ @binop_handler
380
+ def _handle_binop_Mul(self, expr):
381
+ r0, r1 = self._expr_pair(expr.args[0], expr.args[1])
382
+
383
+ if r0.data.concrete and r1.data.concrete:
384
+ # constants
385
+ mul = r0.data * r1.data # type: ignore
386
+ return RichR(mul)
361
387
 
362
388
  result_size = expr.result_size(self.tyenv)
389
+ r = self.state.top(result_size)
390
+ return RichR(r)
391
+
392
+ @binop_handler
393
+ def _handle_binop_MullS(self, expr):
394
+ r0, r1 = self._expr_pair(expr.args[0], expr.args[1])
395
+
363
396
  if r0.data.concrete and r1.data.concrete:
364
397
  # constants
365
- return RichR(r0.data * r1.data)
398
+ xt = r0.data.size()
399
+ mul = r0.data.sign_extend(xt) * r1.data.sign_extend(xt) # type: ignore
400
+ return RichR(mul)
366
401
 
402
+ result_size = expr.result_size(self.tyenv)
367
403
  r = self.state.top(result_size)
368
404
  return RichR(r)
369
405
 
370
- def _handle_DivMod(self, expr):
371
- arg0, arg1 = expr.args
372
- r0 = self._expr(arg0)
373
- r1 = self._expr(arg1)
406
+ @binop_handler
407
+ def _handle_binop_MullU(self, expr):
408
+ r0, r1 = self._expr_pair(expr.args[0], expr.args[1])
409
+
410
+ if r0.data.concrete and r1.data.concrete:
411
+ # constants
412
+ xt = r0.data.size()
413
+ mul = r0.data.zero_extend(xt) * r1.data.zero_extend(xt) # type: ignore
414
+ return RichR(mul)
374
415
 
375
416
  result_size = expr.result_size(self.tyenv)
417
+ r = self.state.top(result_size)
418
+ return RichR(r)
419
+
420
+ @binop_handler
421
+ def _handle_binop_DivMod(self, expr):
422
+ arg0, arg1 = expr.args
423
+ r0 = self._expr_bv(arg0)
424
+ r1 = self._expr_bv(arg1)
425
+
376
426
  if r0.data.concrete and r1.data.concrete:
377
427
  # constants
378
428
  try:
@@ -402,29 +452,31 @@ class SimEngineVRVEX(
402
452
  except ZeroDivisionError:
403
453
  pass
404
454
 
455
+ result_size = expr.result_size(self.tyenv)
405
456
  r = self.state.top(result_size)
406
457
  return RichR(r)
407
458
 
408
- def _handle_Div(self, expr):
409
- arg0, arg1 = expr.args
410
- r0 = self._expr(arg0)
411
- r1 = self._expr(arg1)
459
+ @binop_handler
460
+ def _handle_binop_Div(self, expr):
461
+ r0, r1 = self._expr_pair(expr.args[0], expr.args[1])
412
462
 
413
- result_size = expr.result_size(self.tyenv)
414
463
  if r0.data.concrete and r1.data.concrete:
415
464
  # constants
416
465
  try:
417
- return RichR(r0.data / r1.data)
466
+ div = r0.data / r1.data # type: ignore
467
+ return RichR(div)
418
468
  except ZeroDivisionError:
419
469
  pass
420
470
 
471
+ result_size = expr.result_size(self.tyenv)
421
472
  r = self.state.top(result_size)
422
473
  return RichR(r)
423
474
 
424
- def _handle_Mod(self, expr):
475
+ @binop_handler
476
+ def _handle_binop_Mod(self, expr):
425
477
  arg0, arg1 = expr.args
426
- r0 = self._expr(arg0)
427
- r1 = self._expr(arg1)
478
+ r0 = self._expr_bv(arg0)
479
+ r1 = self._expr_bv(arg1)
428
480
 
429
481
  result_size = expr.result_size(self.tyenv)
430
482
  if r0.data.concrete and r1.data.concrete and r1.data.concrete_value != 0:
@@ -441,10 +493,11 @@ class SimEngineVRVEX(
441
493
  r = self.state.top(result_size)
442
494
  return RichR(r)
443
495
 
444
- def _handle_Shr(self, expr):
496
+ @binop_handler
497
+ def _handle_binop_Shr(self, expr):
445
498
  arg0, arg1 = expr.args
446
- r0 = self._expr(arg0)
447
- r1 = self._expr(arg1)
499
+ r0 = self._expr_bv(arg0)
500
+ r1 = self._expr_bv(arg1)
448
501
 
449
502
  result_size = expr.result_size(self.tyenv)
450
503
  if r0.data.concrete and r1.data.concrete:
@@ -461,10 +514,11 @@ class SimEngineVRVEX(
461
514
  typevar=r0.typevar,
462
515
  )
463
516
 
464
- def _handle_Sar(self, expr):
517
+ @binop_handler
518
+ def _handle_binop_Sar(self, expr):
465
519
  arg0, arg1 = expr.args
466
- r0 = self._expr(arg0)
467
- r1 = self._expr(arg1)
520
+ r0 = self._expr_bv(arg0)
521
+ r1 = self._expr_bv(arg1)
468
522
 
469
523
  result_size = expr.result_size(self.tyenv)
470
524
  if r0.data.concrete and r1.data.concrete:
@@ -476,15 +530,13 @@ class SimEngineVRVEX(
476
530
  )
477
531
 
478
532
  r = self.state.top(result_size)
479
- return RichR(
480
- r,
481
- typevar=r0.typevar,
482
- )
533
+ return RichR(r, typevar=r0.typevar)
483
534
 
484
- def _handle_Shl(self, expr):
535
+ @binop_handler
536
+ def _handle_binop_Shl(self, expr):
485
537
  arg0, arg1 = expr.args
486
- r0 = self._expr(arg0)
487
- r1 = self._expr(arg1)
538
+ r0 = self._expr_bv(arg0)
539
+ r1 = self._expr_bv(arg1)
488
540
 
489
541
  result_size = expr.result_size(self.tyenv)
490
542
  if r0.data.concrete and r1.data.concrete:
@@ -501,82 +553,20 @@ class SimEngineVRVEX(
501
553
  typevar=r0.typevar,
502
554
  )
503
555
 
504
- def _handle_CmpF(self, expr):
505
- return RichR(self.state.top(expr.result_size(self.tyenv)))
506
-
507
- def _handle_16HLto32(self, expr):
508
- return RichR(self.state.top(32))
509
-
510
- def _handle_Add_v(self, expr, vector_size, vector_count):
511
- return RichR(self.state.top(expr.result_size(self.tyenv)))
512
-
513
- def _handle_QSub_v(self, expr, vector_size, vector_count):
514
- return RichR(self.state.top(expr.result_size(self.tyenv)))
515
-
516
- def _handle_HAdd_v(self, expr, vector_size, vector_count):
517
- return RichR(self.state.top(expr.result_size(self.tyenv)))
518
-
519
- def _handle_Clz(self, expr):
520
- return RichR(self.state.top(expr.result_size(self.tyenv)))
521
-
522
- def _handle_Ctz(self, expr):
523
- return RichR(self.state.top(expr.result_size(self.tyenv)))
524
-
525
- def _handle_Mull(self, expr):
526
- return RichR(self.state.top(expr.result_size(self.tyenv)))
527
-
528
- def _handle_CmpEQ(self, expr):
529
- arg0, arg1 = expr.args
530
- _ = self._expr(arg0)
531
- _ = self._expr(arg1)
532
-
533
- return RichR(self.state.top(1))
534
-
535
- def _handle_CmpNE(self, expr):
556
+ @binop_handler
557
+ def _handle_binop_CmpEQ(self, expr):
536
558
  arg0, arg1 = expr.args
537
- _ = self._expr(arg0)
538
- _ = self._expr(arg1)
559
+ self._expr(arg0)
560
+ self._expr(arg1)
539
561
 
540
562
  return RichR(self.state.top(1))
541
563
 
542
- def _handle_CmpLE(self, expr):
543
- arg0, arg1 = expr.args
544
- _ = self._expr(arg0)
545
- _ = self._expr(arg1)
546
-
547
- return RichR(self.state.top(1))
548
-
549
- def _handle_CmpLT(self, expr):
550
- arg0, arg1 = expr.args
551
- _ = self._expr(arg0)
552
- _ = self._expr(arg1)
553
-
554
- return RichR(self.state.top(1))
555
-
556
- def _handle_CmpGE(self, expr):
557
- arg0, arg1 = expr.args
558
- _ = self._expr(arg0)
559
- _ = self._expr(arg1)
560
-
561
- return RichR(self.state.top(1))
562
-
563
- def _handle_CmpGT(self, expr):
564
- arg0, arg1 = expr.args
565
- _ = self._expr(arg0)
566
- _ = self._expr(arg1)
567
-
568
- return RichR(self.state.top(1))
569
-
570
- def _handle_Cmp_v(self, expr, vector_size, vector_count):
571
- return RichR(self.state.top(1))
564
+ _handle_binop_CmpNE = _handle_binop_CmpEQ
565
+ _handle_binop_CmpLE = _handle_binop_CmpEQ
566
+ _handle_binop_CmpLT = _handle_binop_CmpEQ
567
+ _handle_binop_CmpGE = _handle_binop_CmpEQ
568
+ _handle_binop_CmpGT = _handle_binop_CmpEQ
572
569
 
573
570
  def _handle_ExpCmpNE64(self, expr):
574
571
  _, _ = self._expr(expr.args[0]), self._expr(expr.args[1])
575
572
  return RichR(self.state.top(expr.result_size(self.tyenv)))
576
-
577
- _handle_CmpEQ_v = _handle_Cmp_v
578
- _handle_CmpNE_v = _handle_Cmp_v
579
- _handle_CmpLE_v = _handle_Cmp_v
580
- _handle_CmpLT_v = _handle_Cmp_v
581
- _handle_CmpGE_v = _handle_Cmp_v
582
- _handle_CmpGT_v = _handle_Cmp_v