decompiler
1.0.0
|
A class that solves for stack-pointer changes across unknown sub-functions. More...
Public Member Functions | |
void | solve (void) |
Solve the system of equations. | |
void | build (const Funcdata &data, AddrSpace *id, int4 spcbase) |
Build the system of equations. More... | |
int4 | getNumVariables (void) const |
Get the number of variables in the system. | |
Varnode * | getVariable (int4 i) const |
Get the i-th Varnode variable. | |
int4 | getCompanion (int4 i) const |
Get the i-th variable's companion index. | |
int4 | getSolution (int4 i) const |
Get the i-th variable's solution. | |
Private Member Functions | |
void | duplicate (void) |
Duplicate each equation, multiplying by -1. | |
void | propagate (int4 varnum, int4 val) |
Propagate solution for one variable to other variables. More... | |
Private Attributes | |
vector< StackEqn > | eqs |
Known equations based on operations that explicitly change the stack-pointer. | |
vector< StackEqn > | guess |
Guessed equations for underdetermined systems. | |
vector< Varnode * > | vnlist |
The indexed set of variables, one for each reference to the stack-pointer. | |
vector< int4 > | companion |
Index of companion input for variable produced by CPUI_INDIRECT. | |
Address | spacebase |
Starting address of the stack-pointer. | |
vector< int4 > | soln |
Collected solutions (corresponding to array of variables) | |
int4 | missedvariables |
Number of variables for which we are missing an equation. | |
A class that solves for stack-pointer changes across unknown sub-functions.
Build the system of equations.
Collect references to the stack-pointer as variables, and examine their defining PcodeOps to determine equations and coefficient.
data | is the function being analyzed |
id | is the stack address space |
spcbase | is the index, relative to the stack space, of the stack pointer |
References ghidra::Funcdata::beginLoc(), ghidra::PcodeOp::code(), ghidra::Varnode::comparePointers(), ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_AND, ghidra::CPUI_MULTIEQUAL, ghidra::Funcdata::endLoc(), ghidra::ProtoModel::extrapop_unknown, ghidra::Varnode::getAddr(), ghidra::Funcdata::getCallSpecs(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::PcodeOp::getOpFromConst(), ghidra::Varnode::getSpace(), ghidra::AddrSpace::getSpacebase(), ghidra::AddrSpace::getType(), ghidra::IPTR_IOP, ghidra::Varnode::isConstant(), ghidra::PcodeOp::numInput(), ghidra::StackEqn::rhs, ghidra::StackEqn::var1, and ghidra::StackEqn::var2.
Referenced by ghidra::ActionStackPtrFlow::analyzeExtraPop().
|
private |
Propagate solution for one variable to other variables.
Given a solution for one variable, look for equations containing the variable and attempt to solve for the other variable. Continue propagating new solutions to other equations to find even more solutions. Populate the soln array with the solutions.
varnum | is the index of the initial variable |
val | is the solution for the variable |
References ghidra::StackEqn::compare(), ghidra::StackEqn::var1, and ghidra::StackEqn::var2.