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
|
@@ -3,16 +3,18 @@ from __future__ import annotations
|
|
|
3
3
|
from itertools import chain
|
|
4
4
|
from collections.abc import Iterable
|
|
5
5
|
import logging
|
|
6
|
+
from typing import cast
|
|
6
7
|
|
|
7
|
-
import
|
|
8
|
+
from archinfo.types import RegisterOffset
|
|
8
9
|
import claripy
|
|
9
10
|
import ailment
|
|
10
11
|
from claripy import FSORT_DOUBLE, FSORT_FLOAT
|
|
11
12
|
|
|
12
|
-
from angr.engines.light import
|
|
13
|
+
from angr.engines.light import SpOffset
|
|
14
|
+
from angr.engines.light.engine import SimEngineNostmtAIL
|
|
13
15
|
from angr.errors import SimEngineError, SimMemoryMissingError
|
|
14
16
|
from angr.calling_conventions import default_cc, SimRegArg, SimTypeBottom
|
|
15
|
-
from angr.storage.memory_mixins.paged_memory.pages.multi_values import MultiValues
|
|
17
|
+
from angr.storage.memory_mixins.paged_memory.pages.multi_values import MultiValues, mv_is_bv
|
|
16
18
|
from angr.knowledge_plugins.key_definitions.atoms import Atom, Register, Tmp, MemoryLocation
|
|
17
19
|
from angr.knowledge_plugins.key_definitions.constants import OP_BEFORE, OP_AFTER
|
|
18
20
|
from angr.knowledge_plugins.key_definitions.live_definitions import Definition, LiveDefinitions
|
|
@@ -25,22 +27,19 @@ l = logging.getLogger(name=__name__)
|
|
|
25
27
|
|
|
26
28
|
|
|
27
29
|
class SimEngineRDAIL(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
state: ReachingDefinitionsState
|
|
33
|
-
|
|
30
|
+
SimEngineNostmtAIL[
|
|
31
|
+
ReachingDefinitionsState, MultiValues[claripy.ast.BV | claripy.ast.FP], None, ReachingDefinitionsState
|
|
32
|
+
]
|
|
33
|
+
):
|
|
34
34
|
def __init__(
|
|
35
35
|
self,
|
|
36
36
|
project,
|
|
37
|
-
function_handler: FunctionHandler
|
|
37
|
+
function_handler: FunctionHandler,
|
|
38
38
|
stack_pointer_tracker=None,
|
|
39
39
|
use_callee_saved_regs_at_return=True,
|
|
40
40
|
bp_as_gpr: bool = False,
|
|
41
41
|
):
|
|
42
|
-
super().__init__()
|
|
43
|
-
self.project = project
|
|
42
|
+
super().__init__(project)
|
|
44
43
|
self._function_handler = function_handler
|
|
45
44
|
self._visited_blocks = None
|
|
46
45
|
self._dep_graph = None
|
|
@@ -48,54 +47,53 @@ class SimEngineRDAIL(
|
|
|
48
47
|
self._use_callee_saved_regs_at_return = use_callee_saved_regs_at_return
|
|
49
48
|
self.bp_as_gpr = bp_as_gpr
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
self
|
|
63
|
-
|
|
64
|
-
ailment.Expr.Tmp: self._ail_handle_Tmp,
|
|
65
|
-
ailment.Stmt.Call: self._ail_handle_CallExpr,
|
|
66
|
-
ailment.Expr.Register: self._ail_handle_Register,
|
|
67
|
-
ailment.Expr.Load: self._ail_handle_Load,
|
|
68
|
-
ailment.Expr.Convert: self._ail_handle_Convert,
|
|
69
|
-
ailment.Expr.Reinterpret: self._ail_handle_Reinterpret,
|
|
70
|
-
ailment.Expr.ITE: self._ail_handle_ITE,
|
|
71
|
-
ailment.Expr.UnaryOp: self._ail_handle_UnaryOp,
|
|
72
|
-
ailment.Expr.BinaryOp: self._ail_handle_BinaryOp,
|
|
73
|
-
ailment.Expr.Const: self._ail_handle_Const,
|
|
74
|
-
ailment.Expr.StackBaseOffset: self._ail_handle_StackBaseOffset,
|
|
75
|
-
ailment.Expr.DirtyExpression: self._ail_handle_DirtyExpression,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
def process(self, state, *args, dep_graph=None, visited_blocks=None, block=None, fail_fast=False, **kwargs):
|
|
50
|
+
def _is_top(self, expr):
|
|
51
|
+
"""
|
|
52
|
+
MultiValues are not really "top" in the stricter sense. They are just a collection of values,
|
|
53
|
+
some of which might be top
|
|
54
|
+
"""
|
|
55
|
+
return False
|
|
56
|
+
|
|
57
|
+
def _top(self, bits) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
58
|
+
return MultiValues(self.state.top(bits))
|
|
59
|
+
|
|
60
|
+
def process(
|
|
61
|
+
self, state, *, dep_graph=None, visited_blocks=None, block=None, fail_fast=False, whitelist=None, **kwargs
|
|
62
|
+
):
|
|
79
63
|
self._dep_graph = dep_graph
|
|
80
64
|
self._visited_blocks = visited_blocks
|
|
81
65
|
|
|
82
|
-
# we are using a completely different state. Therefore, we directly call our _process() method before
|
|
83
|
-
# SimEngine becomes flexible enough.
|
|
84
66
|
try:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
None,
|
|
88
|
-
block=block,
|
|
89
|
-
)
|
|
90
|
-
except SimEngineError as e:
|
|
67
|
+
result_state = super().process(state, whitelist=whitelist, block=block)
|
|
68
|
+
except SimEngineError:
|
|
91
69
|
if fail_fast is True:
|
|
92
|
-
raise
|
|
70
|
+
raise
|
|
71
|
+
result_state = state
|
|
72
|
+
return result_state
|
|
73
|
+
|
|
74
|
+
def _process_block_end(self, block, stmt_data, whitelist):
|
|
93
75
|
return self.state
|
|
94
76
|
|
|
95
77
|
#
|
|
96
78
|
# Private methods
|
|
97
79
|
#
|
|
98
80
|
|
|
81
|
+
def _expr_bv(self, expr: ailment.expression.Expression) -> MultiValues[claripy.ast.BV]:
|
|
82
|
+
result = self._expr(expr)
|
|
83
|
+
assert mv_is_bv(result)
|
|
84
|
+
return result
|
|
85
|
+
|
|
86
|
+
def _expr_pair(
|
|
87
|
+
self, arg0: ailment.expression.Expression, arg1: ailment.expression.Expression
|
|
88
|
+
) -> (
|
|
89
|
+
tuple[MultiValues[claripy.ast.BV], MultiValues[claripy.ast.BV]]
|
|
90
|
+
| tuple[MultiValues[claripy.ast.FP], MultiValues[claripy.ast.FP]]
|
|
91
|
+
):
|
|
92
|
+
r0 = self._expr(arg0)
|
|
93
|
+
r1 = self._expr(arg1)
|
|
94
|
+
assert type(r0) is type(r1)
|
|
95
|
+
return r0, r1 # type: ignore
|
|
96
|
+
|
|
99
97
|
def _external_codeloc(self):
|
|
100
98
|
return ExternalCodeLocation(self.state.codeloc.context)
|
|
101
99
|
|
|
@@ -115,52 +113,28 @@ class SimEngineRDAIL(
|
|
|
115
113
|
# AIL statement handlers
|
|
116
114
|
#
|
|
117
115
|
|
|
118
|
-
def
|
|
119
|
-
super()._process_Stmt(whitelist=whitelist)
|
|
120
|
-
|
|
121
|
-
def _handle_Stmt(self, stmt):
|
|
116
|
+
def _stmt(self, stmt):
|
|
122
117
|
if self.state.analysis:
|
|
123
118
|
self.state.analysis.stmt_observe(self.stmt_idx, stmt, self.block, self.state, OP_BEFORE)
|
|
124
119
|
self.state.analysis.insn_observe(self.ins_addr, stmt, self.block, self.state, OP_BEFORE)
|
|
125
120
|
|
|
126
121
|
self._set_codeloc()
|
|
127
|
-
|
|
128
|
-
if handler is not None:
|
|
129
|
-
if handler is not ...:
|
|
130
|
-
handler(stmt)
|
|
131
|
-
else:
|
|
132
|
-
self.l.warning("Unsupported statement type %s.", type(stmt).__name__)
|
|
122
|
+
super()._stmt(stmt)
|
|
133
123
|
|
|
134
124
|
if self.state.analysis:
|
|
135
125
|
self.state.analysis.stmt_observe(self.stmt_idx, stmt, self.block, self.state, OP_AFTER)
|
|
136
126
|
self.state.analysis.insn_observe(self.ins_addr, stmt, self.block, self.state, OP_AFTER)
|
|
137
127
|
|
|
138
|
-
def
|
|
139
|
-
handler = self._expr_handlers.get(type(expr), None)
|
|
140
|
-
if handler is not None:
|
|
141
|
-
return handler(expr)
|
|
142
|
-
self.l.warning("Unsupported expression type %s.", type(expr).__name__)
|
|
143
|
-
return MultiValues(self.state.top(self.arch.bits))
|
|
144
|
-
|
|
145
|
-
def _ail_handle_Assignment(self, stmt):
|
|
146
|
-
"""
|
|
147
|
-
|
|
148
|
-
:param ailment.Assignment stmt:
|
|
149
|
-
:return:
|
|
150
|
-
"""
|
|
151
|
-
|
|
128
|
+
def _handle_stmt_Assignment(self, stmt):
|
|
152
129
|
src = self._expr(stmt.src)
|
|
153
130
|
dst = stmt.dst
|
|
154
131
|
|
|
155
|
-
if src is None:
|
|
156
|
-
src = MultiValues(self.state.top(dst.bits))
|
|
157
|
-
|
|
158
132
|
if isinstance(dst, ailment.Tmp):
|
|
159
133
|
self.state.kill_and_add_definition(Tmp(dst.tmp_idx, dst.size), src)
|
|
160
134
|
self.tmps[dst.tmp_idx] = src
|
|
161
135
|
|
|
162
136
|
elif isinstance(dst, ailment.Register):
|
|
163
|
-
reg = Register(dst.reg_offset, dst.size)
|
|
137
|
+
reg = Register(RegisterOffset(dst.reg_offset), dst.size)
|
|
164
138
|
self.state.kill_and_add_definition(reg, src)
|
|
165
139
|
|
|
166
140
|
if dst.reg_offset == self.arch.sp_offset:
|
|
@@ -169,9 +143,9 @@ class SimEngineRDAIL(
|
|
|
169
143
|
else:
|
|
170
144
|
l.warning("Unsupported type of Assignment dst %s.", type(dst).__name__)
|
|
171
145
|
|
|
172
|
-
def
|
|
173
|
-
data
|
|
174
|
-
addr
|
|
146
|
+
def _handle_stmt_Store(self, stmt: ailment.Stmt.Store) -> None:
|
|
147
|
+
data = self._expr(stmt.data)
|
|
148
|
+
addr = self._expr_bv(stmt.addr)
|
|
175
149
|
size: int = stmt.size
|
|
176
150
|
if stmt.guard is not None:
|
|
177
151
|
self._expr(stmt.guard)
|
|
@@ -192,20 +166,20 @@ class SimEngineRDAIL(
|
|
|
192
166
|
if memory_location is not None:
|
|
193
167
|
self.state.kill_and_add_definition(memory_location, data, endness=stmt.endness)
|
|
194
168
|
|
|
195
|
-
def
|
|
169
|
+
def _handle_stmt_Jump(self, stmt):
|
|
196
170
|
_ = self._expr(stmt.target)
|
|
197
171
|
|
|
198
|
-
def
|
|
172
|
+
def _handle_stmt_ConditionalJump(self, stmt):
|
|
199
173
|
_ = self._expr(stmt.condition) # pylint:disable=unused-variable
|
|
200
174
|
if stmt.true_target is not None:
|
|
201
175
|
_ = self._expr(stmt.true_target) # pylint:disable=unused-variable
|
|
202
176
|
if stmt.false_target is not None:
|
|
203
177
|
_ = self._expr(stmt.false_target) # pylint:disable=unused-variable
|
|
204
178
|
|
|
205
|
-
ip = Register(self.arch.ip_offset, self.arch.bytes)
|
|
179
|
+
ip = Register(cast(RegisterOffset, self.arch.ip_offset), self.arch.bytes)
|
|
206
180
|
self.state.kill_definitions(ip)
|
|
207
181
|
|
|
208
|
-
def
|
|
182
|
+
def _handle_stmt_Call(self, stmt: ailment.Stmt.Call):
|
|
209
183
|
data = self._handle_Call_base(stmt, is_expr=False)
|
|
210
184
|
src = data.ret_values
|
|
211
185
|
if src is None:
|
|
@@ -217,7 +191,9 @@ class SimEngineRDAIL(
|
|
|
217
191
|
self.tmps[dst.tmp_idx] = src
|
|
218
192
|
|
|
219
193
|
elif isinstance(dst, ailment.Register):
|
|
220
|
-
full_reg_offset, full_reg_size = self.arch.registers[
|
|
194
|
+
full_reg_offset, full_reg_size = self.arch.registers[
|
|
195
|
+
self.arch.register_names[RegisterOffset(dst.reg_offset)]
|
|
196
|
+
]
|
|
221
197
|
if dst.size != full_reg_size:
|
|
222
198
|
# we need to extend the value to overwrite the entire register
|
|
223
199
|
otv = {}
|
|
@@ -250,7 +226,7 @@ class SimEngineRDAIL(
|
|
|
250
226
|
target = stmt.target
|
|
251
227
|
func_name = None
|
|
252
228
|
|
|
253
|
-
ip = Register(self.arch.ip_offset, self.arch.bytes)
|
|
229
|
+
ip = Register(cast(RegisterOffset, self.arch.ip_offset), self.arch.bytes)
|
|
254
230
|
self.state.kill_definitions(ip)
|
|
255
231
|
|
|
256
232
|
statement = self.block.statements[self.stmt_idx]
|
|
@@ -283,14 +259,19 @@ class SimEngineRDAIL(
|
|
|
283
259
|
|
|
284
260
|
# kill all cc_ops
|
|
285
261
|
if "cc_op" in self.arch.registers:
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
262
|
+
|
|
263
|
+
def killreg(name: str):
|
|
264
|
+
offset, size = self.arch.registers[name]
|
|
265
|
+
self.state.kill_definitions(Register(offset, size))
|
|
266
|
+
|
|
267
|
+
killreg("cc_op")
|
|
268
|
+
killreg("cc_dep1")
|
|
269
|
+
killreg("cc_dep2")
|
|
270
|
+
killreg("cc_ndep")
|
|
290
271
|
|
|
291
272
|
return data
|
|
292
273
|
|
|
293
|
-
def
|
|
274
|
+
def _handle_stmt_Return(self, stmt: ailment.Stmt.Return): # pylint:disable=unused-argument
|
|
294
275
|
cc = None
|
|
295
276
|
prototype = None
|
|
296
277
|
if self.state.analysis.subject.type == SubjectType.Function:
|
|
@@ -362,39 +343,42 @@ class SimEngineRDAIL(
|
|
|
362
343
|
# We don't add sp since stack pointers are supposed to be get rid of in AIL. this is definitely a hack though
|
|
363
344
|
# self.state.add_use(Register(self.project.arch.sp_offset, self.project.arch.bits // 8))
|
|
364
345
|
|
|
365
|
-
def
|
|
346
|
+
def _handle_stmt_DirtyStatement(self, stmt: ailment.Stmt.DirtyStatement):
|
|
366
347
|
self._expr(stmt.dirty)
|
|
367
348
|
|
|
368
349
|
#
|
|
369
350
|
# AIL expression handlers
|
|
370
351
|
#
|
|
371
352
|
|
|
372
|
-
def
|
|
373
|
-
return MultiValues(expr)
|
|
374
|
-
|
|
375
|
-
def _ail_handle_Tmp(self, expr: ailment.Expr.Tmp) -> MultiValues:
|
|
353
|
+
def _handle_expr_Tmp(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
376
354
|
self.state.add_tmp_use(expr.tmp_idx)
|
|
377
355
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
356
|
+
try:
|
|
357
|
+
return self.tmps[expr.tmp_idx]
|
|
358
|
+
except KeyError:
|
|
359
|
+
return self._top(expr.bits)
|
|
382
360
|
|
|
383
|
-
def
|
|
361
|
+
def _handle_expr_Call(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
384
362
|
data = self._handle_Call_base(expr, is_expr=True)
|
|
385
363
|
result = data.ret_values
|
|
386
364
|
|
|
365
|
+
if result is None:
|
|
366
|
+
return self._top(expr.bits)
|
|
367
|
+
|
|
387
368
|
# truncate result if needed
|
|
388
|
-
if result
|
|
389
|
-
|
|
390
|
-
|
|
369
|
+
if len(result) > expr.bits:
|
|
370
|
+
assert mv_is_bv(result)
|
|
371
|
+
result = cast(
|
|
372
|
+
MultiValues[claripy.ast.BV | claripy.ast.FP],
|
|
373
|
+
result.extract((len(result) - expr.bits) // 8, expr.bits // 8, "Iend_BE"),
|
|
374
|
+
)
|
|
391
375
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
376
|
+
if data.ret_values_deps is not None:
|
|
377
|
+
for dep in data.ret_values_deps:
|
|
378
|
+
result = self.state.annotate_mv_with_def(result, dep)
|
|
395
379
|
return result
|
|
396
380
|
|
|
397
|
-
def
|
|
381
|
+
def _handle_expr_Register(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
398
382
|
self.state: ReachingDefinitionsState
|
|
399
383
|
|
|
400
384
|
reg_offset = expr.reg_offset
|
|
@@ -412,7 +396,7 @@ class SimEngineRDAIL(
|
|
|
412
396
|
if sb_offset is not None:
|
|
413
397
|
return MultiValues(v=self.state._initial_stack_pointer() + sb_offset)
|
|
414
398
|
|
|
415
|
-
reg_atom = Register(reg_offset, size)
|
|
399
|
+
reg_atom = Register(RegisterOffset(reg_offset), size)
|
|
416
400
|
|
|
417
401
|
# first check if it is ever defined
|
|
418
402
|
try:
|
|
@@ -465,12 +449,13 @@ class SimEngineRDAIL(
|
|
|
465
449
|
|
|
466
450
|
return value
|
|
467
451
|
|
|
468
|
-
def
|
|
469
|
-
addrs
|
|
452
|
+
def _handle_expr_Load(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
453
|
+
addrs = self._expr_bv(expr.addr)
|
|
470
454
|
|
|
471
455
|
size = expr.size
|
|
472
456
|
bits = expr.bits
|
|
473
457
|
if expr.guard is not None:
|
|
458
|
+
assert expr.alt is not None
|
|
474
459
|
self._expr(expr.guard)
|
|
475
460
|
self._expr(expr.alt)
|
|
476
461
|
|
|
@@ -527,7 +512,7 @@ class SimEngineRDAIL(
|
|
|
527
512
|
|
|
528
513
|
return result
|
|
529
514
|
|
|
530
|
-
def
|
|
515
|
+
def _handle_expr_Convert(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
531
516
|
to_conv: MultiValues = self._expr(expr.operand)
|
|
532
517
|
bits = expr.to_bits
|
|
533
518
|
size = bits // self.arch.byte_width
|
|
@@ -561,7 +546,7 @@ class SimEngineRDAIL(
|
|
|
561
546
|
|
|
562
547
|
return MultiValues(offset_to_values={0: converted})
|
|
563
548
|
|
|
564
|
-
def
|
|
549
|
+
def _handle_expr_Reinterpret(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
565
550
|
_: MultiValues = self._expr(expr.operand)
|
|
566
551
|
bits = expr.to_bits
|
|
567
552
|
|
|
@@ -570,78 +555,67 @@ class SimEngineRDAIL(
|
|
|
570
555
|
|
|
571
556
|
return MultiValues(reinterpreted)
|
|
572
557
|
|
|
573
|
-
def
|
|
558
|
+
def _handle_unop_Default(self, expr):
|
|
559
|
+
return self._top(expr.bits)
|
|
560
|
+
|
|
561
|
+
_handle_unop_Reference = _handle_unop_Default
|
|
562
|
+
_handle_unop_Clz = _handle_unop_Default
|
|
563
|
+
_handle_unop_Ctz = _handle_unop_Default
|
|
564
|
+
_handle_unop_Dereference = _handle_unop_Default
|
|
565
|
+
_handle_unop_GetMSBs = _handle_unop_Default
|
|
566
|
+
_handle_unop_unpack = _handle_unop_Default
|
|
567
|
+
_handle_unop_Sqrt = _handle_unop_Default
|
|
568
|
+
_handle_unop_RSqrtEst = _handle_unop_Default
|
|
569
|
+
|
|
570
|
+
def _handle_expr_ITE(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
574
571
|
_: MultiValues = self._expr(expr.cond)
|
|
575
572
|
iftrue: MultiValues = self._expr(expr.iftrue)
|
|
576
573
|
_: MultiValues = self._expr(expr.iffalse)
|
|
577
574
|
top = self.state.top(len(iftrue))
|
|
578
575
|
return MultiValues(top)
|
|
579
576
|
|
|
580
|
-
def
|
|
581
|
-
operand
|
|
577
|
+
def _handle_unop_Not(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
578
|
+
operand = self._expr_bv(expr.operand)
|
|
582
579
|
bits = expr.bits
|
|
583
580
|
|
|
584
|
-
if operand is None:
|
|
585
|
-
return MultiValues(self.state.top(bits))
|
|
586
|
-
|
|
587
581
|
operand_v = operand.one_value()
|
|
588
582
|
|
|
589
583
|
if operand_v is not None and operand_v.concrete:
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
r = MultiValues(self.state.top(bits))
|
|
593
|
-
|
|
594
|
-
return r
|
|
584
|
+
return MultiValues(~operand_v) # pylint:disable=invalid-unary-operand-type
|
|
585
|
+
return MultiValues(self.state.top(bits))
|
|
595
586
|
|
|
596
|
-
def
|
|
587
|
+
def _handle_unop_Neg(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
597
588
|
operand: MultiValues = self._expr(expr.operand)
|
|
598
589
|
bits = expr.bits
|
|
599
590
|
|
|
600
|
-
if operand is None:
|
|
601
|
-
return MultiValues(self.state.top(bits))
|
|
602
|
-
|
|
603
591
|
operand_v = operand.one_value()
|
|
604
592
|
|
|
605
593
|
if operand_v is not None and operand_v.concrete:
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
r = MultiValues(self.state.top(bits))
|
|
609
|
-
|
|
610
|
-
return r
|
|
594
|
+
return MultiValues(-operand_v) # pylint:disable=invalid-unary-operand-type
|
|
595
|
+
return MultiValues(self.state.top(bits))
|
|
611
596
|
|
|
612
|
-
def
|
|
613
|
-
operand
|
|
597
|
+
def _handle_unop_BitwiseNeg(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
598
|
+
operand = self._expr_bv(expr.operand)
|
|
614
599
|
bits = expr.bits
|
|
615
600
|
|
|
616
|
-
r = None
|
|
617
601
|
operand_v = operand.one_value()
|
|
618
602
|
|
|
619
603
|
if operand_v is not None and operand_v.concrete:
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
r = MultiValues(offset_to_values={0: {self.state.top(bits)}})
|
|
604
|
+
return MultiValues(offset_to_values={0: {~operand_v}})
|
|
605
|
+
return MultiValues(offset_to_values={0: {self.state.top(bits)}})
|
|
623
606
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
def _ail_handle_BinaryOp(self, expr: ailment.Expr.BinaryOp) -> MultiValues:
|
|
627
|
-
r = super()._ail_handle_BinaryOp(expr)
|
|
628
|
-
if isinstance(r, ailment.Expr.BinaryOp):
|
|
629
|
-
l.warning("Unimplemented operation %s.", expr.op)
|
|
630
|
-
top = self.state.top(expr.bits)
|
|
631
|
-
return MultiValues(top)
|
|
632
|
-
return r
|
|
633
|
-
|
|
634
|
-
def _ail_handle_Add(self, expr: ailment.Expr.BinaryOp) -> MultiValues:
|
|
635
|
-
expr0: MultiValues = self._expr(expr.operands[0])
|
|
636
|
-
expr1: MultiValues = self._expr(expr.operands[1])
|
|
607
|
+
def _handle_binop_Add(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
608
|
+
expr0, expr1 = self._expr_pair(expr.operands[0], expr.operands[1])
|
|
637
609
|
bits = expr.bits
|
|
638
610
|
|
|
639
|
-
r = None
|
|
611
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
640
612
|
expr0_v = expr0.one_value()
|
|
641
613
|
expr1_v = expr1.one_value()
|
|
642
614
|
|
|
643
|
-
if expr0_v is None and expr1_v is None:
|
|
644
|
-
|
|
615
|
+
if expr0_v is not None and expr1_v is not None:
|
|
616
|
+
# adding two single values together
|
|
617
|
+
if (expr0_v.concrete or self.state.is_stack_address(expr0_v)) and expr1_v.concrete:
|
|
618
|
+
r = MultiValues(expr0_v + expr1_v) # type: ignore
|
|
645
619
|
elif expr0_v is None and expr1_v is not None:
|
|
646
620
|
# adding a single value to a multivalue
|
|
647
621
|
if (
|
|
@@ -649,34 +623,32 @@ class SimEngineRDAIL(
|
|
|
649
623
|
and 0 in expr0
|
|
650
624
|
and all(v.concrete or self.state.is_stack_address(v) for v in expr0[0])
|
|
651
625
|
):
|
|
652
|
-
vs = {v + expr1_v for v in expr0[0]}
|
|
626
|
+
vs = {v + expr1_v for v in expr0[0]} # type: ignore
|
|
653
627
|
r = MultiValues(offset_to_values={0: vs})
|
|
654
628
|
elif expr0_v is not None and expr1_v is None:
|
|
655
629
|
# adding a single value to a multivalue
|
|
656
630
|
if expr1.count() == 1 and 0 in expr1 and all(v.concrete for v in expr1[0]):
|
|
657
|
-
vs = {v + expr0_v for v in expr1[0]}
|
|
631
|
+
vs = {v + expr0_v for v in expr1[0]} # type: ignore
|
|
658
632
|
r = MultiValues(offset_to_values={0: vs})
|
|
659
633
|
else:
|
|
660
|
-
|
|
661
|
-
if (expr0_v.concrete or self.state.is_stack_address(expr0_v)) and expr1_v.concrete:
|
|
662
|
-
r = MultiValues(expr0_v + expr1_v)
|
|
634
|
+
r = MultiValues(self.state.top(bits))
|
|
663
635
|
|
|
664
636
|
if r is None:
|
|
665
637
|
r = MultiValues(self.state.top(bits))
|
|
666
638
|
|
|
667
639
|
return r
|
|
668
640
|
|
|
669
|
-
def
|
|
670
|
-
expr0
|
|
671
|
-
expr1: MultiValues = self._expr(expr.operands[1])
|
|
641
|
+
def _handle_binop_Sub(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
642
|
+
expr0, expr1 = self._expr_pair(expr.operands[0], expr.operands[1])
|
|
672
643
|
bits = expr.bits
|
|
673
644
|
|
|
674
|
-
r = None
|
|
645
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
675
646
|
expr0_v = expr0.one_value()
|
|
676
647
|
expr1_v = expr1.one_value()
|
|
677
648
|
|
|
678
|
-
if expr0_v is None and expr1_v is None:
|
|
679
|
-
|
|
649
|
+
if expr0_v is not None and expr1_v is not None:
|
|
650
|
+
if (expr0_v.concrete or self.state.is_stack_address(expr0_v)) and expr1_v.concrete:
|
|
651
|
+
r = MultiValues(expr0_v - expr1_v) # type: ignore
|
|
680
652
|
elif expr0_v is None and expr1_v is not None:
|
|
681
653
|
# subtracting a single value from a multivalue
|
|
682
654
|
if (
|
|
@@ -684,35 +656,22 @@ class SimEngineRDAIL(
|
|
|
684
656
|
and 0 in expr0
|
|
685
657
|
and all(v.concrete or self.state.is_stack_address(v) for v in expr0[0])
|
|
686
658
|
):
|
|
687
|
-
vs = {v - expr1_v for v in expr0[0]}
|
|
659
|
+
vs = {v - expr1_v for v in expr0[0]} # type: ignore
|
|
688
660
|
r = MultiValues(offset_to_values={0: vs})
|
|
689
661
|
elif expr0_v is not None and expr1_v is None:
|
|
690
662
|
# subtracting a single value from a multivalue
|
|
691
663
|
if expr1.count() == 1 and 0 in expr1 and all(v.concrete for v in expr1[0]):
|
|
692
|
-
vs = {expr0_v - v for v in expr1[0]}
|
|
664
|
+
vs = {expr0_v - v for v in expr1[0]} # type: ignore
|
|
693
665
|
r = MultiValues(offset_to_values={0: vs})
|
|
694
666
|
else:
|
|
695
|
-
|
|
696
|
-
r = MultiValues(expr0_v - expr1_v)
|
|
667
|
+
r = MultiValues(self.state.top(bits))
|
|
697
668
|
|
|
698
669
|
if r is None:
|
|
699
670
|
r = MultiValues(self.state.top(bits))
|
|
700
671
|
|
|
701
672
|
return r
|
|
702
673
|
|
|
703
|
-
def
|
|
704
|
-
arg0, arg1 = expr.operands
|
|
705
|
-
|
|
706
|
-
self._expr(arg0)
|
|
707
|
-
self._expr(arg1)
|
|
708
|
-
bits = expr.bits
|
|
709
|
-
|
|
710
|
-
return MultiValues(self.state.top(bits))
|
|
711
|
-
|
|
712
|
-
def _ail_handle_DivMod(self, expr):
|
|
713
|
-
return self._ail_handle_Div(expr)
|
|
714
|
-
|
|
715
|
-
def _ail_handle_Mul(self, expr):
|
|
674
|
+
def _handle_binop_Default(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
716
675
|
arg0, arg1 = expr.operands
|
|
717
676
|
|
|
718
677
|
self._expr(arg0)
|
|
@@ -721,53 +680,88 @@ class SimEngineRDAIL(
|
|
|
721
680
|
|
|
722
681
|
return MultiValues(self.state.top(bits))
|
|
723
682
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
683
|
+
_handle_binop_AddV = _handle_binop_Add
|
|
684
|
+
_handle_binop_Div = _handle_binop_Default
|
|
685
|
+
_handle_binop_MulV = _handle_binop_Default
|
|
686
|
+
_handle_binop_MulHiV = _handle_binop_Default
|
|
687
|
+
_handle_binop_Mod = _handle_binop_Default
|
|
688
|
+
_handle_binop_AddF = _handle_binop_Default
|
|
689
|
+
_handle_binop_DivF = _handle_binop_Default
|
|
690
|
+
_handle_binop_DivV = _handle_binop_Default
|
|
691
|
+
_handle_binop_MulF = _handle_binop_Default
|
|
692
|
+
_handle_binop_SubF = _handle_binop_Default
|
|
693
|
+
_handle_binop_SubV = _handle_binop_Default
|
|
694
|
+
_handle_binop_InterleaveLOV = _handle_binop_Default
|
|
695
|
+
_handle_binop_InterleaveHIV = _handle_binop_Default
|
|
696
|
+
_handle_binop_CasCmpEQ = _handle_binop_Default
|
|
697
|
+
_handle_binop_CasCmpNE = _handle_binop_Default
|
|
698
|
+
_handle_binop_ExpCmpNE = _handle_binop_Default
|
|
699
|
+
_handle_binop_SarNV = _handle_binop_Default
|
|
700
|
+
_handle_binop_ShrNV = _handle_binop_Default
|
|
701
|
+
_handle_binop_ShlNV = _handle_binop_Default
|
|
702
|
+
_handle_binop_CmpEQV = _handle_binop_Default
|
|
703
|
+
_handle_binop_CmpNEV = _handle_binop_Default
|
|
704
|
+
_handle_binop_CmpGEV = _handle_binop_Default
|
|
705
|
+
_handle_binop_CmpGTV = _handle_binop_Default
|
|
706
|
+
_handle_binop_CmpLEV = _handle_binop_Default
|
|
707
|
+
_handle_binop_CmpLTV = _handle_binop_Default
|
|
708
|
+
_handle_binop_MinV = _handle_binop_Default
|
|
709
|
+
_handle_binop_MaxV = _handle_binop_Default
|
|
710
|
+
_handle_binop_QAddV = _handle_binop_Default
|
|
711
|
+
_handle_binop_QNarrowBinV = _handle_binop_Default
|
|
712
|
+
_handle_binop_PermV = _handle_binop_Default
|
|
713
|
+
_handle_binop_Set = _handle_binop_Default
|
|
714
|
+
|
|
715
|
+
def _handle_binop_Mul(self, expr):
|
|
716
|
+
expr0 = self._expr(expr.operands[0])
|
|
717
|
+
expr1 = self._expr(expr.operands[1])
|
|
732
718
|
bits = expr.bits
|
|
733
719
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
def _ail_handle_Mod(self, expr):
|
|
737
|
-
arg0, arg1 = expr.operands
|
|
720
|
+
expr0_v = expr0.one_value()
|
|
721
|
+
expr1_v = expr1.one_value()
|
|
738
722
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
723
|
+
if expr0_v is not None and expr1_v is not None and expr0_v.concrete and expr1_v.concrete:
|
|
724
|
+
r = MultiValues(offset_to_values={0: {expr0_v * expr1_v}}) # type: ignore
|
|
725
|
+
else:
|
|
726
|
+
r = MultiValues(offset_to_values={0: {self.state.top(bits)}})
|
|
742
727
|
|
|
743
|
-
return
|
|
728
|
+
return r
|
|
744
729
|
|
|
745
|
-
def
|
|
746
|
-
expr0
|
|
747
|
-
expr1
|
|
730
|
+
def _handle_binop_Mull(self, expr):
|
|
731
|
+
expr0 = self._expr(expr.operands[0])
|
|
732
|
+
expr1 = self._expr(expr.operands[1])
|
|
748
733
|
bits = expr.bits
|
|
749
734
|
|
|
750
735
|
expr0_v = expr0.one_value()
|
|
751
736
|
expr1_v = expr1.one_value()
|
|
752
737
|
|
|
753
738
|
if expr0_v is not None and expr1_v is not None and expr0_v.concrete and expr1_v.concrete:
|
|
754
|
-
|
|
739
|
+
xt = expr.bits // 2
|
|
740
|
+
if expr.signed:
|
|
741
|
+
r = MultiValues(
|
|
742
|
+
offset_to_values={0: {expr0_v.sign_extend(xt) * expr1_v.sign_extend(xt)}} # type: ignore
|
|
743
|
+
)
|
|
744
|
+
else:
|
|
745
|
+
r = MultiValues(
|
|
746
|
+
offset_to_values={0: {expr0_v.zero_extend(xt) * expr1_v.zero_extend(xt)}} # type: ignore
|
|
747
|
+
)
|
|
755
748
|
else:
|
|
756
749
|
r = MultiValues(offset_to_values={0: {self.state.top(bits)}})
|
|
757
750
|
|
|
758
751
|
return r
|
|
759
752
|
|
|
760
|
-
def
|
|
761
|
-
expr0
|
|
762
|
-
expr1
|
|
753
|
+
def _handle_binop_Shr(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
754
|
+
expr0 = self._expr_bv(expr.operands[0])
|
|
755
|
+
expr1 = self._expr_bv(expr.operands[1])
|
|
763
756
|
bits = expr.bits
|
|
764
757
|
|
|
765
|
-
r = None
|
|
758
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
766
759
|
expr0_v = expr0.one_value()
|
|
767
760
|
expr1_v = expr1.one_value()
|
|
768
761
|
|
|
769
|
-
if expr0_v is None and expr1_v is None:
|
|
770
|
-
|
|
762
|
+
if expr0_v is not None and expr1_v is not None:
|
|
763
|
+
if expr0_v.concrete and expr1_v.concrete:
|
|
764
|
+
r = MultiValues(claripy.LShR(expr0_v, expr1_v.concrete_value))
|
|
771
765
|
elif expr0_v is None and expr1_v is not None:
|
|
772
766
|
# each value in expr0 >> expr1_v
|
|
773
767
|
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]) and expr1_v.concrete:
|
|
@@ -783,25 +777,25 @@ class SimEngineRDAIL(
|
|
|
783
777
|
}
|
|
784
778
|
r = MultiValues(offset_to_values={0: vs})
|
|
785
779
|
else:
|
|
786
|
-
|
|
787
|
-
r = MultiValues(claripy.LShR(expr0_v, expr1_v.concrete_value))
|
|
780
|
+
r = MultiValues(self.state.top(bits))
|
|
788
781
|
|
|
789
782
|
if r is None:
|
|
790
783
|
r = MultiValues(self.state.top(bits))
|
|
791
784
|
|
|
792
785
|
return r
|
|
793
786
|
|
|
794
|
-
def
|
|
795
|
-
expr0
|
|
796
|
-
expr1
|
|
787
|
+
def _handle_binop_Sar(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
788
|
+
expr0 = self._expr_bv(expr.operands[0])
|
|
789
|
+
expr1 = self._expr_bv(expr.operands[1])
|
|
797
790
|
bits = expr.bits
|
|
798
791
|
|
|
799
|
-
r = None
|
|
792
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
800
793
|
expr0_v = expr0.one_value()
|
|
801
794
|
expr1_v = expr1.one_value()
|
|
802
795
|
|
|
803
|
-
if expr0_v is None and expr1_v is None:
|
|
804
|
-
|
|
796
|
+
if expr0_v is not None and expr1_v is not None:
|
|
797
|
+
if expr0_v.concrete and expr1_v.concrete:
|
|
798
|
+
r = MultiValues(expr0_v >> expr1_v.concrete_value)
|
|
805
799
|
elif expr0_v is None and expr1_v is not None:
|
|
806
800
|
# each value in expr0 >> expr1_v
|
|
807
801
|
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]) and expr1_v.concrete:
|
|
@@ -817,25 +811,25 @@ class SimEngineRDAIL(
|
|
|
817
811
|
}
|
|
818
812
|
r = MultiValues(offset_to_values={0: vs})
|
|
819
813
|
else:
|
|
820
|
-
|
|
821
|
-
r = MultiValues(expr0_v >> expr1_v.concrete_value)
|
|
814
|
+
r = MultiValues(self.state.top(bits))
|
|
822
815
|
|
|
823
816
|
if r is None:
|
|
824
817
|
r = MultiValues(self.state.top(bits))
|
|
825
818
|
|
|
826
819
|
return r
|
|
827
820
|
|
|
828
|
-
def
|
|
829
|
-
expr0
|
|
830
|
-
expr1
|
|
821
|
+
def _handle_binop_Shl(self, expr):
|
|
822
|
+
expr0 = self._expr_bv(expr.operands[0])
|
|
823
|
+
expr1 = self._expr_bv(expr.operands[1])
|
|
831
824
|
bits = expr.bits
|
|
832
825
|
|
|
833
|
-
r = None
|
|
826
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
834
827
|
expr0_v = expr0.one_value()
|
|
835
828
|
expr1_v = expr1.one_value()
|
|
836
829
|
|
|
837
|
-
if expr0_v is None and expr1_v is None:
|
|
838
|
-
|
|
830
|
+
if expr0_v is not None and expr1_v is not None:
|
|
831
|
+
if expr0_v.concrete and expr1_v.concrete:
|
|
832
|
+
r = MultiValues(expr0_v << expr1_v.concrete_value)
|
|
839
833
|
elif expr0_v is None and expr1_v is not None:
|
|
840
834
|
# each value in expr0 << expr1_v
|
|
841
835
|
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]) and expr1_v.concrete:
|
|
@@ -847,74 +841,60 @@ class SimEngineRDAIL(
|
|
|
847
841
|
vs = {((expr0_v << v.concrete_value) if v.concrete else self.state.top(bits)) for v in expr1[0]}
|
|
848
842
|
r = MultiValues(offset_to_values={0: vs})
|
|
849
843
|
else:
|
|
850
|
-
|
|
851
|
-
r = MultiValues(expr0_v << expr1_v.concrete_value)
|
|
844
|
+
r = MultiValues(self.state.top(bits))
|
|
852
845
|
|
|
853
846
|
if r is None:
|
|
854
847
|
r = MultiValues(self.state.top(bits))
|
|
855
848
|
|
|
856
849
|
return r
|
|
857
850
|
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
self._expr(expr.operands[1])
|
|
861
|
-
bits = expr.bits
|
|
862
|
-
|
|
863
|
-
return MultiValues(self.state.top(bits))
|
|
864
|
-
|
|
865
|
-
def _ail_handle_Ror(self, expr: ailment.Expr.BinaryOp) -> MultiValues:
|
|
866
|
-
self._expr(expr.operands[0])
|
|
867
|
-
self._expr(expr.operands[1])
|
|
868
|
-
bits = expr.bits
|
|
869
|
-
|
|
870
|
-
return MultiValues(self.state.top(bits))
|
|
851
|
+
_handle_binop_Rol = _handle_binop_Default
|
|
852
|
+
_handle_binop_Ror = _handle_binop_Default
|
|
871
853
|
|
|
872
|
-
def
|
|
873
|
-
expr0
|
|
874
|
-
expr1
|
|
854
|
+
def _handle_binop_And(self, expr):
|
|
855
|
+
expr0 = self._expr_bv(expr.operands[0])
|
|
856
|
+
expr1 = self._expr_bv(expr.operands[1])
|
|
875
857
|
bits = expr.bits
|
|
876
858
|
|
|
877
|
-
r = None
|
|
859
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
878
860
|
expr0_v = expr0.one_value()
|
|
879
861
|
expr1_v = expr1.one_value()
|
|
880
862
|
|
|
881
|
-
if expr0_v is None and expr1_v is None:
|
|
882
|
-
return MultiValues(self.state.top(bits))
|
|
883
|
-
|
|
884
|
-
if expr0_v is None and expr1_v is not None:
|
|
885
|
-
# expr1_v & each value in expr0
|
|
886
|
-
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]):
|
|
887
|
-
vs = {v & expr1_v for v in expr0[0]}
|
|
888
|
-
r = MultiValues(offset_to_values={0: vs})
|
|
889
|
-
elif expr0_v is not None and expr1_v is None:
|
|
890
|
-
# expr0_v & each value in expr1
|
|
891
|
-
if expr1.count() == 1 and 0 in expr1 and all(v.concrete for v in expr1[0]):
|
|
892
|
-
vs = {expr0_v & v for v in expr1[0]}
|
|
893
|
-
r = MultiValues(offset_to_values={0: vs})
|
|
894
|
-
else:
|
|
863
|
+
if expr0_v is not None and expr1_v is not None:
|
|
895
864
|
# special handling for stack alignment
|
|
896
865
|
if self.state.is_stack_address(expr0_v):
|
|
897
866
|
r = MultiValues(expr0_v)
|
|
898
867
|
else:
|
|
899
868
|
if expr0_v.concrete and expr1_v.concrete:
|
|
900
869
|
r = MultiValues(expr0_v & expr1_v)
|
|
870
|
+
elif expr0_v is None and expr1_v is not None:
|
|
871
|
+
# expr1_v & each value in expr0
|
|
872
|
+
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]):
|
|
873
|
+
r = MultiValues(offset_to_values={0: {v & expr1_v for v in expr0[0]}})
|
|
874
|
+
elif expr0_v is not None and expr1_v is None:
|
|
875
|
+
# expr0_v & each value in expr1
|
|
876
|
+
if expr1.count() == 1 and 0 in expr1 and all(v.concrete for v in expr1[0]):
|
|
877
|
+
r = MultiValues(offset_to_values={0: {expr0_v & v for v in expr1[0]}})
|
|
878
|
+
else:
|
|
879
|
+
r = MultiValues(self.state.top(bits))
|
|
901
880
|
|
|
902
881
|
if r is None:
|
|
903
882
|
r = MultiValues(self.state.top(bits))
|
|
904
883
|
|
|
905
884
|
return r
|
|
906
885
|
|
|
907
|
-
def
|
|
886
|
+
def _handle_binop_Or(self, expr):
|
|
908
887
|
expr0: MultiValues = self._expr(expr.operands[0])
|
|
909
888
|
expr1: MultiValues = self._expr(expr.operands[1])
|
|
910
889
|
bits = expr.bits
|
|
911
890
|
|
|
912
|
-
r = None
|
|
891
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
913
892
|
expr0_v = expr0.one_value()
|
|
914
893
|
expr1_v = expr1.one_value()
|
|
915
894
|
|
|
916
|
-
if expr0_v is None and expr1_v is None:
|
|
917
|
-
|
|
895
|
+
if expr0_v is not None and expr1_v is not None:
|
|
896
|
+
if expr0_v.concrete and expr1_v.concrete:
|
|
897
|
+
r = MultiValues(expr0_v | expr1_v)
|
|
918
898
|
elif expr0_v is None and expr1_v is not None:
|
|
919
899
|
# expr1_v | each value in expr0
|
|
920
900
|
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]):
|
|
@@ -926,15 +906,14 @@ class SimEngineRDAIL(
|
|
|
926
906
|
vs = {expr0_v | v for v in expr1[0]}
|
|
927
907
|
r = MultiValues(offset_to_values={0: vs})
|
|
928
908
|
else:
|
|
929
|
-
|
|
930
|
-
r = MultiValues(expr0_v | expr1_v)
|
|
909
|
+
r = MultiValues(self.state.top(bits))
|
|
931
910
|
|
|
932
911
|
if r is None:
|
|
933
912
|
r = MultiValues(self.state.top(bits))
|
|
934
913
|
|
|
935
914
|
return r
|
|
936
915
|
|
|
937
|
-
def
|
|
916
|
+
def _handle_binop_LogicalAnd(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
938
917
|
expr0: MultiValues = self._expr(expr.operands[0])
|
|
939
918
|
expr1: MultiValues = self._expr(expr.operands[1])
|
|
940
919
|
bits = expr.bits
|
|
@@ -949,7 +928,7 @@ class SimEngineRDAIL(
|
|
|
949
928
|
|
|
950
929
|
return MultiValues(claripy.If(expr0_v == 0, expr0_v, expr1_v))
|
|
951
930
|
|
|
952
|
-
def
|
|
931
|
+
def _handle_binop_LogicalOr(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
953
932
|
expr0: MultiValues = self._expr(expr.operands[0])
|
|
954
933
|
expr1: MultiValues = self._expr(expr.operands[1])
|
|
955
934
|
bits = expr.bits
|
|
@@ -962,7 +941,7 @@ class SimEngineRDAIL(
|
|
|
962
941
|
|
|
963
942
|
return MultiValues(claripy.If(expr0_v != 0, expr0_v, expr1_v))
|
|
964
943
|
|
|
965
|
-
def
|
|
944
|
+
def _handle_binop_LogicalXor(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
966
945
|
expr0: MultiValues = self._expr(expr.operands[0])
|
|
967
946
|
expr1: MultiValues = self._expr(expr.operands[1])
|
|
968
947
|
bits = expr.bits
|
|
@@ -975,17 +954,18 @@ class SimEngineRDAIL(
|
|
|
975
954
|
|
|
976
955
|
return MultiValues(claripy.If(expr0_v != 0, expr1_v, expr0_v))
|
|
977
956
|
|
|
978
|
-
def
|
|
957
|
+
def _handle_binop_Xor(self, expr):
|
|
979
958
|
expr0: MultiValues = self._expr(expr.operands[0])
|
|
980
959
|
expr1: MultiValues = self._expr(expr.operands[1])
|
|
981
960
|
bits = expr.bits
|
|
982
961
|
|
|
983
|
-
r = None
|
|
962
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
984
963
|
expr0_v = expr0.one_value()
|
|
985
964
|
expr1_v = expr1.one_value()
|
|
986
965
|
|
|
987
|
-
if expr0_v is None and expr1_v is None:
|
|
988
|
-
|
|
966
|
+
if expr0_v is not None and expr1_v is not None:
|
|
967
|
+
if expr0_v.concrete and expr1_v.concrete:
|
|
968
|
+
r = MultiValues(expr0_v ^ expr1_v)
|
|
989
969
|
elif expr0_v is None and expr1_v is not None:
|
|
990
970
|
# expr1_v ^ each value in expr0
|
|
991
971
|
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]):
|
|
@@ -997,63 +977,60 @@ class SimEngineRDAIL(
|
|
|
997
977
|
vs = {expr0_v ^ v for v in expr1[0]}
|
|
998
978
|
r = MultiValues(offset_to_values={0: vs})
|
|
999
979
|
else:
|
|
1000
|
-
|
|
1001
|
-
r = MultiValues(expr0_v ^ expr1_v)
|
|
980
|
+
r = MultiValues(self.state.top(bits))
|
|
1002
981
|
|
|
1003
982
|
if r is None:
|
|
1004
983
|
r = MultiValues(self.state.top(bits))
|
|
1005
984
|
|
|
1006
985
|
return r
|
|
1007
986
|
|
|
1008
|
-
def
|
|
987
|
+
def _handle_binop_Carry(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1009
988
|
_ = self._expr(expr.operands[0])
|
|
1010
989
|
_ = self._expr(expr.operands[1])
|
|
1011
990
|
bits = expr.bits
|
|
1012
991
|
return MultiValues(self.state.top(bits))
|
|
1013
992
|
|
|
1014
|
-
def
|
|
993
|
+
def _handle_binop_SCarry(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1015
994
|
_ = self._expr(expr.operands[0])
|
|
1016
995
|
_ = self._expr(expr.operands[1])
|
|
1017
996
|
bits = expr.bits
|
|
1018
997
|
return MultiValues(self.state.top(bits))
|
|
1019
998
|
|
|
1020
|
-
def
|
|
999
|
+
def _handle_binop_SBorrow(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1021
1000
|
_ = self._expr(expr.operands[0])
|
|
1022
1001
|
_ = self._expr(expr.operands[1])
|
|
1023
1002
|
bits = expr.bits
|
|
1024
1003
|
return MultiValues(self.state.top(bits))
|
|
1025
1004
|
|
|
1026
|
-
def
|
|
1027
|
-
expr0
|
|
1028
|
-
expr1
|
|
1005
|
+
def _handle_binop_Concat(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1006
|
+
expr0 = self._expr_bv(expr.operands[0])
|
|
1007
|
+
expr1 = self._expr_bv(expr.operands[1])
|
|
1029
1008
|
bits = expr.bits
|
|
1030
1009
|
|
|
1031
|
-
r = None
|
|
1010
|
+
r: MultiValues[claripy.ast.BV | claripy.ast.FP] | None = None
|
|
1032
1011
|
expr0_v = expr0.one_value()
|
|
1033
1012
|
expr1_v = expr1.one_value()
|
|
1034
1013
|
|
|
1035
|
-
if expr0_v is None and expr1_v is None:
|
|
1036
|
-
|
|
1014
|
+
if expr0_v is not None and expr1_v is not None:
|
|
1015
|
+
if expr0_v.concrete and expr1_v.concrete:
|
|
1016
|
+
r = MultiValues(claripy.Concat(expr0_v, expr1_v))
|
|
1037
1017
|
elif expr0_v is None and expr1_v is not None:
|
|
1038
1018
|
# concatenate expr1_v with each value in expr0
|
|
1039
1019
|
if expr0.count() == 1 and 0 in expr0 and all(v.concrete for v in expr0[0]):
|
|
1040
|
-
|
|
1041
|
-
r = MultiValues(offset_to_values={0: vs})
|
|
1020
|
+
r = MultiValues(offset_to_values={0: {claripy.Concat(v, expr1_v) for v in expr0[0]}})
|
|
1042
1021
|
elif expr0_v is not None and expr1_v is None:
|
|
1043
1022
|
# concatenate expr0_v with each value in expr1
|
|
1044
1023
|
if expr1.count() == 1 and 0 in expr1 and all(v.concrete for v in expr1[0]):
|
|
1045
|
-
|
|
1046
|
-
r = MultiValues(offset_to_values={0: vs})
|
|
1024
|
+
r = MultiValues(offset_to_values={0: {claripy.Concat(expr0_v, v) for v in expr1[0]}})
|
|
1047
1025
|
else:
|
|
1048
|
-
|
|
1049
|
-
r = MultiValues(claripy.Concat(expr0_v, expr1_v))
|
|
1026
|
+
r = MultiValues(self.state.top(bits))
|
|
1050
1027
|
|
|
1051
1028
|
if r is None:
|
|
1052
1029
|
r = MultiValues(self.state.top(bits))
|
|
1053
1030
|
|
|
1054
1031
|
return r
|
|
1055
1032
|
|
|
1056
|
-
def
|
|
1033
|
+
def _handle_binop_Cmp(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1057
1034
|
op0 = self._expr(expr.operands[0])
|
|
1058
1035
|
op1 = self._expr(expr.operands[1])
|
|
1059
1036
|
|
|
@@ -1065,41 +1042,30 @@ class SimEngineRDAIL(
|
|
|
1065
1042
|
top = self.state.top(expr.bits)
|
|
1066
1043
|
return MultiValues(top)
|
|
1067
1044
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
def
|
|
1082
|
-
_ = self._expr(expr.operands[0])
|
|
1083
|
-
_ = self._expr(expr.operands[1])
|
|
1084
|
-
_ = self._expr(expr.operands[2])
|
|
1085
|
-
|
|
1086
|
-
top = self.state.top(expr.bits)
|
|
1087
|
-
return MultiValues(offset_to_values={0: {top}})
|
|
1088
|
-
|
|
1089
|
-
def _ail_handle_ExpCmpNE(self, expr) -> MultiValues:
|
|
1045
|
+
_handle_binop_CmpF = _handle_binop_Cmp
|
|
1046
|
+
_handle_binop_CmpEQ = _handle_binop_Cmp
|
|
1047
|
+
_handle_binop_CmpNE = _handle_binop_Cmp
|
|
1048
|
+
_handle_binop_CmpLE = _handle_binop_Cmp
|
|
1049
|
+
_handle_binop_CmpLEs = _handle_binop_Cmp
|
|
1050
|
+
_handle_binop_CmpLT = _handle_binop_Cmp
|
|
1051
|
+
_handle_binop_CmpLTs = _handle_binop_Cmp
|
|
1052
|
+
_handle_binop_CmpGE = _handle_binop_Cmp
|
|
1053
|
+
_handle_binop_CmpGEs = _handle_binop_Cmp
|
|
1054
|
+
_handle_binop_CmpGT = _handle_binop_Cmp
|
|
1055
|
+
_handle_binop_CmpGTs = _handle_binop_Cmp
|
|
1056
|
+
_handle_binop_CmpORD = _handle_binop_Cmp
|
|
1057
|
+
|
|
1058
|
+
def _handle_binop_ExpCmpNE(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1090
1059
|
self._expr(expr.operands[0])
|
|
1091
1060
|
self._expr(expr.operands[1])
|
|
1092
1061
|
|
|
1093
|
-
|
|
1094
|
-
return MultiValues(offset_to_values={0: {top}})
|
|
1062
|
+
return MultiValues(self.state.top(expr.bits))
|
|
1095
1063
|
|
|
1096
|
-
def
|
|
1064
|
+
def _handle_unop_Clz(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1097
1065
|
self._expr(expr.operand)
|
|
1066
|
+
return MultiValues(self.state.top(expr.bits))
|
|
1098
1067
|
|
|
1099
|
-
|
|
1100
|
-
return MultiValues(offset_to_values={0: {top}})
|
|
1101
|
-
|
|
1102
|
-
def _ail_handle_Const(self, expr) -> MultiValues:
|
|
1068
|
+
def _handle_expr_Const(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1103
1069
|
self.state.mark_const(expr.value, expr.size)
|
|
1104
1070
|
if isinstance(expr.value, float):
|
|
1105
1071
|
sort = None
|
|
@@ -1110,7 +1076,7 @@ class SimEngineRDAIL(
|
|
|
1110
1076
|
return MultiValues(claripy.FPV(expr.value, sort))
|
|
1111
1077
|
return MultiValues(claripy.BVV(expr.value, expr.bits))
|
|
1112
1078
|
|
|
1113
|
-
def
|
|
1079
|
+
def _handle_expr_StackBaseOffset(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1114
1080
|
stack_addr = self.state.stack_address(expr.offset)
|
|
1115
1081
|
return MultiValues(stack_addr)
|
|
1116
1082
|
|
|
@@ -1121,15 +1087,24 @@ class SimEngineRDAIL(
|
|
|
1121
1087
|
top = self.state.top(expr.bits)
|
|
1122
1088
|
return MultiValues(top)
|
|
1123
1089
|
|
|
1124
|
-
def
|
|
1125
|
-
self
|
|
1126
|
-
) -> MultiValues: # pylint:disable=no-self-use
|
|
1127
|
-
for operand in expr.operands:
|
|
1128
|
-
self._expr(operand)
|
|
1090
|
+
def _handle_expr_Phi(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1091
|
+
return self._top(expr.bits) # TODO
|
|
1129
1092
|
|
|
1130
|
-
|
|
1131
|
-
return
|
|
1093
|
+
def _handle_expr_VEXCCallExpression(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1094
|
+
return self._top(expr.bits) # TODO
|
|
1132
1095
|
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1096
|
+
def _handle_expr_VirtualVariable(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1097
|
+
return self._top(expr.bits) # TODO
|
|
1098
|
+
|
|
1099
|
+
def _handle_expr_DirtyExpression(self, expr) -> MultiValues[claripy.ast.BV | claripy.ast.FP]:
|
|
1100
|
+
if isinstance(expr.dirty_expr, ailment.expression.VEXCCallExpression):
|
|
1101
|
+
for operand in expr.dirty_expr.operands:
|
|
1102
|
+
self._expr(operand)
|
|
1103
|
+
|
|
1104
|
+
return MultiValues(self.state.top(expr.bits))
|
|
1105
|
+
|
|
1106
|
+
def _handle_expr_BasePointerOffset(self, expr):
|
|
1107
|
+
return self._top(expr.bits)
|
|
1108
|
+
|
|
1109
|
+
def _handle_expr_MultiStatementExpression(self, expr):
|
|
1110
|
+
return self._top(expr.bits)
|