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
@@ -123,12 +123,12 @@ class SketchNode(SketchNodeBase):
123
123
  Represents a node in a sketch graph.
124
124
  """
125
125
 
126
- __slots__ = ("typevar", "upper_bound", "lower_bound")
126
+ __slots__ = ("lower_bound", "typevar", "upper_bound")
127
127
 
128
128
  def __init__(self, typevar: TypeVariable | DerivedTypeVariable):
129
129
  self.typevar: TypeVariable | DerivedTypeVariable = typevar
130
- self.upper_bound = TopType()
131
- self.lower_bound = BottomType()
130
+ self.upper_bound: TypeConstant = TopType()
131
+ self.lower_bound: TypeConstant = BottomType()
132
132
 
133
133
  def __repr__(self):
134
134
  return f"{self.lower_bound} <: {self.typevar} <: {self.upper_bound}"
@@ -164,8 +164,8 @@ class Sketch:
164
164
 
165
165
  __slots__ = (
166
166
  "graph",
167
- "root",
168
167
  "node_mapping",
168
+ "root",
169
169
  "solver",
170
170
  )
171
171
 
@@ -202,7 +202,7 @@ class Sketch:
202
202
  node = self.lookup(node.target)
203
203
  return node
204
204
 
205
- def add_edge(self, src: SketchNodeBase, dst: SketchNodeBase, label):
205
+ def add_edge(self, src: SketchNodeBase, dst: SketchNodeBase, label) -> None:
206
206
  self.graph.add_edge(src, dst, label=label)
207
207
 
208
208
  def add_constraint(self, constraint: TypeConstraint) -> None:
@@ -214,13 +214,15 @@ class Sketch:
214
214
  if SimpleSolver._typevar_inside_set(subtype, PRIMITIVE_TYPES) and not SimpleSolver._typevar_inside_set(
215
215
  supertype, PRIMITIVE_TYPES
216
216
  ):
217
- super_node: SketchNode | None = self.lookup(supertype)
217
+ super_node = self.lookup(supertype)
218
+ assert super_node is None or isinstance(super_node, SketchNode)
218
219
  if super_node is not None:
219
220
  super_node.lower_bound = self.solver.join(super_node.lower_bound, subtype)
220
221
  elif SimpleSolver._typevar_inside_set(supertype, PRIMITIVE_TYPES) and not SimpleSolver._typevar_inside_set(
221
222
  subtype, PRIMITIVE_TYPES
222
223
  ):
223
- sub_node: SketchNode | None = self.lookup(subtype)
224
+ sub_node = self.lookup(subtype)
225
+ assert sub_node is None or isinstance(sub_node, SketchNode)
224
226
  # assert sub_node is not None
225
227
  if sub_node is not None:
226
228
  sub_node.upper_bound = self.solver.meet(sub_node.upper_bound, supertype)
@@ -261,7 +263,7 @@ class FORGOTTEN(enum.Enum):
261
263
 
262
264
 
263
265
  class ConstraintGraphNode:
264
- __slots__ = ("typevar", "variance", "tag", "forgotten")
266
+ __slots__ = ("forgotten", "tag", "typevar", "variance")
265
267
 
266
268
  def __init__(
267
269
  self,
@@ -365,7 +367,7 @@ class SimpleSolver:
365
367
 
366
368
  def __init__(self, bits: int, constraints, typevars):
367
369
  if bits not in (32, 64):
368
- raise ValueError("Pointer size %d is not supported. Expect 32 or 64." % bits)
370
+ raise ValueError(f"Pointer size {bits} is not supported. Expect 32 or 64.")
369
371
 
370
372
  self.bits = bits
371
373
  self._constraints: dict[TypeVariable, set[TypeConstraint]] = constraints
@@ -625,10 +627,8 @@ class SimpleSolver:
625
627
  for _, dst0, data0 in graph.out_edges(cls0, data=True):
626
628
  if "label" in data0 and data0["label"] is not None:
627
629
  for _, dst1, data1 in graph.out_edges(cls1, data=True):
628
- if (
629
- data0["label"] == data1["label"]
630
- or isinstance(data0["label"], Load)
631
- and isinstance(data1["label"], Store)
630
+ if data0["label"] == data1["label"] or (
631
+ isinstance(data0["label"], Load) and isinstance(data1["label"], Store)
632
632
  ):
633
633
  SimpleSolver._unify(
634
634
  equivalence_classes, equivalence_classes[dst0], equivalence_classes[dst1], graph
@@ -1278,4 +1278,4 @@ class SimpleSolver:
1278
1278
  return Pointer32
1279
1279
  if self.bits == 64:
1280
1280
  return Pointer64
1281
- raise NotImplementedError("Unsupported bits %d" % self.bits)
1281
+ raise NotImplementedError(f"Unsupported bits {self.bits}")
@@ -42,7 +42,7 @@ class TypeTranslator:
42
42
  #
43
43
 
44
44
  def struct_name(self):
45
- return "struct_%d" % next(self._struct_ctr)
45
+ return f"struct_{next(self._struct_ctr)}"
46
46
 
47
47
  #
48
48
  # Type translation
@@ -151,6 +151,9 @@ class TypeTranslator:
151
151
  def _translate_Int256(self, tc): # pylint:disable=unused-argument
152
152
  return sim_type.SimTypeInt256(signed=False).with_arch(self.arch)
153
153
 
154
+ def _translate_Int512(self, tc): # pylint:disable=unused-argument
155
+ return sim_type.SimTypeInt512(signed=False).with_arch(self.arch)
156
+
154
157
  def _translate_TypeVariableReference(self, tc):
155
158
  if tc.typevar in self.translated:
156
159
  return self.translated[tc.typevar]
@@ -190,6 +193,9 @@ class TypeTranslator:
190
193
  def _translate_SimTypeInt256(self, st: sim_type.SimTypeChar) -> typeconsts.Int256:
191
194
  return typeconsts.Int256()
192
195
 
196
+ def _translate_SimTypeInt512(self, st: sim_type.SimTypeChar) -> typeconsts.Int512:
197
+ return typeconsts.Int512()
198
+
193
199
  def _translate_SimTypeInt(self, st: sim_type.SimTypeInt) -> typeconsts.Int32:
194
200
  return typeconsts.Int32()
195
201
 
@@ -221,7 +227,7 @@ class TypeTranslator:
221
227
  return typeconsts.Pointer32(base)
222
228
  if self.arch.bits == 64:
223
229
  return typeconsts.Pointer64(base)
224
- raise TypeError("Unsupported pointer size %d" % self.arch.bits)
230
+ raise TypeError(f"Unsupported pointer size {self.arch.bits}")
225
231
 
226
232
 
227
233
  TypeConstHandlers = {
@@ -235,6 +241,7 @@ TypeConstHandlers = {
235
241
  typeconsts.Int64: TypeTranslator._translate_Int64,
236
242
  typeconsts.Int128: TypeTranslator._translate_Int128,
237
243
  typeconsts.Int256: TypeTranslator._translate_Int256,
244
+ typeconsts.Int512: TypeTranslator._translate_Int512,
238
245
  typeconsts.TypeVariableReference: TypeTranslator._translate_TypeVariableReference,
239
246
  }
240
247
 
@@ -247,6 +254,7 @@ SimTypeHandlers = {
247
254
  sim_type.SimTypeChar: TypeTranslator._translate_SimTypeChar,
248
255
  sim_type.SimTypeInt128: TypeTranslator._translate_SimTypeInt128,
249
256
  sim_type.SimTypeInt256: TypeTranslator._translate_SimTypeInt256,
257
+ sim_type.SimTypeInt512: TypeTranslator._translate_SimTypeInt512,
250
258
  sim_type.SimStruct: TypeTranslator._translate_SimStruct,
251
259
  sim_type.SimTypeArray: TypeTranslator._translate_SimTypeArray,
252
260
  }
@@ -107,6 +107,13 @@ class Int256(Int):
107
107
  return "int256"
108
108
 
109
109
 
110
+ class Int512(Int):
111
+ SIZE = 32
112
+
113
+ def __repr__(self, memo=None):
114
+ return "int512"
115
+
116
+
110
117
  class FloatBase(TypeConstant):
111
118
  def __repr__(self, memo=None):
112
119
  return "floatbase"
@@ -182,7 +189,7 @@ class Array(TypeConstant):
182
189
  def __repr__(self, memo=None):
183
190
  if self.count is None:
184
191
  return f"{self.element!r}[?]"
185
- return "%r[%d]" % (self.element, self.count)
192
+ return f"{self.element!r}[{self.count}]"
186
193
 
187
194
  def __eq__(self, other):
188
195
  return type(other) is type(self) and self.element == other.element and self.count == other.count
@@ -281,7 +288,7 @@ class TypeVariableReference(TypeConstant):
281
288
  #
282
289
 
283
290
 
284
- def int_type(bits: int) -> Int | None:
291
+ def int_type(bits: int) -> Int:
285
292
  mapping = {
286
293
  1: Int1,
287
294
  8: Int8,
@@ -290,10 +297,11 @@ def int_type(bits: int) -> Int | None:
290
297
  64: Int64,
291
298
  128: Int128,
292
299
  256: Int256,
300
+ 512: Int512,
293
301
  }
294
302
  if bits in mapping:
295
303
  return mapping[bits]()
296
- return None
304
+ raise TypeError(f"Not a known size of int: {bits}")
297
305
 
298
306
 
299
307
  def float_type(bits: int) -> FloatBase | None:
@@ -26,9 +26,9 @@ class TypeConstraint:
26
26
 
27
27
  class Equivalence(TypeConstraint):
28
28
  __slots__ = (
29
+ "_cached_hash",
29
30
  "type_a",
30
31
  "type_b",
31
- "_cached_hash",
32
32
  )
33
33
 
34
34
  def __init__(self, type_a, type_b):
@@ -44,10 +44,8 @@ class Equivalence(TypeConstraint):
44
44
 
45
45
  def __eq__(self, other):
46
46
  return type(other) is Equivalence and (
47
- self.type_a == other.type_a
48
- and self.type_b == other.type_b
49
- or self.type_b == other.type_a
50
- and self.type_a == other.type_b
47
+ (self.type_a == other.type_a and self.type_b == other.type_b)
48
+ or (self.type_b == other.type_a and self.type_a == other.type_b)
51
49
  )
52
50
 
53
51
  def __hash__(self):
@@ -55,7 +53,7 @@ class Equivalence(TypeConstraint):
55
53
 
56
54
 
57
55
  class Existence(TypeConstraint):
58
- __slots__ = ("type_", "_cached_hash")
56
+ __slots__ = ("_cached_hash", "type_")
59
57
 
60
58
  def __init__(self, type_):
61
59
  self.type_ = type_
@@ -85,9 +83,9 @@ class Existence(TypeConstraint):
85
83
 
86
84
  class Subtype(TypeConstraint):
87
85
  __slots__ = (
88
- "super_type",
89
- "sub_type",
90
86
  "_cached_hash",
87
+ "sub_type",
88
+ "super_type",
91
89
  )
92
90
 
93
91
  def __init__(self, sub_type: TypeType, super_type: TypeType):
@@ -141,10 +139,10 @@ class Add(TypeConstraint):
141
139
  """
142
140
 
143
141
  __slots__ = (
142
+ "_cached_hash",
144
143
  "type_0",
145
144
  "type_1",
146
145
  "type_r",
147
- "_cached_hash",
148
146
  )
149
147
 
150
148
  def __init__(self, type_0, type_1, type_r):
@@ -210,10 +208,10 @@ class Sub(TypeConstraint):
210
208
  """
211
209
 
212
210
  __slots__ = (
211
+ "_cached_hash",
213
212
  "type_0",
214
213
  "type_1",
215
214
  "type_r",
216
- "_cached_hash",
217
215
  )
218
216
 
219
217
  def __init__(self, type_0, type_1, type_r):
@@ -277,7 +275,7 @@ _typevariable_counter = count()
277
275
 
278
276
 
279
277
  class TypeVariable:
280
- __slots__ = ("idx", "name", "_cached_hash")
278
+ __slots__ = ("_cached_hash", "idx", "name")
281
279
 
282
280
  def __init__(self, idx: int | None = None, name: str | None = None):
283
281
  if idx is None:
@@ -310,18 +308,18 @@ class TypeVariable:
310
308
  def __repr__(self):
311
309
  if self.name:
312
310
  return f"{self.name}|tv_{self.idx:02d}"
313
- return "tv_%02d" % self.idx
311
+ return f"tv_{self.idx:02d}"
314
312
 
315
313
 
316
314
  class DerivedTypeVariable(TypeVariable):
317
- __slots__ = ("type_var", "labels")
315
+ __slots__ = ("labels", "type_var")
318
316
 
319
- type_var: TypeVariable | TypeConstant
317
+ labels: tuple[BaseLabel, ...]
320
318
 
321
319
  def __init__(
322
320
  self,
323
- type_var: TypeVariable | DerivedTypeVariable | None,
324
- label,
321
+ type_var: TypeType,
322
+ label: BaseLabel | None,
325
323
  labels: Iterable[BaseLabel] | None = None,
326
324
  idx=None,
327
325
  ):
@@ -339,8 +337,10 @@ class DerivedTypeVariable(TypeVariable):
339
337
 
340
338
  if label is not None:
341
339
  self.labels = (*existing_labels, label)
340
+ elif labels is not None:
341
+ self.labels = existing_labels + tuple(labels)
342
342
  else:
343
- self.labels: tuple[BaseLabel] = existing_labels + tuple(labels)
343
+ self.labels = existing_labels
344
344
 
345
345
  if not self.labels:
346
346
  raise ValueError("A DerivedTypeVariable must have at least one label")
@@ -350,10 +350,10 @@ class DerivedTypeVariable(TypeVariable):
350
350
  def one_label(self) -> BaseLabel | None:
351
351
  return self.labels[0] if len(self.labels) == 1 else None
352
352
 
353
- def path(self) -> tuple[BaseLabel]:
353
+ def path(self) -> tuple[BaseLabel, ...]:
354
354
  return self.labels
355
355
 
356
- def longest_prefix(self) -> TypeVariable | DerivedTypeVariable | None:
356
+ def longest_prefix(self) -> TypeType | None:
357
357
  if not self.labels:
358
358
  return None
359
359
  if len(self.labels) == 1:
@@ -396,8 +396,8 @@ class DerivedTypeVariable(TypeVariable):
396
396
 
397
397
  class TypeVariables:
398
398
  __slots__ = (
399
- "_typevars",
400
399
  "_last_typevars",
400
+ "_typevars",
401
401
  )
402
402
 
403
403
  def __init__(self):
@@ -416,9 +416,9 @@ class TypeVariables:
416
416
  # sum(len(v) for v in self._typevars.items()),
417
417
  # len(self._typevars),
418
418
  # )
419
- return "{TypeVars: %d items}" % len(self._typevars)
419
+ return f"{{TypeVars: {len(self._typevars)} items}}"
420
420
 
421
- def add_type_variable(self, var: SimVariable, codeloc, typevar: TypeVariable): # pylint:disable=unused-argument
421
+ def add_type_variable(self, var: SimVariable, codeloc, typevar: TypeType): # pylint:disable=unused-argument
422
422
  if var not in self._typevars:
423
423
  self._typevars[var] = set()
424
424
  elif typevar in self._typevars[var]:
@@ -512,7 +512,7 @@ class AddN(BaseLabel):
512
512
  super().__init__()
513
513
 
514
514
  def __repr__(self):
515
- return "+%d" % self.n
515
+ return f"+{self.n}"
516
516
 
517
517
 
518
518
  class SubN(BaseLabel):
@@ -523,7 +523,7 @@ class SubN(BaseLabel):
523
523
  super().__init__()
524
524
 
525
525
  def __repr__(self):
526
- return "-%d" % self.n
526
+ return f"-{self.n}"
527
527
 
528
528
 
529
529
  class ConvertTo(BaseLabel):
@@ -534,13 +534,13 @@ class ConvertTo(BaseLabel):
534
534
  super().__init__()
535
535
 
536
536
  def __repr__(self):
537
- return "conv(%d)" % self.to_bits
537
+ return f"conv({self.to_bits})"
538
538
 
539
539
 
540
540
  class ReinterpretAs(BaseLabel):
541
541
  __slots__ = (
542
- "to_type",
543
542
  "to_bits",
543
+ "to_type",
544
544
  )
545
545
 
546
546
  def __init__(self, to_type, to_bits):
@@ -3,4 +3,4 @@ from .packing_detector import PackingDetector
3
3
  from .obfuscation_detector import ObfuscationDetector
4
4
 
5
5
 
6
- __all__ = ("PackingDetector", "ObfuscationDetector")
6
+ __all__ = ("ObfuscationDetector", "PackingDetector")