decompiler  1.0.0
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
AncestorRealistic Class Reference

Helper class for determining if Varnodes can trace their value from a legitimate source. More...

#include <funcdata.hh>

Classes

class  State
 Node in a depth first traversal of ancestors. More...
 

Public Member Functions

bool execute (PcodeOp *op, int4 slot, ParamTrial *t, bool allowFail)
 Perform a full ancestor check on a given parameter trial. More...
 

Private Types

enum  {
  enter_node, pop_success, pop_solid, pop_fail,
  pop_failkill
}
 Enumerations for state of depth first traversal. More...
 

Private Member Functions

void mark (Varnode *vn)
 Mark given Varnode is visited by the traversal. More...
 
int4 enterNode (State &state)
 Traverse into a new Varnode. More...
 
int4 uponPop (State &state, int4 command)
 Pop a Varnode from the traversal stack. More...
 
bool checkConditionalExe (State &state)
 Check if current Varnode produced by conditional flow. More...
 

Private Attributes

ParamTrialtrial
 Current trial being analyzed for suitability.
 
vector< StatestateStack
 Holds the depth-first traversal stack.
 
vector< const Varnode * > markedVn
 Holds visited Varnodes to properly trim cycles.
 
int4 multiDepth
 Number of MULTIEQUAL ops along current traversal path.
 
bool allowFailingPath
 True if we allow and test for failing paths due to conditional execution.
 

Detailed Description

Helper class for determining if Varnodes can trace their value from a legitimate source.

Try to determine if a Varnode (expressed as a particular input to a CALL, CALLIND, or RETURN op) makes sense as parameter passing (or return value) storage by examining the Varnode's ancestors. If it has ancestors that are unaffected, abnormal inputs, or killedbycall, then this is a sign that the Varnode doesn't make a good parameter.

Member Enumeration Documentation

anonymous enum
private

Enumerations for state of depth first traversal.

Enumerator
enter_node 

Extending path into new Varnode.

pop_success 

Backtracking, from path that contained a reasonable ancestor.

pop_solid 

Backtracking, from path with successful, solid, movement, via COPY, LOAD, or other arith/logical.

pop_fail 

Backtracking, from path with a bad ancestor.

pop_failkill 

Backtracking, from path with a bad ancestor, specifically killedbycall.

Member Function Documentation

bool AncestorRealistic::checkConditionalExe ( State state)
private

Check if current Varnode produced by conditional flow.

Returns
true if there are two input flows, one of which is a normal solid flow

References FlowBlock::getIn(), PcodeOp::getParent(), AncestorRealistic::State::getSolidSlot(), AncestorRealistic::State::op, FlowBlock::sizeIn(), and FlowBlock::sizeOut().

int4 AncestorRealistic::enterNode ( State state)
private
bool AncestorRealistic::execute ( PcodeOp op,
int4  slot,
ParamTrial t,
bool  allowFail 
)

Perform a full ancestor check on a given parameter trial.

Parameters
opis the CALL or RETURN to test parameter passing for
slotis the index of the particular input varnode to test
tis the ParamTrial object corresponding to the varnode
allowFailis true if we allow and test for failing paths due to conditional execution
Returns
true if the varnode has realistic ancestors for a parameter passing location

References PcodeOp::getIn(), and Varnode::isInput().

Referenced by ActionReturnRecovery::apply(), FuncCallSpecs::checkInputTrialUse(), and FuncCallSpecs::finalInputCheck().

void AncestorRealistic::mark ( Varnode vn)
inlineprivate

Mark given Varnode is visited by the traversal.

Parameters
vnis the given Varnode

References cseEliminateList(), cseElimination(), cseFindInBlock(), earliestUseInBlock(), opFlipInPlaceExecute(), opFlipInPlaceTest(), and Varnode::setMark().

int4 AncestorRealistic::uponPop ( State state,
int4  pop_command 
)
private

Pop a Varnode from the traversal stack.

Backtrack into a previously visited node

Parameters
stateis the node that needs to be popped from the stack
pop_commandis the type of pop (pop_success, pop_fail, pop_failkill, pop_solid) being performed
Returns
the command to execute (push or pop) after the current pop

References PcodeOp::code(), CPUI_MULTIEQUAL, PcodeOp::getIn(), AncestorRealistic::State::markSolid(), PcodeOp::numInput(), AncestorRealistic::State::op, AncestorRealistic::State::slot, and AncestorRealistic::State::vn.


The documentation for this class was generated from the following files: