Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
A helper class describing the pointer being passed to a LOAD or STORE. More...
Public Member Functions | |
bool | find (PcodeOp *op, Datatype *valueType) |
Locate root pointer for underlying LOAD or STORE. | |
void | duplicateToTemp (Funcdata &data, PcodeOp *followOp) |
COPY the root varnode into a temp register. | |
void | freePointerChain (Funcdata &data) |
Remove unused pointer calculations. | |
Private Member Functions | |
bool | backUpPointer (Datatype *impliedBase) |
Follow flow of pointer back thru INT_ADD or PTRSUB. | |
Private Attributes | |
PcodeOp * | loadStore |
LOAD or STORE op. | |
TypePointer * | ptrType |
Base pointer data-type of LOAD or STORE. | |
Varnode * | firstPointer |
Direct pointer input for LOAD or STORE. | |
Varnode * | pointer |
The root pointer. | |
int4 | baseOffset |
Offset of the LOAD or STORE relative to root pointer. | |
Friends | |
class | SplitDatatype |
A helper class describing the pointer being passed to a LOAD or STORE.
It makes distinction between the immediate pointer to the LOAD or STORE and a root pointer to the main structure or array, which the immediate pointer may be at an offset from.
|
private |
Follow flow of pointer back thru INT_ADD or PTRSUB.
If pointer Varnode is written by a COPY, INT_ADD, PTRSUB, or PTRADD from another pointer to a
then update pointer Varnode, baseOffset, and ptrType to this.
impliedBase | if non-null is the allowed element data-type for an implied array |
References ghidra::AddrSpace::addressToByteInt(), baseOffset, ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INT_ADD, ghidra::CPUI_PTRADD, ghidra::CPUI_PTRSUB, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Datatype::getMetatype(), ghidra::Varnode::getOffset(), ghidra::Varnode::getTypeReadFacing(), ghidra::TypePointer::getWordSize(), ghidra::Varnode::isConstant(), ghidra::Varnode::isWritten(), pointer, ptrType, ghidra::TYPE_ARRAY, ghidra::TYPE_PTR, and ghidra::TYPE_STRUCT.
COPY the root varnode into a temp register.
Add a COPY op from the pointer Varnode to temporary register and make it the new root pointer. This guarantees that the pointer Varnode will not be modified by subsequent STOREs and can be implicit in the expressions.
data | is the containing function |
followOp | is the point where the COPY should be inserted |
References ghidra::Funcdata::buildCopyTemp(), ghidra::SplitDatatype::data, and ghidra::Varnode::updateType().
Referenced by ghidra::SplitDatatype::splitStore().
Locate root pointer for underlying LOAD or STORE.
We search for a pointer to the specified data-type starting with the LOAD/STORE. If we don't immediately find it, we back up one level (through a PTRSUB, PTRADD, or INT_ADD). If it isn't found after 1 hop, false is returned. Once this pointer is found, we back up through any single path of nested TYPE_STRUCT and TYPE_ARRAY offsets to establish the final root pointer, and true is returned. Any accumulated offset, relative to the original LOAD or STORE pointer is recorded in the baseOffset.
op | is the LOAD or STORE |
valueType | is the specific data-type to match |
References ghidra::PcodeOp::getIn(), ghidra::Datatype::getMetatype(), ghidra::TYPE_ARRAY, ghidra::TYPE_PARTIALSTRUCT, and ghidra::TYPE_PTR.
Referenced by ghidra::SplitDatatype::splitLoad(), and ghidra::SplitDatatype::splitStore().
void ghidra::SplitDatatype::RootPointer::freePointerChain | ( | Funcdata & | data | ) |
Remove unused pointer calculations.
If the pointer Varnode is no longer used, recursively check and remove the op producing it, which will be either an INT_ADD or PTRSUB, until the root pointer is reached or a Varnode still being used is encountered.
data | is the containing function |
References ghidra::SplitDatatype::data, ghidra::PcodeOp::getIn(), and ghidra::Funcdata::opDestroy().
Referenced by ghidra::SplitDatatype::splitLoad(), and ghidra::SplitDatatype::splitStore().