angr 9.2.131__py3-none-manylinux2014_aarch64.whl → 9.2.133__py3-none-manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of angr might be problematic. Click here for more details.
- 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/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 +262 -263
- 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
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
|
-
from typing import Any, TYPE_CHECKING
|
|
2
|
+
from typing import Any, TYPE_CHECKING, Generic, TypeVar, cast
|
|
3
3
|
import contextlib
|
|
4
4
|
import logging
|
|
5
5
|
|
|
6
6
|
import ailment
|
|
7
7
|
import claripy
|
|
8
8
|
|
|
9
|
+
from angr.analyses.variable_recovery.variable_recovery_base import VariableRecoveryStateBase
|
|
10
|
+
from angr.engines.light.engine import BlockType
|
|
9
11
|
from angr.storage.memory_mixins.paged_memory.pages.multi_values import MultiValues
|
|
10
12
|
from angr.engines.light import SimEngineLight, ArithmeticExpression
|
|
11
|
-
from angr.errors import
|
|
13
|
+
from angr.errors import SimMemoryMissingError
|
|
12
14
|
from angr.sim_variable import SimVariable, SimStackVariable, SimRegisterVariable, SimMemoryVariable
|
|
13
15
|
from angr.code_location import CodeLocation
|
|
14
16
|
from angr.analyses.typehoon import typevars, typeconsts
|
|
15
17
|
from angr.analyses.typehoon.typevars import TypeVariable, DerivedTypeVariable, AddN, SubN, Load, Store
|
|
16
18
|
|
|
17
19
|
if TYPE_CHECKING:
|
|
18
|
-
from .variable_recovery_base import VariableRecoveryStateBase
|
|
19
20
|
from angr.knowledge_plugins.variables.variable_manager import VariableManager
|
|
20
21
|
|
|
21
22
|
#
|
|
@@ -24,59 +25,59 @@ if TYPE_CHECKING:
|
|
|
24
25
|
|
|
25
26
|
l = logging.getLogger(name=__name__)
|
|
26
27
|
|
|
28
|
+
RichRT_co = TypeVar("RichRT_co", bound=claripy.ast.Bits, covariant=True)
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
|
|
31
|
+
class RichR(Generic[RichRT_co]):
|
|
29
32
|
"""
|
|
30
33
|
A rich representation of calculation results. The variable recovery data domain.
|
|
31
34
|
"""
|
|
32
35
|
|
|
33
36
|
__slots__ = (
|
|
34
37
|
"data",
|
|
35
|
-
"variable",
|
|
36
|
-
"typevar",
|
|
37
38
|
"type_constraints",
|
|
39
|
+
"typevar",
|
|
40
|
+
"variable",
|
|
38
41
|
)
|
|
39
42
|
|
|
40
43
|
def __init__(
|
|
41
44
|
self,
|
|
42
|
-
data:
|
|
45
|
+
data: RichRT_co,
|
|
43
46
|
variable=None,
|
|
44
|
-
typevar: typevars.TypeVariable | None = None,
|
|
45
|
-
type_constraints=None,
|
|
47
|
+
typevar: typeconsts.TypeConstant | typevars.TypeVariable | None = None,
|
|
48
|
+
type_constraints: set[typevars.TypeConstraint] | None = None,
|
|
46
49
|
):
|
|
47
|
-
self.data
|
|
50
|
+
self.data = data
|
|
48
51
|
self.variable = variable
|
|
49
52
|
self.typevar = typevar
|
|
50
53
|
self.type_constraints = type_constraints
|
|
51
54
|
|
|
52
55
|
@property
|
|
53
|
-
def bits(self):
|
|
54
|
-
|
|
55
|
-
if isinstance(self.data, claripy.ast.Base):
|
|
56
|
-
return self.data.size()
|
|
57
|
-
return self.data.bits
|
|
58
|
-
if self.variable is not None:
|
|
59
|
-
return self.variable.bits
|
|
60
|
-
return None
|
|
56
|
+
def bits(self) -> int:
|
|
57
|
+
return self.data.size()
|
|
61
58
|
|
|
62
59
|
def __repr__(self):
|
|
63
60
|
return f"R{{{self.data!r}}}"
|
|
64
61
|
|
|
65
62
|
|
|
66
|
-
|
|
63
|
+
VRStateType = TypeVar("VRStateType", bound=VariableRecoveryStateBase)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class SimEngineVRBase(
|
|
67
|
+
Generic[VRStateType, BlockType],
|
|
68
|
+
SimEngineLight[VRStateType, RichR[claripy.ast.BV | claripy.ast.FP], BlockType, None],
|
|
69
|
+
):
|
|
67
70
|
"""
|
|
68
71
|
The base class for variable recovery analyses. Contains methods for basic interactions with the state, like loading
|
|
69
72
|
and storing data.
|
|
70
73
|
"""
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
variable_manager: VariableManager
|
|
73
76
|
|
|
74
77
|
def __init__(self, project, kb):
|
|
75
|
-
super().__init__()
|
|
78
|
+
super().__init__(project)
|
|
76
79
|
|
|
77
|
-
self.project = project
|
|
78
80
|
self.kb = kb
|
|
79
|
-
self.variable_manager: VariableManager | None = None
|
|
80
81
|
self.vvar_region: dict[int, Any] = {}
|
|
81
82
|
|
|
82
83
|
@property
|
|
@@ -85,41 +86,37 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
85
86
|
return None
|
|
86
87
|
return self.state.function.addr
|
|
87
88
|
|
|
88
|
-
def process(self, state, *args, **kwargs):
|
|
89
|
+
def process(self, state, *args, **kwargs):
|
|
89
90
|
self.variable_manager = state.variable_manager
|
|
91
|
+
super().process(state, *args, **kwargs)
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
except SimEngineError as e:
|
|
94
|
-
if kwargs.pop("fail_fast", False) is True:
|
|
95
|
-
raise e
|
|
93
|
+
def _top(self, bits):
|
|
94
|
+
return RichR(self.state.top(bits))
|
|
96
95
|
|
|
97
|
-
def
|
|
98
|
-
self
|
|
99
|
-
): # pylint:disable=unused-argument,arguments-differ,arguments-renamed
|
|
100
|
-
super()._process(state, successors, block=block)
|
|
96
|
+
def _is_top(self, expr):
|
|
97
|
+
return self.state.is_top(expr.data)
|
|
101
98
|
|
|
102
99
|
#
|
|
103
100
|
# Address parsing
|
|
104
101
|
#
|
|
105
102
|
|
|
106
103
|
@staticmethod
|
|
107
|
-
def _addr_has_concrete_base(addr: claripy.ast.
|
|
104
|
+
def _addr_has_concrete_base(addr: claripy.ast.Bits) -> bool:
|
|
108
105
|
if addr.op == "__add__" and len(addr.args) == 2:
|
|
109
|
-
if addr.args[0].concrete:
|
|
106
|
+
if cast(claripy.ast.BV, addr.args[0]).concrete:
|
|
110
107
|
return True
|
|
111
|
-
if addr.args[1].concrete:
|
|
108
|
+
if cast(claripy.ast.BV, addr.args[1]).concrete:
|
|
112
109
|
return True
|
|
113
110
|
return False
|
|
114
111
|
|
|
115
112
|
@staticmethod
|
|
116
|
-
def _parse_offsetted_addr(addr: claripy.ast.
|
|
113
|
+
def _parse_offsetted_addr(addr: claripy.ast.Bits) -> tuple[claripy.ast.BV, claripy.ast.BV, int] | None:
|
|
117
114
|
if addr.op == "__add__" and len(addr.args) == 2:
|
|
118
115
|
concrete_base, byte_offset = None, None
|
|
119
|
-
if addr.args[0].concrete:
|
|
120
|
-
concrete_base, byte_offset = addr.args
|
|
121
|
-
elif addr.args[1].concrete:
|
|
122
|
-
concrete_base, byte_offset = addr.args[1], addr.args[0]
|
|
116
|
+
if cast(claripy.ast.BV, addr.args[0]).concrete:
|
|
117
|
+
concrete_base, byte_offset = cast(tuple[claripy.ast.BV, claripy.ast.BV], addr.args)
|
|
118
|
+
elif cast(claripy.ast.BV, addr.args[1]).concrete:
|
|
119
|
+
concrete_base, byte_offset = cast(tuple[claripy.ast.BV, claripy.ast.BV], (addr.args[1], addr.args[0]))
|
|
123
120
|
if concrete_base is None or byte_offset is None:
|
|
124
121
|
return None
|
|
125
122
|
base_addr = concrete_base
|
|
@@ -130,9 +127,9 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
130
127
|
elem_size = 1
|
|
131
128
|
else:
|
|
132
129
|
abs_offset = byte_offset
|
|
133
|
-
if abs_offset.op == "__lshift__" and abs_offset.args[1].concrete:
|
|
134
|
-
offset = abs_offset.args[0]
|
|
135
|
-
elem_size = 2 ** abs_offset.args[1].concrete_value
|
|
130
|
+
if abs_offset.op == "__lshift__" and cast(claripy.ast.BV, abs_offset.args[1]).concrete:
|
|
131
|
+
offset = cast(claripy.ast.BV, abs_offset.args[0])
|
|
132
|
+
elem_size = 2 ** cast(claripy.ast.BV, abs_offset.args[1]).concrete_value
|
|
136
133
|
elif abs_offset.op == "__mul__" and abs_offset.args[1].concrete:
|
|
137
134
|
offset = abs_offset.args[0]
|
|
138
135
|
elem_size = abs_offset.args[1].concrete_value
|
|
@@ -146,12 +143,9 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
146
143
|
#
|
|
147
144
|
|
|
148
145
|
def _ensure_variable_existence(
|
|
149
|
-
self, richr_addr: RichR, codeloc: CodeLocation, src_expr=None
|
|
150
|
-
) -> list[tuple[SimVariable, int]]
|
|
151
|
-
data
|
|
152
|
-
|
|
153
|
-
if data is None:
|
|
154
|
-
return None
|
|
146
|
+
self, richr_addr: RichR[claripy.ast.BV | claripy.ast.FP], codeloc: CodeLocation, src_expr=None
|
|
147
|
+
) -> list[tuple[SimVariable, int]]:
|
|
148
|
+
data = richr_addr.data
|
|
155
149
|
|
|
156
150
|
if self.state.is_stack_address(data):
|
|
157
151
|
# this is a stack address
|
|
@@ -209,7 +203,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
209
203
|
|
|
210
204
|
# write the variable back to stack
|
|
211
205
|
if vs is None:
|
|
212
|
-
top = self.state.top(self.arch.byte_width)
|
|
206
|
+
top = self.state.top(self.project.arch.byte_width)
|
|
213
207
|
top = self.state.annotate_with_variables(top, [(0, variable)])
|
|
214
208
|
vs = MultiValues(top)
|
|
215
209
|
self.state.stack_region.store(stack_addr, vs)
|
|
@@ -234,7 +228,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
234
228
|
existing_vars = [(variable, 0)]
|
|
235
229
|
|
|
236
230
|
else:
|
|
237
|
-
return
|
|
231
|
+
return []
|
|
238
232
|
|
|
239
233
|
# record all variables
|
|
240
234
|
for var, offset in existing_vars:
|
|
@@ -244,8 +238,8 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
244
238
|
|
|
245
239
|
return existing_vars
|
|
246
240
|
|
|
247
|
-
def _reference(self, richr: RichR, codeloc: CodeLocation, src=None):
|
|
248
|
-
data
|
|
241
|
+
def _reference(self, richr: RichR[claripy.ast.BV | claripy.ast.FP], codeloc: CodeLocation, src=None):
|
|
242
|
+
data = richr.data
|
|
249
243
|
|
|
250
244
|
if data is None:
|
|
251
245
|
return
|
|
@@ -260,7 +254,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
260
254
|
self.block.addr,
|
|
261
255
|
self.stmt_idx,
|
|
262
256
|
"memory",
|
|
263
|
-
block_idx=self.block.idx if isinstance(self.block, ailment.Block) else None,
|
|
257
|
+
block_idx=cast(ailment.Block, self.block).idx if isinstance(self.block, ailment.Block) else None,
|
|
264
258
|
)
|
|
265
259
|
|
|
266
260
|
# find the correct variable
|
|
@@ -306,14 +300,17 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
306
300
|
:return:
|
|
307
301
|
"""
|
|
308
302
|
|
|
309
|
-
if
|
|
303
|
+
if (
|
|
304
|
+
offset in (self.project.arch.ip_offset, self.project.arch.sp_offset, self.project.arch.lr_offset)
|
|
305
|
+
or not create_variable
|
|
306
|
+
):
|
|
310
307
|
# only store the value. don't worry about variables.
|
|
311
308
|
v = MultiValues(richr.data)
|
|
312
309
|
self.state.register_region.store(offset, v)
|
|
313
310
|
return
|
|
314
311
|
|
|
315
312
|
codeloc: CodeLocation = self._codeloc()
|
|
316
|
-
data
|
|
313
|
+
data = richr.data
|
|
317
314
|
|
|
318
315
|
# lea
|
|
319
316
|
self._ensure_variable_existence(richr, codeloc)
|
|
@@ -329,7 +326,9 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
329
326
|
# next check if we are overwriting *part* of an existing variable that is not an input variable
|
|
330
327
|
addr_and_variables = set()
|
|
331
328
|
try:
|
|
332
|
-
vs: MultiValues = self.state.register_region.load(
|
|
329
|
+
vs: MultiValues = self.state.register_region.load(
|
|
330
|
+
offset, size=size, endness=self.project.arch.register_endness
|
|
331
|
+
)
|
|
333
332
|
for values in vs.values():
|
|
334
333
|
for value in values:
|
|
335
334
|
addr_and_variables.update(self.state.extract_variables(value))
|
|
@@ -371,8 +370,8 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
371
370
|
|
|
372
371
|
def _assign_to_vvar(
|
|
373
372
|
self,
|
|
374
|
-
vvar: ailment.
|
|
375
|
-
richr,
|
|
373
|
+
vvar: ailment.expression.VirtualVariable,
|
|
374
|
+
richr: RichR[claripy.ast.BV | claripy.ast.FP],
|
|
376
375
|
src=None,
|
|
377
376
|
dst=None,
|
|
378
377
|
create_variable: bool = True,
|
|
@@ -383,16 +382,15 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
383
382
|
vvar_id = vvar.varid
|
|
384
383
|
|
|
385
384
|
if (
|
|
386
|
-
vvar.category == ailment.
|
|
387
|
-
and vvar.oident in (self.arch.ip_offset, self.arch.sp_offset, self.arch.lr_offset)
|
|
388
|
-
|
|
389
|
-
):
|
|
385
|
+
vvar.category == ailment.expression.VirtualVariableCategory.REGISTER
|
|
386
|
+
and vvar.oident in (self.project.arch.ip_offset, self.project.arch.sp_offset, self.project.arch.lr_offset)
|
|
387
|
+
) or not create_variable:
|
|
390
388
|
# only store the value. don't worry about variables.
|
|
391
389
|
self.vvar_region[vvar_id] = richr.data
|
|
392
390
|
return
|
|
393
391
|
|
|
394
392
|
codeloc: CodeLocation = self._codeloc()
|
|
395
|
-
data
|
|
393
|
+
data = richr.data
|
|
396
394
|
|
|
397
395
|
# lea
|
|
398
396
|
self._ensure_variable_existence(richr, codeloc)
|
|
@@ -467,7 +465,9 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
467
465
|
self.state.add_type_constraint(typevars.Subtype(richr.typevar, typevar))
|
|
468
466
|
self.state.add_type_constraint(typevars.Subtype(typevar, typeconsts.int_type(variable.size * 8)))
|
|
469
467
|
|
|
470
|
-
def _store(
|
|
468
|
+
def _store(
|
|
469
|
+
self, richr_addr: RichR[claripy.ast.BV], data: RichR[claripy.ast.BV | claripy.ast.FP], size, stmt=None
|
|
470
|
+
): # pylint:disable=unused-argument
|
|
471
471
|
"""
|
|
472
472
|
|
|
473
473
|
:param RichR addr:
|
|
@@ -476,16 +476,16 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
476
476
|
:return:
|
|
477
477
|
"""
|
|
478
478
|
|
|
479
|
-
addr
|
|
479
|
+
addr = richr_addr.data
|
|
480
480
|
stored = False
|
|
481
481
|
|
|
482
482
|
if addr.concrete:
|
|
483
483
|
# fully concrete. this is a global address
|
|
484
484
|
self._store_to_global(addr.concrete_value, data, size, stmt=stmt)
|
|
485
485
|
stored = True
|
|
486
|
-
elif self._addr_has_concrete_base(addr) and self._parse_offsetted_addr(addr) is not None:
|
|
486
|
+
elif self._addr_has_concrete_base(addr) and (parsed := self._parse_offsetted_addr(addr)) is not None:
|
|
487
487
|
# we are storing to a concrete global address with an offset
|
|
488
|
-
base_addr, offset, elem_size =
|
|
488
|
+
base_addr, offset, elem_size = parsed
|
|
489
489
|
self._store_to_global(base_addr.concrete_value, data, size, stmt=stmt, offset=offset, elem_size=elem_size)
|
|
490
490
|
stored = True
|
|
491
491
|
else:
|
|
@@ -509,7 +509,9 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
509
509
|
# storing to a location specified by a pointer whose value cannot be determined at this point
|
|
510
510
|
self._store_to_variable(richr_addr, size, stmt=stmt)
|
|
511
511
|
|
|
512
|
-
def _store_to_stack(
|
|
512
|
+
def _store_to_stack(
|
|
513
|
+
self, stack_offset, data: RichR[claripy.ast.BV | claripy.ast.FP], size, offset=0, stmt=None, endness=None
|
|
514
|
+
):
|
|
513
515
|
if stmt is None:
|
|
514
516
|
existing_vars = self.variable_manager[self.func_addr].find_variables_by_stmt(
|
|
515
517
|
self.block.addr, self.stmt_idx, "memory"
|
|
@@ -581,7 +583,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
581
583
|
size: int,
|
|
582
584
|
stmt=None,
|
|
583
585
|
offset: claripy.ast.BV | None = None,
|
|
584
|
-
elem_size:
|
|
586
|
+
elem_size: int | None = None,
|
|
585
587
|
):
|
|
586
588
|
variable_manager = self.variable_manager["global"]
|
|
587
589
|
if stmt is None:
|
|
@@ -592,8 +594,8 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
592
594
|
if offset is None or elem_size is None:
|
|
593
595
|
# trivial case
|
|
594
596
|
abs_addr = addr
|
|
595
|
-
elif offset.concrete
|
|
596
|
-
abs_addr = addr + offset.concrete_value * elem_size
|
|
597
|
+
elif offset.concrete:
|
|
598
|
+
abs_addr = addr + offset.concrete_value * elem_size
|
|
597
599
|
else:
|
|
598
600
|
abs_addr = None
|
|
599
601
|
|
|
@@ -618,17 +620,17 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
618
620
|
|
|
619
621
|
if abs_addr is not None:
|
|
620
622
|
self.state.global_region.store(
|
|
621
|
-
addr, data_expr, endness=self.
|
|
623
|
+
addr, data_expr, endness=self.project.arch.memory_endness if stmt is None else stmt.endness
|
|
622
624
|
)
|
|
623
625
|
|
|
624
626
|
codeloc = CodeLocation(
|
|
625
627
|
self.block.addr, self.stmt_idx, ins_addr=self.ins_addr, block_idx=getattr(self.block, "idx", None)
|
|
626
628
|
)
|
|
627
|
-
values = None
|
|
629
|
+
values: MultiValues | None = None
|
|
628
630
|
if abs_addr is not None:
|
|
629
631
|
with contextlib.suppress(SimMemoryMissingError):
|
|
630
|
-
values
|
|
631
|
-
abs_addr, size=size, endness=self.
|
|
632
|
+
values = self.state.global_region.load(
|
|
633
|
+
abs_addr, size=size, endness=self.project.arch.memory_endness if stmt is None else stmt.endness
|
|
632
634
|
)
|
|
633
635
|
|
|
634
636
|
if values is not None:
|
|
@@ -649,8 +651,8 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
649
651
|
|
|
650
652
|
if offset is not None and elem_size is not None:
|
|
651
653
|
# it's an array!
|
|
652
|
-
if offset.concrete
|
|
653
|
-
concrete_offset = offset.concrete_value * elem_size
|
|
654
|
+
if offset.concrete:
|
|
655
|
+
concrete_offset = offset.concrete_value * elem_size
|
|
654
656
|
store_typevar = self._create_access_typevar(typevar, True, size, concrete_offset)
|
|
655
657
|
self.state.add_type_constraint(typevars.Subtype(store_typevar, typeconsts.TopType()))
|
|
656
658
|
else:
|
|
@@ -671,7 +673,9 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
671
673
|
self.state.add_type_constraint(typevars.Subtype(store_typevar, typeconsts.TopType()))
|
|
672
674
|
self.state.add_type_constraint(typevars.Subtype(data.typevar, store_typevar))
|
|
673
675
|
|
|
674
|
-
def _store_to_variable(
|
|
676
|
+
def _store_to_variable(
|
|
677
|
+
self, richr_addr: RichR[claripy.ast.BV], size: int, stmt=None
|
|
678
|
+
): # pylint:disable=unused-argument
|
|
675
679
|
addr_variable = richr_addr.variable
|
|
676
680
|
codeloc = self._codeloc()
|
|
677
681
|
|
|
@@ -698,7 +702,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
698
702
|
self.state.typevars.add_type_variable(addr_variable, codeloc, typevar)
|
|
699
703
|
self.state.add_type_constraint(typevars.Subtype(store_typevar, typeconsts.TopType()))
|
|
700
704
|
|
|
701
|
-
def _load(self, richr_addr: RichR, size: int, expr=None):
|
|
705
|
+
def _load(self, richr_addr: RichR[claripy.ast.BV], size: int, expr=None):
|
|
702
706
|
"""
|
|
703
707
|
|
|
704
708
|
:param RichR richr_addr:
|
|
@@ -706,7 +710,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
706
710
|
:return:
|
|
707
711
|
"""
|
|
708
712
|
|
|
709
|
-
addr
|
|
713
|
+
addr = cast(claripy.ast.BV, richr_addr.data)
|
|
710
714
|
codeloc = CodeLocation(
|
|
711
715
|
self.block.addr, self.stmt_idx, ins_addr=self.ins_addr, block_idx=getattr(self.block, "idx", None)
|
|
712
716
|
)
|
|
@@ -737,14 +741,17 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
737
741
|
concrete_offset = stack_offset
|
|
738
742
|
dynamic_offset = None
|
|
739
743
|
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
self.state.
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
744
|
+
if concrete_offset is not None:
|
|
745
|
+
try:
|
|
746
|
+
values: MultiValues | None = self.state.stack_region.load(
|
|
747
|
+
self.state.stack_addr_from_offset(concrete_offset),
|
|
748
|
+
size=size,
|
|
749
|
+
endness=self.project.arch.memory_endness,
|
|
750
|
+
)
|
|
746
751
|
|
|
747
|
-
|
|
752
|
+
except SimMemoryMissingError:
|
|
753
|
+
values = None
|
|
754
|
+
else:
|
|
748
755
|
values = None
|
|
749
756
|
|
|
750
757
|
all_vars: set[tuple[int, SimVariable]] = set()
|
|
@@ -756,7 +763,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
756
763
|
var_offset = stack_offset - var_.offset
|
|
757
764
|
all_vars.add((var_offset, var_))
|
|
758
765
|
|
|
759
|
-
if not all_vars:
|
|
766
|
+
if not all_vars and concrete_offset is not None:
|
|
760
767
|
variables = self.variable_manager[self.func_addr].find_variables_by_stack_offset(concrete_offset)
|
|
761
768
|
if not variables:
|
|
762
769
|
variable = SimStackVariable(
|
|
@@ -770,28 +777,27 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
770
777
|
variables = {variable}
|
|
771
778
|
l.debug("Identified a new stack variable %s at %#x.", variable, self.ins_addr)
|
|
772
779
|
for variable in variables:
|
|
773
|
-
v = self.state.top(size * self.
|
|
780
|
+
v = self.state.top(size * self.project.arch.byte_width)
|
|
774
781
|
v = self.state.annotate_with_variables(v, [(0, variable)])
|
|
775
782
|
stack_addr = self.state.stack_addr_from_offset(concrete_offset)
|
|
776
|
-
self.state.stack_region.store(stack_addr, v, endness=self.
|
|
783
|
+
self.state.stack_region.store(stack_addr, v, endness=self.project.arch.memory_endness)
|
|
777
784
|
|
|
778
785
|
all_vars = {(0, variable) for variable in variables}
|
|
779
786
|
|
|
780
|
-
|
|
781
|
-
# overlapping variables
|
|
782
|
-
all_vars = list(all_vars)
|
|
787
|
+
all_vars_list = list(all_vars)
|
|
783
788
|
|
|
789
|
+
if len(all_vars_list) > 1:
|
|
784
790
|
# sort by some value so that the outcome here isn't random
|
|
785
|
-
|
|
791
|
+
cast(list[tuple[int, SimStackVariable]], all_vars_list).sort(
|
|
786
792
|
reverse=True,
|
|
787
793
|
key=lambda val: (val[0], val[1].offset, val[1].base, val[1].base_addr, val[1].size),
|
|
788
794
|
)
|
|
789
795
|
|
|
790
796
|
l.warning(
|
|
791
|
-
"Reading memory with overlapping variables: %s. Ignoring all but the first one.",
|
|
797
|
+
"Reading memory with overlapping variables: %s. Ignoring all but the first one.", all_vars_list
|
|
792
798
|
)
|
|
793
799
|
|
|
794
|
-
var_offset, var = next(iter(
|
|
800
|
+
var_offset, var = next(iter(all_vars_list)) # won't fail
|
|
795
801
|
# calculate variable_offset
|
|
796
802
|
if dynamic_offset is None:
|
|
797
803
|
offset_into_variable = var_offset
|
|
@@ -838,8 +844,8 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
838
844
|
# | typevars.HasField(size * 8, 0)
|
|
839
845
|
# | )
|
|
840
846
|
|
|
841
|
-
r = self.state.top(size * self.
|
|
842
|
-
r = self.state.annotate_with_variables(r,
|
|
847
|
+
r = self.state.top(size * self.project.arch.byte_width)
|
|
848
|
+
r = self.state.annotate_with_variables(r, all_vars_list)
|
|
843
849
|
return RichR(r, variable=var, typevar=typevar)
|
|
844
850
|
|
|
845
851
|
elif addr.concrete:
|
|
@@ -847,9 +853,9 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
847
853
|
v = self._load_from_global(addr.concrete_value, size, expr=expr)
|
|
848
854
|
typevar = v.typevar
|
|
849
855
|
|
|
850
|
-
elif self._addr_has_concrete_base(addr) and self._parse_offsetted_addr(addr) is not None:
|
|
856
|
+
elif self._addr_has_concrete_base(addr) and (parsed := self._parse_offsetted_addr(addr)) is not None:
|
|
851
857
|
# Loading data from a memory address with an offset
|
|
852
|
-
base_addr, offset, elem_size =
|
|
858
|
+
base_addr, offset, elem_size = parsed
|
|
853
859
|
v = self._load_from_global(base_addr.concrete_value, size, expr=expr, offset=offset, elem_size=elem_size)
|
|
854
860
|
typevar = v.typevar
|
|
855
861
|
|
|
@@ -883,7 +889,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
883
889
|
typevar = self._create_access_typevar(richr_addr_typevar, False, size, offset)
|
|
884
890
|
self.state.add_type_constraint(typevars.Subtype(typevar, typeconsts.TopType()))
|
|
885
891
|
|
|
886
|
-
return RichR(self.state.top(size * self.
|
|
892
|
+
return RichR(self.state.top(size * self.project.arch.byte_width), typevar=typevar)
|
|
887
893
|
|
|
888
894
|
def _load_from_global(
|
|
889
895
|
self,
|
|
@@ -891,8 +897,8 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
891
897
|
size,
|
|
892
898
|
expr=None,
|
|
893
899
|
offset: claripy.ast.BV | None = None,
|
|
894
|
-
elem_size:
|
|
895
|
-
) -> RichR:
|
|
900
|
+
elem_size: int | None = None,
|
|
901
|
+
) -> RichR[claripy.ast.BV]:
|
|
896
902
|
variable_manager = self.variable_manager["global"]
|
|
897
903
|
if expr is None:
|
|
898
904
|
existing_vars = variable_manager.find_variables_by_stmt(self.block.addr, self.stmt_idx, "memory")
|
|
@@ -914,7 +920,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
914
920
|
if not existing_vars:
|
|
915
921
|
# is this address mapped?
|
|
916
922
|
if self.project.loader.find_object_containing(addr) is None:
|
|
917
|
-
return RichR(self.state.top(size * self.
|
|
923
|
+
return RichR(self.state.top(size * self.project.arch.byte_width))
|
|
918
924
|
variable = SimMemoryVariable(
|
|
919
925
|
addr,
|
|
920
926
|
size,
|
|
@@ -940,8 +946,8 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
940
946
|
|
|
941
947
|
if offset is not None and elem_size is not None:
|
|
942
948
|
# it's an array!
|
|
943
|
-
if offset.concrete
|
|
944
|
-
concrete_offset = offset.concrete_value * elem_size
|
|
949
|
+
if offset.concrete:
|
|
950
|
+
concrete_offset = offset.concrete_value * elem_size
|
|
945
951
|
load_typevar = self._create_access_typevar(typevar, True, size, concrete_offset)
|
|
946
952
|
self.state.add_type_constraint(typevars.Subtype(load_typevar, typeconsts.TopType()))
|
|
947
953
|
else:
|
|
@@ -951,7 +957,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
951
957
|
load_typevar = self._create_access_typevar(typevar, True, size, concrete_offset)
|
|
952
958
|
self.state.add_type_constraint(typevars.Subtype(load_typevar, typeconsts.TopType()))
|
|
953
959
|
|
|
954
|
-
return RichR(self.state.top(size * self.
|
|
960
|
+
return RichR(self.state.top(size * self.project.arch.byte_width), typevar=typevar)
|
|
955
961
|
|
|
956
962
|
def _read_from_register(self, offset, size, expr=None, force_variable_size=None, create_variable: bool = True):
|
|
957
963
|
"""
|
|
@@ -968,17 +974,17 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
968
974
|
except SimMemoryMissingError:
|
|
969
975
|
values = None
|
|
970
976
|
|
|
971
|
-
if offset in (self.arch.sp_offset, self.arch.ip_offset):
|
|
977
|
+
if offset in (self.project.arch.sp_offset, self.project.arch.ip_offset):
|
|
972
978
|
# load values. don't worry about variables
|
|
973
979
|
if values is None:
|
|
974
|
-
r_value = self.state.top(size * self.arch.byte_width)
|
|
980
|
+
r_value = self.state.top(size * self.project.arch.byte_width)
|
|
975
981
|
else:
|
|
976
982
|
r_value = next(iter(next(iter(values.values()))))
|
|
977
983
|
return RichR(r_value, variable=None, typevar=None)
|
|
978
984
|
|
|
979
985
|
if not values:
|
|
980
986
|
# the value does not exist.
|
|
981
|
-
value = self.state.top(size * self.
|
|
987
|
+
value = self.state.top(size * self.project.arch.byte_width)
|
|
982
988
|
if create_variable:
|
|
983
989
|
# create a new variable if necessary
|
|
984
990
|
variable = SimRegisterVariable(
|
|
@@ -1001,7 +1007,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
1001
1007
|
self.variable_manager[self.func_addr].read_from(var, None, codeloc, atom=expr, overwrite=False)
|
|
1002
1008
|
variable_set.add(var)
|
|
1003
1009
|
|
|
1004
|
-
if offset == self.arch.sp_offset:
|
|
1010
|
+
if offset == self.project.arch.sp_offset:
|
|
1005
1011
|
# ignore sp
|
|
1006
1012
|
typevar = None
|
|
1007
1013
|
var = None
|
|
@@ -1028,7 +1034,7 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
1028
1034
|
typevar = self.state.typevars[var]
|
|
1029
1035
|
|
|
1030
1036
|
r_value = (
|
|
1031
|
-
next(iter(value_list[0])) if len(value_list) == 1 else self.state.top(size * self.arch.byte_width)
|
|
1037
|
+
next(iter(value_list[0])) if len(value_list) == 1 else self.state.top(size * self.project.arch.byte_width)
|
|
1032
1038
|
) # fall back to top
|
|
1033
1039
|
if var is not None and var.size != size:
|
|
1034
1040
|
# ignore the variable and the associated type if we are only reading part of the variable
|
|
@@ -1036,22 +1042,26 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
1036
1042
|
return RichR(r_value, variable=var, typevar=typevar)
|
|
1037
1043
|
|
|
1038
1044
|
def _read_from_vvar(
|
|
1039
|
-
self,
|
|
1045
|
+
self,
|
|
1046
|
+
vvar: ailment.expression.VirtualVariable,
|
|
1047
|
+
expr=None,
|
|
1048
|
+
create_variable: bool = True,
|
|
1049
|
+
vvar_id: int | None = None,
|
|
1040
1050
|
):
|
|
1041
1051
|
codeloc = self._codeloc()
|
|
1042
1052
|
|
|
1043
1053
|
if vvar_id is None:
|
|
1044
1054
|
vvar_id = vvar.varid
|
|
1045
1055
|
|
|
1046
|
-
value: claripy.ast.
|
|
1056
|
+
value: claripy.ast.BV | None = self.vvar_region.get(vvar_id, None)
|
|
1047
1057
|
|
|
1048
1058
|
# fallback for register arguments
|
|
1049
1059
|
if value is None and vvar.was_reg:
|
|
1050
1060
|
return self._read_from_register(vvar.reg_offset, vvar.size, expr=vvar, create_variable=True)
|
|
1051
1061
|
|
|
1052
1062
|
if vvar.category == ailment.Expr.VirtualVariableCategory.REGISTER and vvar.oident in (
|
|
1053
|
-
self.arch.sp_offset,
|
|
1054
|
-
self.arch.ip_offset,
|
|
1063
|
+
self.project.arch.sp_offset,
|
|
1064
|
+
self.project.arch.ip_offset,
|
|
1055
1065
|
):
|
|
1056
1066
|
# load values. don't worry about variables
|
|
1057
1067
|
r_value = self.state.top(vvar.size) if value is None else value
|
|
@@ -1095,7 +1105,10 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
1095
1105
|
self.variable_manager[self.func_addr].read_from(var, None, codeloc, atom=expr, overwrite=False)
|
|
1096
1106
|
variable_set.add(var)
|
|
1097
1107
|
|
|
1098
|
-
if
|
|
1108
|
+
if (
|
|
1109
|
+
vvar.category == ailment.Expr.VirtualVariableCategory.REGISTER
|
|
1110
|
+
and vvar.oident == self.project.arch.sp_offset
|
|
1111
|
+
):
|
|
1099
1112
|
# ignore sp
|
|
1100
1113
|
typevar = None
|
|
1101
1114
|
var = None
|
|
@@ -1127,7 +1140,11 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
1127
1140
|
return RichR(value, variable=var, typevar=typevar)
|
|
1128
1141
|
|
|
1129
1142
|
def _create_access_typevar(
|
|
1130
|
-
self,
|
|
1143
|
+
self,
|
|
1144
|
+
typevar: typeconsts.TypeConstant | TypeVariable | DerivedTypeVariable,
|
|
1145
|
+
is_store: bool,
|
|
1146
|
+
size: int,
|
|
1147
|
+
offset: int,
|
|
1131
1148
|
) -> DerivedTypeVariable:
|
|
1132
1149
|
if isinstance(typevar, DerivedTypeVariable):
|
|
1133
1150
|
if isinstance(typevar.labels[-1], AddN):
|
|
@@ -1146,5 +1163,5 @@ class SimEngineVRBase(SimEngineLight):
|
|
|
1146
1163
|
return DerivedTypeVariable(
|
|
1147
1164
|
typevar,
|
|
1148
1165
|
None,
|
|
1149
|
-
labels=(lbl, typevars.HasField(size * self.
|
|
1166
|
+
labels=(lbl, typevars.HasField(size * self.project.arch.byte_width, offset)),
|
|
1150
1167
|
)
|