angr 9.2.131__py3-none-win_amd64.whl → 9.2.133__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.
- angr/__init__.py +128 -128
- angr/analyses/__init__.py +38 -38
- angr/analyses/analysis.py +6 -2
- angr/analyses/backward_slice.py +3 -4
- angr/analyses/binary_optimizer.py +5 -12
- angr/analyses/bindiff.py +3 -6
- angr/analyses/calling_convention.py +3 -4
- angr/analyses/cfg/__init__.py +3 -3
- angr/analyses/cfg/cfg_base.py +1 -1
- angr/analyses/cfg/cfg_emulated.py +5 -5
- angr/analyses/cfg/cfg_fast.py +19 -17
- angr/analyses/cfg/indirect_jump_resolvers/__init__.py +5 -5
- angr/analyses/cfg/indirect_jump_resolvers/amd64_elf_got.py +1 -1
- angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +148 -101
- angr/analyses/cfg/indirect_jump_resolvers/x86_elf_pic_plt.py +1 -1
- angr/analyses/data_dep/__init__.py +4 -4
- angr/analyses/datagraph_meta.py +1 -1
- angr/analyses/ddg.py +16 -17
- angr/analyses/decompiler/__init__.py +12 -12
- angr/analyses/decompiler/ail_simplifier.py +24 -12
- angr/analyses/decompiler/block_similarity.py +2 -4
- angr/analyses/decompiler/block_simplifier.py +10 -21
- angr/analyses/decompiler/callsite_maker.py +1 -1
- angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +1 -1
- angr/analyses/decompiler/clinic.py +122 -41
- angr/analyses/decompiler/condition_processor.py +57 -39
- angr/analyses/decompiler/counters/__init__.py +3 -3
- angr/analyses/decompiler/decompilation_cache.py +7 -7
- angr/analyses/decompiler/dephication/__init__.py +1 -1
- angr/analyses/decompiler/dephication/graph_rewriting.py +1 -1
- angr/analyses/decompiler/dephication/graph_vvar_mapping.py +11 -3
- angr/analyses/decompiler/dephication/rewriting_engine.py +169 -45
- angr/analyses/decompiler/dephication/seqnode_dephication.py +5 -4
- angr/analyses/decompiler/expression_narrower.py +1 -1
- angr/analyses/decompiler/graph_region.py +8 -8
- angr/analyses/decompiler/optimization_passes/__init__.py +20 -20
- angr/analyses/decompiler/optimization_passes/const_derefs.py +1 -0
- angr/analyses/decompiler/optimization_passes/deadblock_remover.py +1 -2
- angr/analyses/decompiler/optimization_passes/div_simplifier.py +41 -16
- angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +8 -7
- angr/analyses/decompiler/optimization_passes/duplication_reverter/utils.py +1 -3
- angr/analyses/decompiler/optimization_passes/engine_base.py +262 -84
- angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +175 -39
- angr/analyses/decompiler/optimization_passes/ite_region_converter.py +2 -5
- angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +5 -5
- angr/analyses/decompiler/optimization_passes/mod_simplifier.py +12 -3
- angr/analyses/decompiler/optimization_passes/optimization_pass.py +42 -19
- angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +9 -5
- angr/analyses/decompiler/peephole_optimizations/__init__.py +1 -1
- angr/analyses/decompiler/peephole_optimizations/base.py +6 -6
- angr/analyses/decompiler/peephole_optimizations/remove_noop_conversions.py +2 -0
- angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +1 -1
- angr/analyses/decompiler/presets/__init__.py +1 -1
- angr/analyses/decompiler/region_simplifiers/expr_folding.py +3 -3
- angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +8 -12
- angr/analyses/decompiler/ssailification/rewriting.py +1 -2
- angr/analyses/decompiler/ssailification/rewriting_engine.py +139 -56
- angr/analyses/decompiler/ssailification/ssailification.py +2 -1
- angr/analyses/decompiler/ssailification/traversal.py +4 -6
- angr/analyses/decompiler/ssailification/traversal_engine.py +125 -42
- angr/analyses/decompiler/structured_codegen/__init__.py +5 -5
- angr/analyses/decompiler/structured_codegen/base.py +3 -3
- angr/analyses/decompiler/structured_codegen/c.py +39 -40
- angr/analyses/decompiler/structuring/__init__.py +3 -3
- angr/analyses/decompiler/structuring/phoenix.py +45 -29
- angr/analyses/decompiler/structuring/structurer_base.py +2 -2
- angr/analyses/decompiler/structuring/structurer_nodes.py +23 -14
- angr/analyses/deobfuscator/__init__.py +3 -3
- angr/analyses/deobfuscator/irsb_reg_collector.py +29 -60
- angr/analyses/deobfuscator/string_obf_finder.py +2 -2
- angr/analyses/deobfuscator/string_obf_opt_passes.py +1 -1
- angr/analyses/disassembly.py +4 -4
- angr/analyses/forward_analysis/__init__.py +1 -1
- angr/analyses/forward_analysis/visitors/graph.py +6 -6
- angr/analyses/init_finder.py +47 -22
- angr/analyses/loop_analysis.py +1 -1
- angr/analyses/loopfinder.py +1 -1
- angr/analyses/propagator/engine_base.py +21 -14
- angr/analyses/propagator/engine_vex.py +149 -179
- angr/analyses/propagator/outdated_definition_walker.py +12 -6
- angr/analyses/propagator/propagator.py +10 -28
- angr/analyses/propagator/top_checker_mixin.py +211 -5
- angr/analyses/propagator/vex_vars.py +4 -4
- angr/analyses/reaching_definitions/__init__.py +9 -9
- angr/analyses/reaching_definitions/call_trace.py +2 -2
- angr/analyses/reaching_definitions/dep_graph.py +1 -1
- angr/analyses/reaching_definitions/engine_ail.py +304 -329
- angr/analyses/reaching_definitions/engine_vex.py +243 -229
- angr/analyses/reaching_definitions/function_handler.py +3 -3
- angr/analyses/reaching_definitions/function_handler_library/__init__.py +1 -1
- angr/analyses/reaching_definitions/rd_state.py +47 -42
- angr/analyses/reassembler.py +26 -31
- angr/analyses/s_liveness.py +8 -0
- angr/analyses/s_propagator.py +18 -3
- angr/analyses/s_reaching_definitions/s_rda_view.py +2 -5
- angr/analyses/s_reaching_definitions/s_reaching_definitions.py +9 -5
- angr/analyses/stack_pointer_tracker.py +4 -4
- angr/analyses/typehoon/simple_solver.py +14 -14
- angr/analyses/typehoon/translator.py +10 -2
- angr/analyses/typehoon/typeconsts.py +11 -3
- angr/analyses/typehoon/typevars.py +26 -26
- angr/analyses/unpacker/__init__.py +1 -1
- angr/analyses/variable_recovery/engine_ail.py +299 -259
- angr/analyses/variable_recovery/engine_base.py +138 -121
- angr/analyses/variable_recovery/engine_vex.py +175 -185
- angr/analyses/variable_recovery/irsb_scanner.py +49 -38
- angr/analyses/variable_recovery/variable_recovery.py +28 -5
- angr/analyses/variable_recovery/variable_recovery_base.py +33 -34
- angr/analyses/variable_recovery/variable_recovery_fast.py +4 -8
- angr/analyses/veritesting.py +2 -2
- angr/analyses/vfg.py +5 -5
- angr/analyses/xrefs.py +46 -19
- angr/angrdb/serializers/__init__.py +1 -1
- angr/annocfg.py +20 -15
- angr/blade.py +2 -2
- angr/block.py +20 -25
- angr/calling_conventions.py +12 -14
- angr/code_location.py +6 -10
- angr/codenode.py +3 -3
- angr/engines/__init__.py +12 -14
- angr/engines/engine.py +24 -61
- angr/engines/light/__init__.py +13 -5
- angr/engines/light/data.py +1 -1
- angr/engines/light/engine.py +1003 -1185
- angr/engines/pcode/__init__.py +1 -1
- angr/engines/pcode/behavior.py +1 -1
- angr/engines/pcode/cc.py +2 -0
- angr/engines/pcode/lifter.py +13 -15
- angr/engines/soot/expressions/__init__.py +12 -12
- angr/engines/soot/statements/__init__.py +6 -6
- angr/engines/soot/values/__init__.py +6 -6
- angr/engines/soot/values/arrayref.py +2 -2
- angr/engines/soot/values/constants.py +1 -1
- angr/engines/soot/values/instancefieldref.py +1 -1
- angr/engines/soot/values/paramref.py +1 -1
- angr/engines/soot/values/staticfieldref.py +1 -1
- angr/engines/successors.py +15 -14
- angr/engines/vex/__init__.py +5 -5
- angr/engines/vex/claripy/ccall.py +2 -2
- angr/engines/vex/claripy/datalayer.py +1 -1
- angr/engines/vex/claripy/irop.py +19 -19
- angr/engines/vex/heavy/__init__.py +2 -2
- angr/engines/vex/heavy/actions.py +1 -3
- angr/engines/vex/heavy/heavy.py +4 -6
- angr/engines/vex/lifter.py +2 -4
- angr/engines/vex/light/light.py +0 -2
- angr/engines/vex/light/slicing.py +5 -5
- angr/exploration_techniques/__init__.py +19 -142
- angr/exploration_techniques/base.py +126 -0
- angr/exploration_techniques/bucketizer.py +1 -1
- angr/exploration_techniques/dfs.py +3 -1
- angr/exploration_techniques/director.py +2 -3
- angr/exploration_techniques/driller_core.py +1 -1
- angr/exploration_techniques/explorer.py +4 -2
- angr/exploration_techniques/lengthlimiter.py +2 -1
- angr/exploration_techniques/local_loop_seer.py +2 -1
- angr/exploration_techniques/loop_seer.py +5 -5
- angr/exploration_techniques/manual_mergepoint.py +2 -1
- angr/exploration_techniques/memory_watcher.py +3 -1
- angr/exploration_techniques/oppologist.py +4 -5
- angr/exploration_techniques/slicecutor.py +4 -2
- angr/exploration_techniques/spiller.py +1 -1
- angr/exploration_techniques/stochastic.py +2 -1
- angr/exploration_techniques/stub_stasher.py +2 -1
- angr/exploration_techniques/suggestions.py +3 -1
- angr/exploration_techniques/symbion.py +3 -1
- angr/exploration_techniques/tech_builder.py +2 -1
- angr/exploration_techniques/threading.py +2 -11
- angr/exploration_techniques/timeout.py +4 -2
- angr/exploration_techniques/tracer.py +4 -3
- angr/exploration_techniques/unique.py +3 -2
- angr/exploration_techniques/veritesting.py +1 -1
- angr/factory.py +36 -6
- angr/keyed_region.py +4 -4
- angr/knowledge_base.py +1 -1
- angr/knowledge_plugins/__init__.py +11 -11
- angr/knowledge_plugins/cfg/__init__.py +5 -5
- angr/knowledge_plugins/cfg/cfg_manager.py +2 -2
- angr/knowledge_plugins/cfg/cfg_model.py +8 -8
- angr/knowledge_plugins/cfg/cfg_node.py +19 -19
- angr/knowledge_plugins/cfg/indirect_jump.py +6 -6
- angr/knowledge_plugins/cfg/memory_data.py +5 -7
- angr/knowledge_plugins/functions/function.py +48 -52
- angr/knowledge_plugins/functions/function_parser.py +4 -4
- angr/knowledge_plugins/key_definitions/__init__.py +3 -3
- angr/knowledge_plugins/key_definitions/atoms.py +8 -8
- angr/knowledge_plugins/key_definitions/definition.py +1 -1
- angr/knowledge_plugins/key_definitions/live_definitions.py +30 -27
- angr/knowledge_plugins/labels.py +1 -1
- angr/knowledge_plugins/propagations/__init__.py +1 -1
- angr/knowledge_plugins/propagations/prop_value.py +2 -2
- angr/knowledge_plugins/propagations/propagation_model.py +7 -8
- angr/knowledge_plugins/propagations/states.py +44 -39
- angr/knowledge_plugins/variables/variable_access.py +2 -2
- angr/knowledge_plugins/variables/variable_manager.py +24 -10
- angr/knowledge_plugins/xrefs/xref.py +5 -8
- angr/lib/angr_native.dll +0 -0
- angr/misc/__init__.py +4 -4
- angr/misc/hookset.py +4 -5
- angr/misc/loggers.py +2 -2
- angr/misc/telemetry.py +1 -1
- angr/procedures/__init__.py +1 -1
- angr/procedures/cgc/fdwait.py +2 -2
- angr/procedures/definitions/__init__.py +2 -2
- angr/procedures/definitions/linux_kernel.py +0 -1
- angr/procedures/definitions/parse_syscalls_from_local_system.py +1 -1
- angr/procedures/definitions/parse_win32json.py +0 -1
- angr/procedures/ntdll/exceptions.py +1 -1
- angr/procedures/stubs/format_parser.py +3 -3
- angr/procedures/win32/dynamic_loading.py +1 -1
- angr/protos/__init__.py +3 -3
- angr/sim_manager.py +3 -5
- angr/sim_state.py +40 -42
- angr/sim_state_options.py +3 -3
- angr/sim_type.py +15 -14
- angr/sim_variable.py +42 -45
- angr/simos/__init__.py +4 -4
- angr/simos/cgc.py +1 -1
- angr/simos/simos.py +1 -1
- angr/simos/userland.py +1 -1
- angr/slicer.py +4 -7
- angr/state_plugins/__init__.py +34 -34
- angr/state_plugins/callstack.py +5 -12
- angr/state_plugins/heap/__init__.py +2 -2
- angr/state_plugins/heap/heap_brk.py +2 -4
- angr/state_plugins/heap/heap_ptmalloc.py +1 -1
- angr/state_plugins/jni_references.py +3 -2
- angr/state_plugins/scratch.py +1 -1
- angr/state_plugins/sim_action.py +1 -4
- angr/state_plugins/sim_event.py +1 -1
- angr/state_plugins/solver.py +7 -9
- angr/state_plugins/uc_manager.py +1 -1
- angr/state_plugins/view.py +2 -2
- angr/storage/__init__.py +1 -1
- angr/storage/file.py +10 -10
- angr/storage/memory_mixins/__init__.py +46 -46
- angr/storage/memory_mixins/default_filler_mixin.py +1 -3
- angr/storage/memory_mixins/javavm_memory_mixin.py +2 -2
- angr/storage/memory_mixins/name_resolution_mixin.py +2 -2
- angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -3
- angr/storage/memory_mixins/paged_memory/pages/__init__.py +6 -6
- angr/storage/memory_mixins/paged_memory/pages/list_page.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/multi_values.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +1 -1
- angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +2 -4
- angr/storage/memory_mixins/regioned_memory/__init__.py +3 -3
- angr/storage/memory_mixins/regioned_memory/region_data.py +5 -5
- angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +7 -9
- angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +4 -4
- angr/storage/memory_object.py +4 -4
- angr/utils/__init__.py +3 -3
- angr/utils/bits.py +12 -0
- angr/utils/dynamic_dictlist.py +1 -1
- angr/utils/graph.py +1 -1
- angr/utils/orderedset.py +4 -1
- angr/utils/segment_list.py +2 -2
- angr/utils/ssa/__init__.py +33 -8
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/METADATA +6 -6
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/RECORD +263 -264
- angr/analyses/propagator/engine_ail.py +0 -1562
- angr/storage/memory_mixins/__init__.pyi +0 -48
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/LICENSE +0 -0
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/WHEEL +0 -0
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/entry_points.txt +0 -0
- {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/top_level.txt +0 -0
|
@@ -19,7 +19,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
19
19
|
"""
|
|
20
20
|
|
|
21
21
|
@staticmethod
|
|
22
|
-
def _check_divisor(a, b, ndigits=6):
|
|
22
|
+
def _check_divisor(a: int, b: int, ndigits: int = 6) -> int | None:
|
|
23
23
|
if b == 0:
|
|
24
24
|
return None
|
|
25
25
|
divisor_1 = 1 + (a // b)
|
|
@@ -27,7 +27,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
27
27
|
return divisor_1 if divisor_1 == divisor_2 else None
|
|
28
28
|
|
|
29
29
|
# pylint: disable=too-many-boolean-expressions
|
|
30
|
-
def
|
|
30
|
+
def _handle_expr_Convert(self, expr: Expr.Convert):
|
|
31
31
|
if expr.from_bits == 128 and expr.to_bits == 64:
|
|
32
32
|
operand_expr = self._expr(expr.operand)
|
|
33
33
|
if (
|
|
@@ -42,18 +42,20 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
42
42
|
):
|
|
43
43
|
if operand_expr.operands[0].op == "Shr":
|
|
44
44
|
Y = operand_expr.operands[0].operands[1].value
|
|
45
|
+
assert isinstance(Y, int)
|
|
45
46
|
else:
|
|
46
47
|
Y = int(math.log2(operand_expr.operands[0].operands[1].value))
|
|
47
48
|
C = operand_expr.operands[1].value
|
|
49
|
+
assert isinstance(C, int)
|
|
48
50
|
divisor = self._check_divisor(pow(2, 64 + Y), C)
|
|
49
51
|
if divisor:
|
|
50
52
|
X = operand_expr.operands[0].operands[0]
|
|
51
53
|
new_const = Expr.Const(expr.idx, None, divisor, 64)
|
|
52
54
|
return Expr.BinaryOp(expr.idx, "Div", [X, new_const], expr.signed, **expr.tags)
|
|
53
55
|
|
|
54
|
-
return
|
|
56
|
+
return expr
|
|
55
57
|
|
|
56
|
-
def
|
|
58
|
+
def _handle_binop_Shr(self, expr):
|
|
57
59
|
operand_0 = self._expr(expr.operands[0])
|
|
58
60
|
operand_1 = self._expr(expr.operands[1])
|
|
59
61
|
|
|
@@ -90,6 +92,8 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
90
92
|
if isinstance(operand_0.operand.operands[1], Expr.Const):
|
|
91
93
|
C = operand_0.operand.operands[1].value
|
|
92
94
|
Y = operand_1.value
|
|
95
|
+
assert isinstance(C, int)
|
|
96
|
+
assert isinstance(Y, int)
|
|
93
97
|
divisor = self._check_divisor(pow(2, 64 + Y), C)
|
|
94
98
|
X = operand_0.operand.operands[0]
|
|
95
99
|
elif isinstance(operand_0.operand.operands[0], Expr.BinaryOp) and operand_0.operand.operands[0].op in {
|
|
@@ -102,6 +106,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
102
106
|
Y = operand_0.operand.operands[0].operands[1].value
|
|
103
107
|
else:
|
|
104
108
|
Y = int(math.log2(operand_0.operand.operands[0].operands[1].value))
|
|
109
|
+
assert isinstance(C, int)
|
|
110
|
+
assert isinstance(Y, int)
|
|
111
|
+
assert isinstance(Z, int)
|
|
105
112
|
divisor = self._check_divisor(pow(2, 64 + Z + Y), C)
|
|
106
113
|
X = operand_0.operand.operands[0].operands[0]
|
|
107
114
|
if isinstance(operand_1, Expr.Const) and isinstance(operand_0, Expr.BinaryOp) and operand_0.op == "Add":
|
|
@@ -127,6 +134,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
127
134
|
and V_.operands[0] == X
|
|
128
135
|
and V_.operands[1] == xC
|
|
129
136
|
):
|
|
137
|
+
assert isinstance(Y, int)
|
|
138
|
+
assert isinstance(Z, int)
|
|
139
|
+
assert isinstance(V, int)
|
|
130
140
|
divisor = self._check_divisor(
|
|
131
141
|
pow(2, Y + V + Z), C * (pow(2, V) - 1) + pow(2, Y)
|
|
132
142
|
)
|
|
@@ -141,6 +151,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
141
151
|
if isinstance(V, Expr.Const):
|
|
142
152
|
V = V.value
|
|
143
153
|
if isinstance(V_, Expr.BinaryOp) and V_.op == "Sub" and V_.operands[1] == xC:
|
|
154
|
+
assert isinstance(Y, int)
|
|
155
|
+
assert isinstance(Z, int)
|
|
156
|
+
assert isinstance(V, int)
|
|
144
157
|
divisor = self._check_divisor(pow(2, Y + V + Z), C * (pow(2, V) - 1) + pow(2, Y))
|
|
145
158
|
elif (
|
|
146
159
|
isinstance(xC, Expr.BinaryOp)
|
|
@@ -164,6 +177,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
164
177
|
Y = xC.operands[1].value
|
|
165
178
|
V = x_xC.operands[1].value
|
|
166
179
|
if x_xC.operands[0].operands[0] == X:
|
|
180
|
+
assert isinstance(Y, int)
|
|
181
|
+
assert isinstance(Z, int)
|
|
182
|
+
assert isinstance(V, int)
|
|
167
183
|
divisor = self._check_divisor(pow(2, Y + V + Z), C * (pow(2, V) - 1) + pow(2, Y))
|
|
168
184
|
|
|
169
185
|
# unsigned int
|
|
@@ -178,6 +194,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
178
194
|
C = operand_0.operands[1].value
|
|
179
195
|
Z = operand_1.value
|
|
180
196
|
X = operand_0.operands[0]
|
|
197
|
+
assert isinstance(C, int)
|
|
198
|
+
assert isinstance(Z, int)
|
|
199
|
+
assert isinstance(V, int)
|
|
181
200
|
divisor = self._check_divisor(pow(2, V + Z), C)
|
|
182
201
|
elif (
|
|
183
202
|
isinstance(operand_0.operands[0], Expr.BinaryOp)
|
|
@@ -196,11 +215,17 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
196
215
|
if operand_0.operands[0].op == "Mod":
|
|
197
216
|
Y = int(math.log2(operand_0.operands[0].operands[1].value))
|
|
198
217
|
Z = operand_1.value
|
|
218
|
+
assert isinstance(Y, int)
|
|
219
|
+
assert isinstance(Z, int)
|
|
220
|
+
assert isinstance(V, int)
|
|
221
|
+
assert isinstance(C, int)
|
|
199
222
|
divisor = self._check_divisor(pow(2, Y + Z + V), C, ndigits)
|
|
200
223
|
else:
|
|
201
224
|
X = operand_0.operands[0]
|
|
202
225
|
Y = operand_1.value
|
|
203
226
|
C = operand_0.operands[1].value
|
|
227
|
+
assert isinstance(Y, int)
|
|
228
|
+
assert isinstance(C, int)
|
|
204
229
|
divisor = self._check_divisor(pow(2, Y), C)
|
|
205
230
|
|
|
206
231
|
if divisor and X:
|
|
@@ -225,7 +250,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
225
250
|
return Expr.BinaryOp(expr.idx, "Shr", [operand_0, operand_1], expr.signed)
|
|
226
251
|
return expr
|
|
227
252
|
|
|
228
|
-
def
|
|
253
|
+
def _handle_binop_Mul(self, expr):
|
|
229
254
|
operand_0, operand_1 = expr.operands
|
|
230
255
|
|
|
231
256
|
if (
|
|
@@ -234,6 +259,8 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
234
259
|
and isinstance(operand_0.operands[1], Expr.Const)
|
|
235
260
|
and operand_0.op in {"Mod", "Shr"}
|
|
236
261
|
):
|
|
262
|
+
assert isinstance(operand_0.operands[1].value, int)
|
|
263
|
+
assert isinstance(operand_1.value, int)
|
|
237
264
|
Y = int(math.log2(operand_0.operands[1].value)) if operand_0.op == "Mod" else operand_0.operands[1].value
|
|
238
265
|
C = operand_1.value
|
|
239
266
|
X = operand_0.operands[0]
|
|
@@ -242,8 +269,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
242
269
|
if isinstance(X, Expr.Convert):
|
|
243
270
|
V = X.from_bits - X.to_bits
|
|
244
271
|
ndigits = 5 if V == 32 else 6
|
|
245
|
-
if self._check_divisor(pow(2, V + Y), C, ndigits) and X:
|
|
246
|
-
divisor = self._check_divisor(pow(2, Y + V), C, ndigits)
|
|
272
|
+
if (divisor := self._check_divisor(pow(2, V + Y), C, ndigits)) and X:
|
|
247
273
|
new_const = Expr.Const(expr.idx, None, divisor, 64)
|
|
248
274
|
return Expr.BinaryOp(expr.idx, "Div", [X, new_const], expr.signed, **expr.tags)
|
|
249
275
|
if (
|
|
@@ -252,7 +278,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
252
278
|
and isinstance(operand_0.operand, Expr.BinaryOp)
|
|
253
279
|
and isinstance(operand_0.operand.operands[1], Expr.Const)
|
|
254
280
|
and operand_0.operand.op in {"Mod", "Shr"}
|
|
281
|
+
and isinstance(operand_1.value, int)
|
|
255
282
|
):
|
|
283
|
+
assert isinstance(operand_0.operand.operands[1].value, int)
|
|
256
284
|
if operand_0.operand.op == "Mod":
|
|
257
285
|
Y = int(math.log2(operand_0.operand.operands[1].value))
|
|
258
286
|
else:
|
|
@@ -261,13 +289,12 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
261
289
|
X = operand_0.operand.operands[0]
|
|
262
290
|
V = operand_0.from_bits - operand_0.to_bits
|
|
263
291
|
ndigits = 5 if V == 32 else 6
|
|
264
|
-
if self._check_divisor(pow(2, V + Y), C, ndigits) and X:
|
|
265
|
-
divisor = self._check_divisor(pow(2, Y + V), C, ndigits)
|
|
292
|
+
if (divisor := self._check_divisor(pow(2, V + Y), C, ndigits)) and X:
|
|
266
293
|
new_const = Expr.Const(expr.idx, None, divisor, 64)
|
|
267
294
|
return Expr.BinaryOp(expr.idx, "Div", [X, new_const], expr.signed, **expr.tags)
|
|
268
|
-
return
|
|
295
|
+
return expr
|
|
269
296
|
|
|
270
|
-
def
|
|
297
|
+
def _handle_binop_Div(self, expr):
|
|
271
298
|
operand_0 = self._expr(expr.operands[0])
|
|
272
299
|
operand_1 = self._expr(expr.operands[1])
|
|
273
300
|
|
|
@@ -285,10 +312,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
285
312
|
return Expr.BinaryOp(expr.idx, "Div", [operand_0, operand_1], expr.signed, **expr.tags)
|
|
286
313
|
return expr
|
|
287
314
|
|
|
288
|
-
def
|
|
289
|
-
if len(expr.operands) != 2:
|
|
290
|
-
return super()._ail_handle_Add(expr)
|
|
291
|
-
|
|
315
|
+
def _handle_binop_Add(self, expr):
|
|
292
316
|
op0 = self._expr(expr.operands[0])
|
|
293
317
|
op1 = self._expr(expr.operands[1])
|
|
294
318
|
|
|
@@ -350,6 +374,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
|
|
|
350
374
|
X = operand_1
|
|
351
375
|
V = bits
|
|
352
376
|
ndigits = 5 if V == 32 else 6
|
|
377
|
+
assert isinstance(C, int)
|
|
353
378
|
divisor = self._check_divisor(pow(2, V), C, ndigits)
|
|
354
379
|
if divisor is not None and X:
|
|
355
380
|
new_const = Expr.Const(None, None, divisor, V)
|
|
@@ -380,7 +405,7 @@ class DivSimplifier(OptimizationPass):
|
|
|
380
405
|
super().__init__(func, **kwargs)
|
|
381
406
|
|
|
382
407
|
self.state = SimplifierAILState(self.project.arch)
|
|
383
|
-
self.engine = DivSimplifierAILEngine()
|
|
408
|
+
self.engine = DivSimplifierAILEngine(self.project)
|
|
384
409
|
|
|
385
410
|
self.analyze()
|
|
386
411
|
|
|
@@ -242,11 +242,8 @@ class DuplicationReverter(StructuringOptimizationPass):
|
|
|
242
242
|
target_candidates = []
|
|
243
243
|
for mblock, oblocks in ail_merge_graph.merge_blocks_to_originals.items():
|
|
244
244
|
for oblock in oblocks:
|
|
245
|
-
if (
|
|
246
|
-
isinstance(oblock,
|
|
247
|
-
and oblock.original.addr == target_addr
|
|
248
|
-
or isinstance(oblock, Block)
|
|
249
|
-
and oblock.addr == target_addr
|
|
245
|
+
if (isinstance(oblock, AILBlockSplit) and oblock.original.addr == target_addr) or (
|
|
246
|
+
isinstance(oblock, Block) and oblock.addr == target_addr
|
|
250
247
|
):
|
|
251
248
|
target_candidates.append(mblock)
|
|
252
249
|
|
|
@@ -287,7 +284,9 @@ class DuplicationReverter(StructuringOptimizationPass):
|
|
|
287
284
|
break
|
|
288
285
|
|
|
289
286
|
if new_target is None:
|
|
290
|
-
|
|
287
|
+
_l.debug("Unable to correct a predecessor, this is a bug!")
|
|
288
|
+
self.write_graph = self.read_graph.copy()
|
|
289
|
+
return False
|
|
291
290
|
|
|
292
291
|
replacement_map[target_addr] = new_target.addr
|
|
293
292
|
self.write_graph.add_edge(orig_pred, new_target)
|
|
@@ -316,7 +315,9 @@ class DuplicationReverter(StructuringOptimizationPass):
|
|
|
316
315
|
break
|
|
317
316
|
|
|
318
317
|
if new_succ is None:
|
|
319
|
-
|
|
318
|
+
_l.debug("Unable to find the successor for block with no jump or condition!")
|
|
319
|
+
self.write_graph = self.read_graph.copy()
|
|
320
|
+
return False
|
|
320
321
|
|
|
321
322
|
self.write_graph.add_edge(orig_pred, new_succ)
|
|
322
323
|
|
|
@@ -8,8 +8,8 @@ from ailment import Const
|
|
|
8
8
|
from ailment.block import Block
|
|
9
9
|
from ailment.statement import Statement, ConditionalJump, Jump
|
|
10
10
|
|
|
11
|
-
from .errors import UnsupportedAILNodeError
|
|
12
11
|
from angr.analyses.decompiler.structuring.structurer_nodes import IncompleteSwitchCaseHeadStatement
|
|
12
|
+
from .errors import UnsupportedAILNodeError
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
_l = logging.getLogger(name=__name__)
|
|
@@ -47,8 +47,6 @@ def replace_node_in_graph(graph: nx.DiGraph, node, replace_with):
|
|
|
47
47
|
else:
|
|
48
48
|
graph.add_edge(replace_with, dst)
|
|
49
49
|
|
|
50
|
-
assert node not in graph
|
|
51
|
-
|
|
52
50
|
|
|
53
51
|
def bfs_list_blocks(start_block: Block, graph: nx.DiGraph):
|
|
54
52
|
blocks = []
|