angr 9.2.101__py3-none-win_amd64.whl → 9.2.103__py3-none-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.

Potentially problematic release.


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

Files changed (240) hide show
  1. angr/__init__.py +1 -1
  2. angr/analyses/analysis.py +7 -6
  3. angr/analyses/calling_convention.py +33 -35
  4. angr/analyses/cdg.py +2 -4
  5. angr/analyses/cfg/cfb.py +4 -3
  6. angr/analyses/cfg/cfg_base.py +14 -14
  7. angr/analyses/cfg/cfg_emulated.py +3 -4
  8. angr/analyses/cfg/cfg_fast.py +46 -46
  9. angr/analyses/cfg/cfg_fast_soot.py +1 -2
  10. angr/analyses/cfg/cfg_job_base.py +2 -2
  11. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +14 -13
  12. angr/analyses/cfg/indirect_jump_resolvers/mips_elf_fast.py +5 -5
  13. angr/analyses/cfg_slice_to_sink/cfg_slice_to_sink.py +3 -3
  14. angr/analyses/complete_calling_conventions.py +13 -12
  15. angr/analyses/data_dep/data_dependency_analysis.py +24 -24
  16. angr/analyses/data_dep/dep_nodes.py +3 -3
  17. angr/analyses/ddg.py +1 -2
  18. angr/analyses/decompiler/ail_simplifier.py +35 -34
  19. angr/analyses/decompiler/block_io_finder.py +20 -20
  20. angr/analyses/decompiler/block_similarity.py +4 -6
  21. angr/analyses/decompiler/block_simplifier.py +17 -16
  22. angr/analyses/decompiler/callsite_maker.py +25 -10
  23. angr/analyses/decompiler/ccall_rewriters/amd64_ccalls.py +1 -3
  24. angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +2 -4
  25. angr/analyses/decompiler/clinic.py +250 -45
  26. angr/analyses/decompiler/condition_processor.py +15 -8
  27. angr/analyses/decompiler/decompilation_cache.py +7 -7
  28. angr/analyses/decompiler/decompilation_options.py +4 -4
  29. angr/analyses/decompiler/decompiler.py +19 -15
  30. angr/analyses/decompiler/expression_counters.py +10 -9
  31. angr/analyses/decompiler/goto_manager.py +2 -4
  32. angr/analyses/decompiler/graph_region.py +9 -9
  33. angr/analyses/decompiler/jump_target_collector.py +1 -2
  34. angr/analyses/decompiler/optimization_passes/__init__.py +4 -3
  35. angr/analyses/decompiler/optimization_passes/code_motion.py +5 -6
  36. angr/analyses/decompiler/optimization_passes/const_derefs.py +4 -4
  37. angr/analyses/decompiler/optimization_passes/deadblock_remover.py +73 -0
  38. angr/analyses/decompiler/optimization_passes/engine_base.py +25 -3
  39. angr/analyses/decompiler/optimization_passes/expr_op_swapper.py +6 -5
  40. angr/analyses/decompiler/optimization_passes/flip_boolean_cmp.py +2 -2
  41. angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +3 -0
  42. angr/analyses/decompiler/optimization_passes/ite_expr_converter.py +2 -2
  43. angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +17 -17
  44. angr/analyses/decompiler/optimization_passes/optimization_pass.py +12 -13
  45. angr/analyses/decompiler/optimization_passes/register_save_area_simplifier.py +25 -21
  46. angr/analyses/decompiler/optimization_passes/ret_addr_save_simplifier.py +3 -3
  47. angr/analyses/decompiler/optimization_passes/ret_deduplicator.py +1 -2
  48. angr/analyses/decompiler/optimization_passes/return_duplicator_base.py +7 -7
  49. angr/analyses/decompiler/optimization_passes/spilled_register_finder.py +18 -0
  50. angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +2 -3
  51. angr/analyses/decompiler/optimization_passes/win_stack_canary_simplifier.py +1 -2
  52. angr/analyses/decompiler/optimization_passes/x86_gcc_getpc_simplifier.py +2 -2
  53. angr/analyses/decompiler/peephole_optimizations/__init__.py +4 -3
  54. angr/analyses/decompiler/peephole_optimizations/base.py +13 -15
  55. angr/analyses/decompiler/peephole_optimizations/bswap.py +1 -3
  56. angr/analyses/decompiler/peephole_optimizations/cmpord_rewriter.py +72 -0
  57. angr/analyses/decompiler/peephole_optimizations/const_mull_a_shift.py +1 -2
  58. angr/analyses/decompiler/peephole_optimizations/eager_eval.py +1 -1
  59. angr/analyses/decompiler/peephole_optimizations/inlined_strcpy.py +5 -10
  60. angr/analyses/decompiler/peephole_optimizations/inlined_strcpy_consolidation.py +3 -4
  61. angr/analyses/decompiler/peephole_optimizations/inlined_wstrcpy.py +7 -10
  62. angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +2 -3
  63. angr/analyses/decompiler/peephole_optimizations/sar_to_signed_div.py +1 -2
  64. angr/analyses/decompiler/peephole_optimizations/tidy_stack_addr.py +4 -4
  65. angr/analyses/decompiler/redundant_label_remover.py +4 -5
  66. angr/analyses/decompiler/region_identifier.py +4 -5
  67. angr/analyses/decompiler/region_simplifiers/cascading_cond_transformer.py +1 -2
  68. angr/analyses/decompiler/region_simplifiers/expr_folding.py +19 -20
  69. angr/analyses/decompiler/region_simplifiers/goto.py +2 -3
  70. angr/analyses/decompiler/region_simplifiers/loop.py +1 -2
  71. angr/analyses/decompiler/region_simplifiers/node_address_finder.py +1 -2
  72. angr/analyses/decompiler/region_simplifiers/region_simplifier.py +1 -3
  73. angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +19 -19
  74. angr/analyses/decompiler/return_maker.py +1 -2
  75. angr/analyses/decompiler/structured_codegen/base.py +5 -6
  76. angr/analyses/decompiler/structured_codegen/c.py +39 -38
  77. angr/analyses/decompiler/structuring/__init__.py +1 -1
  78. angr/analyses/decompiler/structuring/dream.py +17 -16
  79. angr/analyses/decompiler/structuring/phoenix.py +45 -46
  80. angr/analyses/decompiler/structuring/recursive_structurer.py +4 -4
  81. angr/analyses/decompiler/structuring/structurer_base.py +16 -15
  82. angr/analyses/decompiler/structuring/structurer_nodes.py +10 -9
  83. angr/analyses/decompiler/utils.py +17 -16
  84. angr/analyses/disassembly.py +7 -6
  85. angr/analyses/flirt.py +9 -9
  86. angr/analyses/forward_analysis/forward_analysis.py +15 -14
  87. angr/analyses/forward_analysis/visitors/function_graph.py +1 -2
  88. angr/analyses/forward_analysis/visitors/graph.py +16 -15
  89. angr/analyses/propagator/engine_ail.py +30 -26
  90. angr/analyses/propagator/outdated_definition_walker.py +8 -7
  91. angr/analyses/propagator/propagator.py +11 -13
  92. angr/analyses/proximity_graph.py +21 -21
  93. angr/analyses/reaching_definitions/__init__.py +3 -3
  94. angr/analyses/reaching_definitions/call_trace.py +3 -6
  95. angr/analyses/reaching_definitions/dep_graph.py +41 -48
  96. angr/analyses/reaching_definitions/engine_ail.py +11 -5
  97. angr/analyses/reaching_definitions/engine_vex.py +9 -8
  98. angr/analyses/reaching_definitions/function_handler.py +51 -34
  99. angr/analyses/reaching_definitions/heap_allocator.py +3 -4
  100. angr/analyses/reaching_definitions/rd_initializer.py +8 -8
  101. angr/analyses/reaching_definitions/rd_state.py +57 -58
  102. angr/analyses/reaching_definitions/reaching_definitions.py +18 -17
  103. angr/analyses/reaching_definitions/subject.py +2 -3
  104. angr/analyses/stack_pointer_tracker.py +15 -6
  105. angr/analyses/typehoon/dfa.py +4 -4
  106. angr/analyses/typehoon/simple_solver.py +48 -52
  107. angr/analyses/typehoon/translator.py +3 -6
  108. angr/analyses/typehoon/typeconsts.py +13 -14
  109. angr/analyses/typehoon/typehoon.py +9 -9
  110. angr/analyses/typehoon/typevars.py +18 -17
  111. angr/analyses/variable_recovery/engine_ail.py +5 -5
  112. angr/analyses/variable_recovery/engine_base.py +25 -21
  113. angr/analyses/variable_recovery/irsb_scanner.py +8 -9
  114. angr/analyses/variable_recovery/variable_recovery.py +1 -2
  115. angr/analyses/variable_recovery/variable_recovery_base.py +14 -13
  116. angr/analyses/variable_recovery/variable_recovery_fast.py +8 -8
  117. angr/analyses/veritesting.py +1 -2
  118. angr/analyses/vfg.py +57 -56
  119. angr/analyses/xrefs.py +1 -2
  120. angr/angrdb/db.py +7 -7
  121. angr/angrdb/serializers/kb.py +16 -13
  122. angr/angrdb/serializers/loader.py +1 -2
  123. angr/angrdb/serializers/structured_code.py +2 -2
  124. angr/annocfg.py +1 -2
  125. angr/block.py +16 -6
  126. angr/calling_conventions.py +27 -27
  127. angr/code_location.py +8 -8
  128. angr/codenode.py +1 -2
  129. angr/concretization_strategies/max.py +1 -3
  130. angr/distributed/server.py +1 -3
  131. angr/distributed/worker.py +1 -2
  132. angr/engines/engine.py +2 -3
  133. angr/engines/light/engine.py +4 -4
  134. angr/engines/pcode/behavior.py +20 -2
  135. angr/engines/pcode/emulate.py +1 -1
  136. angr/engines/pcode/engine.py +7 -7
  137. angr/engines/pcode/lifter.py +78 -77
  138. angr/engines/vex/claripy/ccall.py +1 -2
  139. angr/engines/vex/claripy/datalayer.py +1 -2
  140. angr/engines/vex/light/light.py +1 -2
  141. angr/exploration_techniques/tracer.py +4 -4
  142. angr/factory.py +12 -15
  143. angr/flirt/__init__.py +8 -8
  144. angr/flirt/build_sig.py +2 -3
  145. angr/keyed_region.py +2 -2
  146. angr/knowledge_base/knowledge_base.py +3 -3
  147. angr/knowledge_plugins/callsite_prototypes.py +4 -6
  148. angr/knowledge_plugins/cfg/cfg_manager.py +19 -6
  149. angr/knowledge_plugins/cfg/cfg_model.py +26 -27
  150. angr/knowledge_plugins/cfg/cfg_node.py +2 -2
  151. angr/knowledge_plugins/cfg/indirect_jump.py +6 -8
  152. angr/knowledge_plugins/cfg/memory_data.py +8 -9
  153. angr/knowledge_plugins/custom_strings.py +1 -3
  154. angr/knowledge_plugins/debug_variables.py +2 -2
  155. angr/knowledge_plugins/functions/function.py +21 -22
  156. angr/knowledge_plugins/functions/function_manager.py +5 -5
  157. angr/knowledge_plugins/indirect_jumps.py +1 -3
  158. angr/knowledge_plugins/key_definitions/atoms.py +7 -7
  159. angr/knowledge_plugins/key_definitions/definition.py +14 -14
  160. angr/knowledge_plugins/key_definitions/environment.py +5 -7
  161. angr/knowledge_plugins/key_definitions/heap_address.py +1 -3
  162. angr/knowledge_plugins/key_definitions/key_definition_manager.py +3 -2
  163. angr/knowledge_plugins/key_definitions/live_definitions.py +60 -59
  164. angr/knowledge_plugins/key_definitions/liveness.py +16 -16
  165. angr/knowledge_plugins/key_definitions/rd_model.py +15 -15
  166. angr/knowledge_plugins/key_definitions/uses.py +11 -11
  167. angr/knowledge_plugins/patches.py +4 -8
  168. angr/knowledge_plugins/propagations/prop_value.py +10 -9
  169. angr/knowledge_plugins/propagations/propagation_manager.py +3 -5
  170. angr/knowledge_plugins/propagations/propagation_model.py +9 -9
  171. angr/knowledge_plugins/propagations/states.py +52 -22
  172. angr/knowledge_plugins/structured_code/manager.py +2 -2
  173. angr/knowledge_plugins/sync/sync_controller.py +3 -3
  174. angr/knowledge_plugins/variables/variable_access.py +4 -4
  175. angr/knowledge_plugins/variables/variable_manager.py +56 -39
  176. angr/knowledge_plugins/xrefs/xref.py +9 -11
  177. angr/knowledge_plugins/xrefs/xref_manager.py +3 -4
  178. angr/lib/angr_native.dll +0 -0
  179. angr/misc/ansi.py +1 -2
  180. angr/misc/autoimport.py +3 -3
  181. angr/misc/plugins.py +9 -9
  182. angr/procedures/definitions/__init__.py +16 -16
  183. angr/procedures/definitions/linux_kernel.py +1 -1
  184. angr/procedures/definitions/parse_win32json.py +1 -1
  185. angr/procedures/java_jni/__init__.py +1 -1
  186. angr/procedures/java_jni/array_operations.py +1 -2
  187. angr/procedures/java_jni/method_calls.py +1 -2
  188. angr/procedures/posix/inet_ntoa.py +1 -2
  189. angr/procedures/stubs/format_parser.py +3 -3
  190. angr/project.py +13 -11
  191. angr/sim_manager.py +12 -12
  192. angr/sim_procedure.py +7 -3
  193. angr/sim_state.py +2 -2
  194. angr/sim_type.py +60 -45
  195. angr/sim_variable.py +5 -5
  196. angr/simos/simos.py +1 -2
  197. angr/simos/userland.py +1 -2
  198. angr/state_plugins/callstack.py +3 -2
  199. angr/state_plugins/history.py +1 -2
  200. angr/state_plugins/solver.py +34 -34
  201. angr/storage/memory_mixins/__init__.py +4 -3
  202. angr/storage/memory_mixins/actions_mixin.py +1 -3
  203. angr/storage/memory_mixins/address_concretization_mixin.py +1 -3
  204. angr/storage/memory_mixins/convenient_mappings_mixin.py +3 -4
  205. angr/storage/memory_mixins/default_filler_mixin.py +1 -1
  206. angr/storage/memory_mixins/label_merger_mixin.py +2 -2
  207. angr/storage/memory_mixins/multi_value_merger_mixin.py +4 -3
  208. angr/storage/memory_mixins/paged_memory/page_backer_mixins.py +9 -8
  209. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +12 -11
  210. angr/storage/memory_mixins/paged_memory/pages/cooperation.py +8 -8
  211. angr/storage/memory_mixins/paged_memory/pages/history_tracking_mixin.py +2 -3
  212. angr/storage/memory_mixins/paged_memory/pages/list_page.py +10 -11
  213. angr/storage/memory_mixins/paged_memory/pages/multi_values.py +11 -10
  214. angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +18 -17
  215. angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +12 -11
  216. angr/storage/memory_mixins/regioned_memory/abstract_address_descriptor.py +3 -3
  217. angr/storage/memory_mixins/regioned_memory/abstract_merger_mixin.py +3 -2
  218. angr/storage/memory_mixins/regioned_memory/region_data.py +1 -2
  219. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +2 -2
  220. angr/storage/memory_mixins/regioned_memory/regioned_address_concretization_mixin.py +3 -3
  221. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +18 -21
  222. angr/storage/memory_mixins/size_resolution_mixin.py +1 -2
  223. angr/storage/memory_mixins/symbolic_merger_mixin.py +3 -2
  224. angr/storage/memory_mixins/top_merger_mixin.py +3 -2
  225. angr/storage/memory_object.py +2 -4
  226. angr/utils/algo.py +3 -2
  227. angr/utils/dynamic_dictlist.py +5 -5
  228. angr/utils/formatting.py +4 -4
  229. angr/utils/funcid.py +1 -2
  230. angr/utils/graph.py +5 -6
  231. angr/utils/library.py +5 -5
  232. angr/utils/mp.py +5 -4
  233. angr/utils/segment_list.py +3 -4
  234. angr/utils/typing.py +3 -2
  235. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/METADATA +9 -11
  236. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/RECORD +240 -237
  237. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/LICENSE +0 -0
  238. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/WHEEL +0 -0
  239. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/entry_points.txt +0 -0
  240. {angr-9.2.101.dist-info → angr-9.2.103.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  # pylint:disable=line-too-long,missing-class-docstring,no-self-use
2
2
  import logging
3
- from typing import Optional, List, Dict, Type, Union
3
+ from typing import Optional, Union
4
4
  from collections import defaultdict
5
5
 
6
6
  import claripy
@@ -116,7 +116,7 @@ class AllocHelper:
116
116
 
117
117
 
118
118
  def refine_locs_with_struct_type(
119
- arch: archinfo.Arch, locs: List, arg_type: SimType, offset: int = 0, treat_bot_as_int=True
119
+ arch: archinfo.Arch, locs: list, arg_type: SimType, offset: int = 0, treat_bot_as_int=True
120
120
  ):
121
121
  # CONTRACT FOR USING THIS METHOD: locs must be a list of locs which are all wordsize
122
122
  # ADDITIONAL NUANCE: this will not respect the need for big-endian integers to be stored at the end of words.
@@ -265,7 +265,7 @@ class SimFunctionArgument:
265
265
  def refine(self, size, arch=None, offset=None, is_fp=None):
266
266
  raise NotImplementedError
267
267
 
268
- def get_footprint(self) -> List[Union["SimRegArg", "SimStackArg"]]:
268
+ def get_footprint(self) -> list[Union["SimRegArg", "SimStackArg"]]:
269
269
  """
270
270
  Return a list of SimRegArg and SimStackArgs that are the base components used for this location
271
271
  """
@@ -424,7 +424,7 @@ class SimStructArg(SimFunctionArgument):
424
424
  :ivar locs: The storage locations to use
425
425
  """
426
426
 
427
- def __init__(self, struct: SimStruct, locs: Dict[str, SimFunctionArgument]):
427
+ def __init__(self, struct: SimStruct, locs: dict[str, SimFunctionArgument]):
428
428
  super().__init__(sum(loc.size for loc in locs.values()))
429
429
  self.struct = struct
430
430
  self.locs = locs
@@ -557,18 +557,18 @@ class SimCC:
557
557
  # Here are all the things a subclass needs to specify!
558
558
  #
559
559
 
560
- ARG_REGS: List[str] = [] # A list of all the registers used for integral args, in order (names or offsets)
561
- FP_ARG_REGS: List[str] = [] # A list of all the registers used for floating point args, in order
560
+ ARG_REGS: list[str] = [] # A list of all the registers used for integral args, in order (names or offsets)
561
+ FP_ARG_REGS: list[str] = [] # A list of all the registers used for floating point args, in order
562
562
  STACKARG_SP_BUFF = 0 # The amount of stack space reserved between the saved return address
563
563
  # (if applicable) and the arguments. Probably zero.
564
564
  STACKARG_SP_DIFF = 0 # The amount of stack space reserved for the return address
565
- CALLER_SAVED_REGS: List[str] = [] # Caller-saved registers
565
+ CALLER_SAVED_REGS: list[str] = [] # Caller-saved registers
566
566
  RETURN_ADDR: SimFunctionArgument = None # The location where the return address is stored, as a SimFunctionArgument
567
567
  RETURN_VAL: SimFunctionArgument = None # The location where the return value is stored, as a SimFunctionArgument
568
- OVERFLOW_RETURN_VAL: Optional[SimFunctionArgument] = (
568
+ OVERFLOW_RETURN_VAL: SimFunctionArgument | None = (
569
569
  None # The second half of the location where a double-length return value is stored
570
570
  )
571
- FP_RETURN_VAL: Optional[SimFunctionArgument] = (
571
+ FP_RETURN_VAL: SimFunctionArgument | None = (
572
572
  None # The location where floating-point argument return values are stored
573
573
  )
574
574
  ARCH = None # The archinfo.Arch class that this CC must be used for, if relevant
@@ -629,7 +629,7 @@ class SimCC:
629
629
 
630
630
  ArgSession = ArgSession # import this from global scope so SimCC subclasses can subclass it if they like
631
631
 
632
- def arg_session(self, ret_ty: Optional[SimType]):
632
+ def arg_session(self, ret_ty: SimType | None):
633
633
  """
634
634
  Return an arg session.
635
635
 
@@ -785,7 +785,7 @@ class SimCC:
785
785
 
786
786
  return result
787
787
 
788
- def arg_locs(self, prototype) -> List[SimFunctionArgument]:
788
+ def arg_locs(self, prototype) -> list[SimFunctionArgument]:
789
789
  if prototype._arch is None:
790
790
  prototype = prototype.with_arch(self.arch)
791
791
  session = self.arg_session(prototype.returnty)
@@ -1073,7 +1073,7 @@ class SimCC:
1073
1073
  return isinstance(other, self.__class__)
1074
1074
 
1075
1075
  @classmethod
1076
- def _match(cls, arch, args: List, sp_delta):
1076
+ def _match(cls, arch, args: list, sp_delta):
1077
1077
  if cls.ARCH is not None and not isinstance(
1078
1078
  arch, cls.ARCH
1079
1079
  ): # pylint:disable=isinstance-second-argument-not-valid-type
@@ -1103,7 +1103,7 @@ class SimCC:
1103
1103
 
1104
1104
  @staticmethod
1105
1105
  def find_cc(
1106
- arch: "archinfo.Arch", args: List[SimFunctionArgument], sp_delta: int, platform: str = "Linux"
1106
+ arch: "archinfo.Arch", args: list[SimFunctionArgument], sp_delta: int, platform: str = "Linux"
1107
1107
  ) -> Optional["SimCC"]:
1108
1108
  """
1109
1109
  Pinpoint the best-fit calling convention and return the corresponding SimCC instance, or None if no fit is
@@ -1472,7 +1472,7 @@ class SimCCSystemVAMD64(SimCC):
1472
1472
 
1473
1473
  return refine_locs_with_struct_type(self.arch, mapped_classes, arg_type)
1474
1474
 
1475
- def return_val(self, ty: Optional[SimType], perspective_returned=False):
1475
+ def return_val(self, ty: SimType | None, perspective_returned=False):
1476
1476
  if ty is None:
1477
1477
  return None
1478
1478
  if ty._arch is None:
@@ -1552,8 +1552,8 @@ class SimCCSystemVAMD64(SimCC):
1552
1552
  else:
1553
1553
  raise NotImplementedError("Ummmmm... not sure what goes here. report bug to @rhelmot")
1554
1554
 
1555
- def _flatten(self, ty) -> Optional[Dict[int, List[SimType]]]:
1556
- result: Dict[int, List[SimType]] = defaultdict(list)
1555
+ def _flatten(self, ty) -> dict[int, list[SimType]] | None:
1556
+ result: dict[int, list[SimType]] = defaultdict(list)
1557
1557
  if isinstance(ty, SimStruct):
1558
1558
  if ty.packed:
1559
1559
  return None
@@ -1733,8 +1733,8 @@ class SimCCARM(SimCC):
1733
1733
  return "INTEGER"
1734
1734
  return "SSE"
1735
1735
 
1736
- def _flatten(self, ty) -> Optional[Dict[int, List[SimType]]]:
1737
- result: Dict[int, List[SimType]] = defaultdict(list)
1736
+ def _flatten(self, ty) -> dict[int, list[SimType]] | None:
1737
+ result: dict[int, list[SimType]] = defaultdict(list)
1738
1738
  if isinstance(ty, SimStruct):
1739
1739
  if ty.packed:
1740
1740
  return None
@@ -1957,8 +1957,8 @@ class SimCCO32(SimCC):
1957
1957
  return "INTEGER"
1958
1958
  return "SSE"
1959
1959
 
1960
- def _flatten(self, ty) -> Optional[Dict[int, List[SimType]]]:
1961
- result: Dict[int, List[SimType]] = defaultdict(list)
1960
+ def _flatten(self, ty) -> dict[int, list[SimType]] | None:
1961
+ result: dict[int, list[SimType]] = defaultdict(list)
1962
1962
  if isinstance(ty, SimStruct):
1963
1963
  if ty.packed:
1964
1964
  return None
@@ -2156,7 +2156,7 @@ class SimCCS390XLinuxSyscall(SimCCSyscall):
2156
2156
  return state.regs.r1
2157
2157
 
2158
2158
 
2159
- CC: Dict[str, Dict[str, List[Type[SimCC]]]] = {
2159
+ CC: dict[str, dict[str, list[type[SimCC]]]] = {
2160
2160
  "AMD64": {
2161
2161
  "default": [SimCCSystemVAMD64],
2162
2162
  "Linux": [SimCCSystemVAMD64],
@@ -2207,7 +2207,7 @@ CC: Dict[str, Dict[str, List[Type[SimCC]]]] = {
2207
2207
  }
2208
2208
 
2209
2209
 
2210
- DEFAULT_CC: Dict[str, Dict[str, Type[SimCC]]] = {
2210
+ DEFAULT_CC: dict[str, dict[str, type[SimCC]]] = {
2211
2211
  "AMD64": {"Linux": SimCCSystemVAMD64, "Win32": SimCCMicrosoftAMD64},
2212
2212
  "X86": {"Linux": SimCCCdecl, "CGC": SimCCCdecl, "Win32": SimCCMicrosoftCdecl},
2213
2213
  "ARMEL": {"Linux": SimCCARM},
@@ -2225,7 +2225,7 @@ DEFAULT_CC: Dict[str, Dict[str, Type[SimCC]]] = {
2225
2225
  }
2226
2226
 
2227
2227
 
2228
- def register_default_cc(arch: str, cc: Type[SimCC], platform: str = "Linux"):
2228
+ def register_default_cc(arch: str, cc: type[SimCC], platform: str = "Linux"):
2229
2229
  DEFAULT_CC[arch] = {platform: cc}
2230
2230
  if arch not in CC:
2231
2231
  CC[arch] = {}
@@ -2263,11 +2263,11 @@ for k, vs in ARCH_NAME_ALIASES.items():
2263
2263
 
2264
2264
  def default_cc( # pylint:disable=unused-argument
2265
2265
  arch: str,
2266
- platform: Optional[str] = "Linux",
2267
- language: Optional[str] = None,
2266
+ platform: str | None = "Linux",
2267
+ language: str | None = None,
2268
2268
  syscall: bool = False,
2269
2269
  **kwargs,
2270
- ) -> Optional[Type[SimCC]]:
2270
+ ) -> type[SimCC] | None:
2271
2271
  """
2272
2272
  Return the default calling convention for a given architecture, platform, and language combination.
2273
2273
 
@@ -2318,7 +2318,7 @@ def unify_arch_name(arch: str) -> str:
2318
2318
  return ALIAS_TO_ARCH_NAME.get(arch, arch)
2319
2319
 
2320
2320
 
2321
- SYSCALL_CC: Dict[str, Dict[str, Type[SimCCSyscall]]] = {
2321
+ SYSCALL_CC: dict[str, dict[str, type[SimCCSyscall]]] = {
2322
2322
  "X86": {
2323
2323
  "default": SimCCX86LinuxSyscall,
2324
2324
  "Linux": SimCCX86LinuxSyscall,
angr/code_location.py CHANGED
@@ -1,4 +1,4 @@
1
- from typing import Optional, Dict, Tuple, Any
1
+ from typing import Any
2
2
 
3
3
 
4
4
  class CodeLocation:
@@ -21,9 +21,9 @@ class CodeLocation:
21
21
  def __init__(
22
22
  self,
23
23
  block_addr: int,
24
- stmt_idx: Optional[int],
24
+ stmt_idx: int | None,
25
25
  sim_procedure=None,
26
- ins_addr: Optional[int] = None,
26
+ ins_addr: int | None = None,
27
27
  context: Any = None,
28
28
  block_idx: int = None,
29
29
  **kwargs,
@@ -42,14 +42,14 @@ class CodeLocation:
42
42
  """
43
43
 
44
44
  self.block_addr: int = block_addr
45
- self.stmt_idx: Optional[int] = stmt_idx
45
+ self.stmt_idx: int | None = stmt_idx
46
46
  self.sim_procedure = sim_procedure
47
- self.ins_addr: Optional[int] = ins_addr
48
- self.context: Optional[Tuple[int]] = context
47
+ self.ins_addr: int | None = ins_addr
48
+ self.context: tuple[int] | None = context
49
49
  self.block_idx = block_idx
50
50
  self._hash = None
51
51
 
52
- self.info: Optional[Dict] = None
52
+ self.info: dict | None = None
53
53
 
54
54
  if kwargs:
55
55
  self._store_kwargs(**kwargs)
@@ -152,7 +152,7 @@ class ExternalCodeLocation(CodeLocation):
152
152
 
153
153
  __slots__ = ("call_string",)
154
154
 
155
- def __init__(self, call_string: Optional[Tuple[int, ...]] = None):
155
+ def __init__(self, call_string: tuple[int, ...] | None = None):
156
156
  super().__init__(0, None)
157
157
  self.call_string = call_string if call_string is not None else ()
158
158
 
angr/codenode.py CHANGED
@@ -1,5 +1,4 @@
1
1
  import logging
2
- from typing import List
3
2
 
4
3
  l = logging.getLogger(name=__name__)
5
4
 
@@ -46,7 +45,7 @@ class CodeNode:
46
45
  self._hash = hash((self.addr, self.size))
47
46
  return self._hash
48
47
 
49
- def successors(self) -> List["CodeNode"]:
48
+ def successors(self) -> list["CodeNode"]:
50
49
  if self._graph is None:
51
50
  raise ValueError("Cannot calculate successors for graphless node")
52
51
  return list(self._graph.successors(self))
@@ -1,5 +1,3 @@
1
- from typing import Optional
2
-
3
1
  from ..errors import SimSolverError
4
2
  from . import SimConcretizationStrategy
5
3
 
@@ -9,7 +7,7 @@ class SimConcretizationStrategyMax(SimConcretizationStrategy):
9
7
  Concretization strategy that returns the maximum address.
10
8
  """
11
9
 
12
- def __init__(self, max_addr: Optional[int] = None):
10
+ def __init__(self, max_addr: int | None = None):
13
11
  super().__init__()
14
12
  self._max_addr = max_addr
15
13
 
@@ -1,5 +1,3 @@
1
- from typing import Dict, Tuple
2
-
3
1
  import logging
4
2
  import time
5
3
  import os
@@ -63,7 +61,7 @@ class Server:
63
61
  self._recursion_limit = recursion_limit
64
62
 
65
63
  self._worker_exit_args_lock = None
66
- self._worker_exit_args: Dict[int, Tuple] = None
64
+ self._worker_exit_args: dict[int, tuple] = None
67
65
 
68
66
  # the following will not be pickled
69
67
  self._worker_exit_callback = worker_exit_callback
@@ -1,4 +1,3 @@
1
- from typing import Dict
2
1
  import time
3
2
  import multiprocessing
4
3
  import logging
@@ -42,7 +41,7 @@ class ExplorationStatusNotifier(ExplorationTechnique):
42
41
  Force the exploration to stop if the server.stop is True.
43
42
  """
44
43
 
45
- def __init__(self, server_state: Dict):
44
+ def __init__(self, server_state: dict):
46
45
  super().__init__()
47
46
  self.server_state = server_state
48
47
 
angr/engines/engine.py CHANGED
@@ -3,7 +3,6 @@
3
3
  import abc
4
4
  import logging
5
5
  import threading
6
- from typing import Optional
7
6
  import angr
8
7
 
9
8
  from archinfo.arch_soot import SootAddressDescriptor
@@ -20,7 +19,7 @@ class SimEngineBase:
20
19
  def __init__(self, project=None, **kwargs):
21
20
  if kwargs:
22
21
  raise TypeError("Unused initializer args: " + ", ".join(kwargs.keys()))
23
- self.project: Optional[angr.Project] = project
22
+ self.project: angr.Project | None = project
24
23
  self.state = None
25
24
 
26
25
  __tls = ("state",)
@@ -107,7 +106,7 @@ class SuccessorsMixin(SimEngine):
107
106
  def __init__(self, *args, **kwargs):
108
107
  super().__init__(*args, **kwargs)
109
108
 
110
- self.successors: Optional[SimSuccessors] = None
109
+ self.successors: SimSuccessors | None = None
111
110
 
112
111
  __tls = ("successors",)
113
112
 
@@ -1,5 +1,5 @@
1
1
  # pylint:disable=no-self-use,isinstance-second-argument-not-valid-type,unused-argument
2
- from typing import Tuple, Optional, Union, Any
2
+ from typing import Any
3
3
  import struct
4
4
  import re
5
5
  import logging
@@ -23,7 +23,7 @@ class SimEngineLightMixin:
23
23
  """
24
24
 
25
25
  def __init__(self, *args, logger=None, **kwargs):
26
- self.arch: Optional[archinfo.Arch] = None
26
+ self.arch: archinfo.Arch | None = None
27
27
  self.l = logger
28
28
  super().__init__(*args, **kwargs)
29
29
 
@@ -53,7 +53,7 @@ class SimEngineLightMixin:
53
53
  return base
54
54
 
55
55
  @staticmethod
56
- def extract_offset_to_sp(spoffset_expr: claripy.ast.Base) -> Optional[int]:
56
+ def extract_offset_to_sp(spoffset_expr: claripy.ast.Base) -> int | None:
57
57
  """
58
58
  Extract the offset to the original stack pointer.
59
59
 
@@ -485,7 +485,7 @@ class SimEngineLightVEXMixin(SimEngineLightMixin):
485
485
  # Binary operation handlers
486
486
  #
487
487
 
488
- def _binop_get_args(self, expr) -> Union[Optional[Tuple[Any, Any]], Optional[Any]]:
488
+ def _binop_get_args(self, expr) -> tuple[Any, Any] | None | Any | None:
489
489
  arg0, arg1 = expr.args
490
490
  expr_0 = self._expr(arg0)
491
491
  if expr_0 is None:
@@ -1,5 +1,5 @@
1
1
  import operator
2
- from typing import Callable, Iterable, Tuple
2
+ from collections.abc import Callable, Iterable
3
3
 
4
4
  import claripy
5
5
  from claripy.ast.bv import BV
@@ -14,7 +14,7 @@ except ImportError:
14
14
  # pylint:disable=abstract-method
15
15
 
16
16
 
17
- def make_bv_sizes_equal(bv1: BV, bv2: BV) -> Tuple[BV, BV]:
17
+ def make_bv_sizes_equal(bv1: BV, bv2: BV) -> tuple[BV, BV]:
18
18
  """
19
19
  Makes two BVs equal in length through sign extension.
20
20
  """
@@ -886,6 +886,23 @@ class OpBehaviorPopcount(OpBehavior):
886
886
  return expr
887
887
 
888
888
 
889
+ class OpBehaviorLzcount(OpBehavior):
890
+ """
891
+ Behavior for the LZCOUNT operation.
892
+ """
893
+
894
+ def __init__(self):
895
+ super().__init__(OpCode.LZCOUNT, True)
896
+
897
+ def evaluate_unary(self, size_out: int, size_in: int, in1: BV) -> BV:
898
+ expr = claripy.BVV(len(in1), size_out * 8)
899
+ for pos in range(len(in1)):
900
+ expr = claripy.If(
901
+ claripy.Extract(pos, pos, in1) == claripy.BVV(1, 1), claripy.BVV(len(in1) - pos - 1, size_out * 8), expr
902
+ )
903
+ return expr
904
+
905
+
889
906
  class BehaviorFactory:
890
907
  """
891
908
  Returns the behavior object for a given opcode.
@@ -973,5 +990,6 @@ class BehaviorFactory:
973
990
  OpCode.INSERT: OpBehavior(OpCode.INSERT, False, True),
974
991
  OpCode.EXTRACT: OpBehavior(OpCode.EXTRACT, False, True),
975
992
  OpCode.POPCOUNT: OpBehaviorPopcount(),
993
+ OpCode.LZCOUNT: OpBehaviorLzcount(),
976
994
  }
977
995
  )
@@ -27,7 +27,7 @@ class PcodeEmulatorMixin(SimEngineBase):
27
27
 
28
28
  _current_op: Optional["PcodeOp"]
29
29
  _current_op_idx: int
30
- _current_behavior: Optional[OpBehavior]
30
+ _current_behavior: OpBehavior | None
31
31
 
32
32
  def __init__(self, *args, **kwargs):
33
33
  super().__init__(*args, **kwargs)
@@ -1,4 +1,4 @@
1
- from typing import Optional, Iterable
1
+ from collections.abc import Iterable
2
2
 
3
3
  import claripy
4
4
  import logging
@@ -50,13 +50,13 @@ class HeavyPcodeMixin(
50
50
  def process_successors(
51
51
  self,
52
52
  successors: SimSuccessors,
53
- irsb: Optional[IRSB] = None,
54
- insn_text: Optional[str] = None,
55
- insn_bytes: Optional[bytes] = None,
53
+ irsb: IRSB | None = None,
54
+ insn_text: str | None = None,
55
+ insn_bytes: bytes | None = None,
56
56
  thumb: bool = False,
57
- size: Optional[int] = None,
58
- num_inst: Optional[int] = None,
59
- extra_stop_points: Optional[Iterable[int]] = None,
57
+ size: int | None = None,
58
+ num_inst: int | None = None,
59
+ extra_stop_points: Iterable[int] | None = None,
60
60
  **kwargs,
61
61
  ) -> None:
62
62
  # pylint:disable=arguments-differ