angr.analyses.reaching_definitions.function_handler¶
- angr.analyses.reaching_definitions.function_handler.get_exit_livedefinitions(func, rda_model)¶
Get LiveDefinitions at all exits of a function, merge them, and return.
- Parameters:
func (Function)
rda_model (ReachingDefinitionsModel)
- class angr.analyses.reaching_definitions.function_handler.FunctionEffect¶
Bases:
objectA single effect that a function summary may apply to the state. This is largely an implementation detail; use FunctionCallData.depends instead.
- value: MultiValues | None = None¶
- sources_defns: set[Definition] | None = None¶
- __init__(dest, sources, value=None, sources_defns=None, apply_at_callsite=False, tags=None)¶
- Parameters:
dest (Atom | None)
value (MultiValues | None)
sources_defns (set[Definition] | None)
apply_at_callsite (bool)
- Return type:
None
- class angr.analyses.reaching_definitions.function_handler.FunctionCallData¶
Bases:
objectA bundle of intermediate data used when computing the sum effect of a function during ReachingDefinitionsAnalysis.
RDA engine contract:
Construct one of these before calling FunctionHandler.handle_function. Fill it with as many fields as you can realistically provide without duplicating effort.
Provide callsite_codeloc as either the call statement (AIL) or the default exit of the default statement of the calling block (VEX)
Provide function_codeloc as the callee address with stmt_idx=0`.
Function handler contract:
If redefine_locals is unset, do not adjust any artifacts of the function call abstraction, such as the stack pointer, the caller saved registers, etc.
If caller_will_handle_single_ret is set, and there is a single entry in ret_atoms, do not apply to the state effects modifying this atom. Instead, set ret_values and ret_values_deps to the values and deps which are used constructing these values.
- callsite_codeloc: CodeLocation
- function_codeloc: CodeLocation
- address_multi: MultiValues[BV | FP] | None
- prototype: SimTypeFunction | None = None¶
- effects: list[FunctionEffect]
- ret_values: MultiValues[BV | FP] | None = None¶
- ret_values_deps: set[Definition] | None = None¶
- has_clobbered(dest)¶
Determines whether the given atom already has effects applied
- depends(dest, *sources, value=None, apply_at_callsite=False, tags=None)¶
Mark a single effect of the current function, including the atom being modified, the input atoms on which that output atom depends, the precise (or imprecise!) value to store, and whether the effect should be applied during the function or afterwards, at the callsite.
The tags are used to annotate the Definition of the Atom that will be created, when the function effects are applied to the state.
The atom being modified may be None to mark uses of the source atoms which do not have any explicit sinks.
- reset_prototype(prototype, state, soft_reset=False)¶
- Return type:
- Parameters:
prototype (SimTypeFunction)
state (ReachingDefinitionsState)
soft_reset (bool)
- __init__(callsite_codeloc, function_codeloc, address_multi, address=None, symbol=None, function=None, name=None, cc=None, prototype=None, args_atoms=None, args_values=None, ret_atoms=None, redefine_locals=True, visited_blocks=None, effects=<factory>, ret_values=None, ret_values_deps=None, caller_will_handle_single_ret=False, guessed_cc=False, guessed_prototype=False, retaddr_popped=False)¶
- Parameters:
callsite_codeloc (CodeLocation)
function_codeloc (CodeLocation)
address_multi (MultiValues[BV | FP] | None)
address (int | None)
symbol (Symbol | None)
function (Function | None)
name (str | None)
cc (SimCC | None)
prototype (SimTypeFunction | None)
args_values (list[MultiValues[BV | FP]] | None)
redefine_locals (bool)
effects (list[FunctionEffect])
ret_values (MultiValues[BV | FP] | None)
ret_values_deps (set[Definition] | None)
caller_will_handle_single_ret (bool)
guessed_cc (bool)
guessed_prototype (bool)
retaddr_popped (bool)
- Return type:
None
- class angr.analyses.reaching_definitions.function_handler.FunctionCallDataUnwrapped¶
Bases:
FunctionCallDataA subclass of FunctionCallData which asserts that many of its members are non-None at construction time. Typechecks be gone!
- address_multi: MultiValues
- __init__(inner)¶
- Parameters:
inner (FunctionCallData)
- static decorate(wrapper, *, wrapped=<function FunctionCallDataUnwrapped.decorate>, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__', '__type_params__'), updated=('__dict__', ))
Update a wrapper function to look like the wrapped function
wrapper is the function to be updated wrapped is the original function assigned is a tuple naming the attributes assigned directly from the wrapped function to the wrapper function (defaults to functools.WRAPPER_ASSIGNMENTS) updated is a tuple naming the attributes of the wrapper that are updated with the corresponding attribute from the wrapped function (defaults to functools.WRAPPER_UPDATES)
- class angr.analyses.reaching_definitions.function_handler.FunctionCallRelationships¶
Bases:
objectProduced by the function handler, provides associated callsite info and function input/output definitions.
- callsite: CodeLocation
- args_defns: list[set[Definition]]
- other_input_defns: set[Definition]
- ret_defns: set[Definition]
- other_output_defns: set[Definition]
- __init__(callsite, target, args_defns, other_input_defns, ret_defns, other_output_defns)¶
- Parameters:
callsite (CodeLocation)
target (int | None)
args_defns (list[set[Definition]])
other_input_defns (set[Definition])
ret_defns (set[Definition])
other_output_defns (set[Definition])
- Return type:
None
- class angr.analyses.reaching_definitions.function_handler.FunctionHandler¶
Bases:
objectA mechanism for summarizing a function call’s effect on a program for ReachingDefinitionsAnalysis.
- __init__(interfunction_level=0, extra_impls=None)¶
- Parameters:
interfunction_level (
int) – Maximum depth in to continue local function explorationextra_impls (
Iterable[type[FunctionHandler]] |None) – FunctionHandler classes to implement beyond what’s implemented in function_handler_library
- interfunction_level: int
- hook(analysis)¶
Attach this instance of the function handler to an instance of RDA.
- Return type:
- Parameters:
analysis (ReachingDefinitionsAnalysis)
- make_function_codeloc(target, callsite, callsite_func_addr)¶
The RDA engine will call this function to transform a callsite CodeLocation into a callee CodeLocation.
- Parameters:
target (None | int | MultiValues)
callsite (CodeLocation)
callsite_func_addr (int | None)
- handle_function(state, data)¶
The main entry point for the function handler. Called with a RDA state and a FunctionCallData, it is expected to update the state and the data as per the contracts described on FunctionCallData.
You can override this method to take full control over how data is processed, or override any of the following to use the higher-level interface (data.depends()):
handle_impl_<function name> - used for <function name>.
handle_local_function - used for any function (excluding plt stubs) whose address is inside the main binary.
handle_external_function - used for any function or plt stub whose address is outside the main binary.
handle_indirect_function - used for any function whose target cannot be resolved.
handle_generic_function - used as a default if none of the above are overridden.
Each of them take the same signature as handle_function.
- Parameters:
state (ReachingDefinitionsState)
data (FunctionCallData)
- handle_generic_function(state, data)¶
- Parameters:
state (ReachingDefinitionsState)
data (FunctionCallData)
- handle_indirect_function(state, data)¶
- Return type:
- Parameters:
state (ReachingDefinitionsState)
data (FunctionCallData)
- handle_local_function(state, data)¶
- Return type:
- Parameters:
state (ReachingDefinitionsState)
data (FunctionCallData)
- handle_external_function(state, data)¶
- Return type:
- Parameters:
state (ReachingDefinitionsState)
data (FunctionCallData)
- recurse_analysis(state, data)¶
Precondition:
data.functionMUST NOT BE NONE in order to call this method.- Return type:
- Parameters:
state (ReachingDefinitionsState)
data (FunctionCallData)
- static c_args_as_atoms(state, cc, prototype)¶
- Return type:
- Parameters:
state (ReachingDefinitionsState)
cc (SimCC)
prototype (SimTypeFunction)
- static c_return_as_atoms(state, cc, prototype)¶
- Return type:
- Parameters:
state (ReachingDefinitionsState)
cc (SimCC)
prototype (SimTypeFunction)
- static caller_saved_regs_as_atoms(state, cc)¶
- Return type:
- Parameters:
state (ReachingDefinitionsState)
cc (SimCC)