decompiler
1.0.0
|
Container for data structures associated with a single function. More...
#include <funcdata.hh>
Public Member Functions | |
Funcdata (const string &nm, const string &disp, Scope *conf, const Address &addr, FunctionSymbol *sym, int4 sz=0) | |
Constructor. More... | |
~Funcdata (void) | |
Destructor. | |
const string & | getName (void) const |
Get the function's local symbol name. | |
const string & | getDisplayName (void) const |
Get the name to display in output. | |
const Address & | getAddress (void) const |
Get the entry point address. | |
int4 | getSize (void) const |
Get the function body size in bytes. | |
Architecture * | getArch (void) const |
Get the program/architecture owning this function. | |
FunctionSymbol * | getSymbol (void) const |
Return the symbol associated with this function. | |
bool | isHighOn (void) const |
Are high-level variables assigned to Varnodes. | |
bool | isProcStarted (void) const |
Has processing of the function started. | |
bool | isProcComplete (void) const |
Is processing of the function complete. | |
bool | hasUnreachableBlocks (void) const |
Did this function exhibit unreachable code. | |
bool | isTypeRecoveryOn (void) const |
Will data-type analysis be performed. | |
bool | hasTypeRecoveryStarted (void) const |
Has data-type recovery processes started. | |
bool | hasNoCode (void) const |
Return true if this function has no code body. | |
void | setNoCode (bool val) |
Toggle whether this has a body. | |
void | setLanedRegGenerated (void) |
Mark that laned registers have been collected. | |
void | setJumptableRecovery (bool val) |
Toggle whether this is being used for jump-table recovery. More... | |
bool | isJumptableRecoveryOn (void) const |
Is this used for jump-table recovery. | |
void | setDoublePrecisRecovery (bool val) |
Toggle whether double precision analysis is used. More... | |
bool | isDoublePrecisOn (void) const |
Is double precision analysis enabled. | |
bool | hasNoStructBlocks (void) const |
Return true if no block structuring was performed. | |
void | clear (void) |
Clear out old disassembly. | |
void | warning (const string &txt, const Address &ad) const |
Add a warning comment in the function body. More... | |
void | warningHeader (const string &txt) const |
Add a warning comment as part of the function header. More... | |
void | startProcessing (void) |
Start processing for this function. More... | |
void | stopProcessing (void) |
Mark that processing has completed for this function. | |
bool | startTypeRecovery (void) |
Mark that data-type analysis has started. | |
void | setTypeRecovery (bool val) |
Toggle whether data-type recovery will be performed on this function. More... | |
void | startCastPhase (void) |
Start the cast insertion phase. | |
uint4 | getCastPhaseIndex (void) const |
Get creation index at the start of cast insertion. | |
uint4 | getHighLevelIndex (void) const |
Get creation index at the start of HighVariable creation. | |
void | startCleanUp (void) |
Start clean-up phase. | |
uint4 | getCleanUpIndex (void) const |
Get creation index at the start of clean-up phase. | |
void | followFlow (const Address &baddr, const Address &eadddr) |
Generate raw p-code for the function. More... | |
void | truncatedFlow (const Funcdata *fd, const FlowInfo *flow) |
Generate a clone with truncated control-flow given a partial function. More... | |
bool | inlineFlow (Funcdata *inlinefd, FlowInfo &flow, PcodeOp *callop) |
In-line the p-code from another function into this function. More... | |
void | overrideFlow (const Address &addr, uint4 type) |
Override the control-flow p-code for a particular instruction. More... | |
void | doLiveInject (InjectPayload *payload, const Address &addr, BlockBasic *bl, list< PcodeOp *>::iterator pos) |
Inject p-code from a payload into this live function. More... | |
void | printRaw (ostream &s) const |
Print raw p-code op descriptions to a stream. More... | |
void | printVarnodeTree (ostream &s) const |
Print a description of all Varnodes to a stream. More... | |
void | printBlockTree (ostream &s) const |
Print a description of control-flow structuring to a stream. More... | |
void | printLocalRange (ostream &s) const |
Print description of memory ranges associated with local scopes. More... | |
void | encode (Encoder &encoder, uint8 id, bool savetree) const |
Encode a description of this function to stream. More... | |
uint8 | decode (Decoder &decoder) |
Restore the state of this function from an XML description. More... | |
void | encodeJumpTable (Encoder &encoder) const |
Encode a description of jump-tables to stream. More... | |
void | decodeJumpTable (Decoder &decoder) |
Decode jump-tables from a stream. More... | |
void | encodeTree (Encoder &encoder) const |
Encode a description of the p-code tree to stream. More... | |
void | encodeHigh (Encoder &encoder) const |
Encode a description of all HighVariables to stream. More... | |
Override & | getOverride (void) |
Get the Override object for this function. | |
void | setRestartPending (bool val) |
Toggle whether analysis needs to be restarted for this function. More... | |
bool | hasRestartPending (void) const |
Does this function need to restart its analysis. More... | |
bool | hasUnimplemented (void) const |
Does this function have instructions marked as unimplemented. More... | |
bool | hasBadData (void) const |
Does this function flow into bad data. | |
void | spacebase (void) |
Mark registers that map to a virtual address space. More... | |
Varnode * | newSpacebasePtr (AddrSpace *id) |
Construct a new spacebase register for a given address space. More... | |
Varnode * | findSpacebaseInput (AddrSpace *id) const |
void | spacebaseConstant (PcodeOp *op, int4 slot, SymbolEntry *entry, const Address &rampoint, uintb origval, int4 origsize) |
Convert a constant pointer into a ram CPUI_PTRSUB. More... | |
int4 | getHeritagePass (void) const |
Get overall count of heritage passes. | |
int4 | numHeritagePasses (AddrSpace *spc) |
Get the number of heritage passes performed for the given address space. More... | |
void | seenDeadcode (AddrSpace *spc) |
Mark that dead Varnodes have been seen in a specific address space. More... | |
void | setDeadCodeDelay (AddrSpace *spc, int4 delay) |
Set a delay before removing dead code for a specific address space. More... | |
bool | deadRemovalAllowed (AddrSpace *spc) const |
Check if dead code removal is allowed for a specific address space. More... | |
bool | deadRemovalAllowedSeen (AddrSpace *spc) |
Check if dead Varnodes have been removed for a specific address space. More... | |
bool | isHeritaged (Varnode *vn) |
Check if a specific Varnode has been linked in fully to the syntax tree (SSA) More... | |
const list< LoadGuard > & | getLoadGuards (void) const |
Get the list of guarded LOADs. | |
const list< LoadGuard > & | getStoreGuards (void) const |
Get the list of guarded STOREs. | |
const LoadGuard * | getStoreGuard (PcodeOp *op) const |
Get LoadGuard associated with STORE op. | |
int4 | numCalls (void) const |
Get the number of calls made by this function. | |
FuncCallSpecs * | getCallSpecs (int4 i) const |
Get the i-th call specification. | |
FuncCallSpecs * | getCallSpecs (const PcodeOp *op) const |
Get the call specification associated with a CALL op. | |
int4 | fillinExtrapop (void) |
Recover and return the extrapop for this function. More... | |
int4 | numVarnodes (void) const |
Get the total number of Varnodes. | |
Varnode * | newVarnodeOut (int4 s, const Address &m, PcodeOp *op) |
Create a new output Varnode. More... | |
Varnode * | newUniqueOut (int4 s, PcodeOp *op) |
Create a new temporary output Varnode. More... | |
Varnode * | newVarnode (int4 s, const Address &m, Datatype *ct=(Datatype *) 0) |
Create a new unattached Varnode object. More... | |
Varnode * | newConstant (int4 s, uintb constant_val) |
Create a new constant Varnode. More... | |
Varnode * | newVarnode (int4 s, AddrSpace *base, uintb off) |
Create a new Varnode given an address space and offset. More... | |
Varnode * | newVarnodeIop (PcodeOp *op) |
Create a PcodeOp annotation Varnode. More... | |
Varnode * | newVarnodeSpace (AddrSpace *spc) |
Create a constant Varnode referring to an address space. More... | |
Varnode * | newVarnodeCallSpecs (FuncCallSpecs *fc) |
Create a call specification annotation Varnode. More... | |
Varnode * | newUnique (int4 s, Datatype *ct=(Datatype *) 0) |
Create a new temporary Varnode. More... | |
Varnode * | newCodeRef (const Address &m) |
Create a code address annotation Varnode. More... | |
Varnode * | setInputVarnode (Varnode *vn) |
Mark a Varnode as an input to the function. More... | |
void | adjustInputVarnodes (const Address &addr, int4 sz) |
Adjust input Varnodes contained in the given range. More... | |
void | deleteVarnode (Varnode *vn) |
Delete the given varnode. | |
Address | findDisjointCover (Varnode *vn, int4 &sz) |
Find range covering given Varnode and any intersecting Varnodes. More... | |
Varnode * | findCoveredInput (int4 s, const Address &loc) const |
Find the first input Varnode covered by the given range. More... | |
Varnode * | findCoveringInput (int4 s, const Address &loc) const |
Find the input Varnode that contains the given range. More... | |
Varnode * | findVarnodeInput (int4 s, const Address &loc) const |
Find the input Varnode with the given size and storage address. More... | |
Varnode * | findVarnodeWritten (int4 s, const Address &loc, const Address &pc, uintm uniq=~((uintm) 0)) const |
Find a defined Varnode via its storage address and its definition address. More... | |
VarnodeLocSet::const_iterator | beginLoc (void) const |
Start of all Varnodes sorted by storage. | |
VarnodeLocSet::const_iterator | endLoc (void) const |
End of all Varnodes sorted by storage. | |
VarnodeLocSet::const_iterator | beginLoc (AddrSpace *spaceid) const |
Start of Varnodes stored in a given address space. | |
VarnodeLocSet::const_iterator | endLoc (AddrSpace *spaceid) const |
End of Varnodes stored in a given address space. | |
VarnodeLocSet::const_iterator | beginLoc (const Address &addr) const |
Start of Varnodes at a storage address. | |
VarnodeLocSet::const_iterator | endLoc (const Address &addr) const |
End of Varnodes at a storage address. | |
VarnodeLocSet::const_iterator | beginLoc (int4 s, const Address &addr) const |
Start of Varnodes with given storage. | |
VarnodeLocSet::const_iterator | endLoc (int4 s, const Address &addr) const |
End of Varnodes with given storage. | |
VarnodeLocSet::const_iterator | beginLoc (int4 s, const Address &addr, uint4 fl) const |
Start of Varnodes matching storage and properties. | |
VarnodeLocSet::const_iterator | endLoc (int4 s, const Address &addr, uint4 fl) const |
End of Varnodes matching storage and properties. | |
VarnodeLocSet::const_iterator | beginLoc (int4 s, const Address &addr, const Address &pc, uintm uniq=~((uintm) 0)) const |
Start of Varnodes matching storage and definition address. | |
VarnodeLocSet::const_iterator | endLoc (int4 s, const Address &addr, const Address &pc, uintm uniq=~((uintm) 0)) const |
End of Varnodes matching storage and definition address. | |
uint4 | overlapLoc (VarnodeLocSet::const_iterator iter, vector< VarnodeLocSet::const_iterator > &bounds) const |
Given start, return maximal range of overlapping Varnodes. | |
VarnodeDefSet::const_iterator | beginDef (void) const |
Start of all Varnodes sorted by definition address. | |
VarnodeDefSet::const_iterator | endDef (void) const |
End of all Varnodes sorted by definition address. | |
VarnodeDefSet::const_iterator | beginDef (uint4 fl) const |
Start of Varnodes with a given definition property. | |
VarnodeDefSet::const_iterator | endDef (uint4 fl) const |
End of Varnodes with a given definition property. | |
VarnodeDefSet::const_iterator | beginDef (uint4 fl, const Address &addr) const |
Start of (input or free) Varnodes at a given storage address. | |
VarnodeDefSet::const_iterator | endDef (uint4 fl, const Address &addr) const |
End of (input or free) Varnodes at a given storage address. | |
void | checkForLanedRegister (int4 sz, const Address &addr) |
Check for a potential laned register. More... | |
map< VarnodeData, const LanedRegister * >::const_iterator | beginLaneAccess (void) const |
Beginning iterator over laned accesses. | |
map< VarnodeData, const LanedRegister * >::const_iterator | endLaneAccess (void) const |
Ending iterator over laned accesses. | |
void | clearLanedAccessMap (void) |
Clear records from the laned access list. | |
HighVariable * | findHigh (const string &nm) const |
Find a high-level variable by name. More... | |
void | mapGlobals (void) |
Make sure there is a Symbol entry for all global Varnodes. More... | |
void | prepareThisPointer (void) |
Prepare for recovery of the "this" pointer. More... | |
bool | checkCallDoubleUse (const PcodeOp *opmatch, const PcodeOp *op, const Varnode *vn, uint4 fl, const ParamTrial &trial) const |
Test for legitimate double use of a parameter trial. More... | |
bool | onlyOpUse (const Varnode *invn, const PcodeOp *opmatch, const ParamTrial &trial, uint4 mainFlags) const |
Test if the given Varnode seems to only be used by a CALL. More... | |
bool | ancestorOpUse (int4 maxlevel, const Varnode *invn, const PcodeOp *op, ParamTrial &trial, int4 offset, uint4 mainFlags) const |
Test if the given trial Varnode is likely only used for parameter passing. More... | |
bool | syncVarnodesWithSymbols (const ScopeLocal *lm, bool updateDatatypes, bool unmappedAliasCheck) |
Update Varnode properties based on (new) Symbol information. More... | |
void | transferVarnodeProperties (Varnode *vn, Varnode *newVn, int4 lsbOffset) |
Copy properties from an existing Varnode to a new Varnode. More... | |
bool | fillinReadOnly (Varnode *vn) |
Replace the given Varnode with its (constant) value in the load image. More... | |
bool | replaceVolatile (Varnode *vn) |
Replace accesses of the given Varnode with volatile operations. More... | |
void | markIndirectOnly (void) |
Mark illegal input Varnodes used only in INDIRECTs. More... | |
void | totalReplace (Varnode *vn, Varnode *newvn) |
Replace all read references to the first Varnode with a second Varnode. More... | |
void | totalReplaceConstant (Varnode *vn, uintb val) |
Replace every read reference of the given Varnode with a constant value. More... | |
ScopeLocal * | getScopeLocal (void) |
Get the local function scope. | |
const ScopeLocal * | getScopeLocal (void) const |
Get the local function scope. | |
FuncProto & | getFuncProto (void) |
Get the function's prototype object. | |
const FuncProto & | getFuncProto (void) const |
Get the function's prototype object. | |
void | initActiveOutput (void) |
void | clearActiveOutput (void) |
Clear any analysis of the function's return prototype. | |
ParamActive * | getActiveOutput (void) const |
Get the return prototype recovery object. | |
void | setHighLevel (void) |
Turn on HighVariable objects for all Varnodes. | |
void | clearDeadVarnodes (void) |
Delete any dead Varnodes. More... | |
void | calcNZMask (void) |
Calculate non-zero masks for all Varnodes. More... | |
void | clearDeadOps (void) |
Delete any dead PcodeOps. | |
void | remapVarnode (Varnode *vn, Symbol *sym, const Address &usepoint) |
Remap a Symbol to a given Varnode using a static mapping. More... | |
void | remapDynamicVarnode (Varnode *vn, Symbol *sym, const Address &usepoint, uint8 hash) |
Remap a Symbol to a given Varnode using a new dynamic mapping. More... | |
void | linkProtoPartial (Varnode *vn) |
Find or create Symbol and a partial mapping. More... | |
Symbol * | linkSymbol (Varnode *vn) |
Find or create Symbol associated with given Varnode. More... | |
Symbol * | linkSymbolReference (Varnode *vn) |
Discover and attach Symbol to a constant reference. More... | |
Varnode * | findLinkedVarnode (SymbolEntry *entry) const |
Find a Varnode matching the given Symbol mapping. More... | |
void | findLinkedVarnodes (SymbolEntry *entry, vector< Varnode *> &res) const |
Find Varnodes that map to the given SymbolEntry. More... | |
void | buildDynamicSymbol (Varnode *vn) |
Build a dynamic Symbol associated with the given Varnode. More... | |
bool | attemptDynamicMapping (SymbolEntry *entry, DynamicHash &dhash) |
Map properties of a dynamic symbol to a Varnode. More... | |
bool | attemptDynamicMappingLate (SymbolEntry *entry, DynamicHash &dhash) |
Map the name of a dynamic symbol to a Varnode. More... | |
Merge & | getMerge (void) |
Get the Merge object for this function. | |
PcodeOp * | newOp (int4 inputs, const Address &pc) |
PcodeOp * | newOp (int4 inputs, const SeqNum &sq) |
Allocate a new PcodeOp with Address. More... | |
PcodeOp * | newOpBefore (PcodeOp *follow, OpCode opc, Varnode *in1, Varnode *in2, Varnode *in3=(Varnode *) 0) |
Allocate a new PcodeOp with sequence number. More... | |
PcodeOp * | cloneOp (const PcodeOp *op, const SeqNum &seq) |
PcodeOp * | getFirstReturnOp (void) const |
Clone a PcodeOp into this function. More... | |
PcodeOp * | newIndirectOp (PcodeOp *indeffect, const Address &addr, int4 sz, uint4 extraFlags) |
Find a representative CPUI_RETURN op for this function. More... | |
PcodeOp * | newIndirectCreation (PcodeOp *indeffect, const Address &addr, int4 sz, bool possibleout) |
Build a CPUI_INDIRECT op that indirectly creates a Varnode. More... | |
void | markIndirectCreation (PcodeOp *indop, bool possibleOutput) |
Convert CPUI_INDIRECT into an indirect creation. More... | |
PcodeOp * | findOp (const SeqNum &sq) |
Find PcodeOp with given sequence number. | |
void | opInsertBefore (PcodeOp *op, PcodeOp *follow) |
Insert given PcodeOp before a specific op. More... | |
void | opInsertAfter (PcodeOp *op, PcodeOp *prev) |
Insert given PcodeOp after a specific op. More... | |
void | opInsertBegin (PcodeOp *op, BlockBasic *bl) |
Insert given PcodeOp at the beginning of a basic block. More... | |
void | opInsertEnd (PcodeOp *op, BlockBasic *bl) |
Insert given PcodeOp at the end of a basic block. More... | |
void | opDeadInsertAfter (PcodeOp *op, PcodeOp *prev) |
Moved given PcodeOp to specified point in the dead list. | |
void | opHeritage (void) |
Perform an entire heritage pass linking Varnode reads to writes. | |
void | opSetOpcode (PcodeOp *op, OpCode opc) |
Set the op-code for a specific PcodeOp. More... | |
void | opMarkHalt (PcodeOp *op, uint4 flag) |
Mark given CPUI_RETURN op as a special halt. More... | |
void | opSetOutput (PcodeOp *op, Varnode *vn) |
Set a specific output Varnode for the given PcodeOp. More... | |
void | opUnsetOutput (PcodeOp *op) |
Remove output Varnode from the given PcodeOp. More... | |
void | opSetInput (PcodeOp *op, Varnode *vn, int4 slot) |
Set a specific input operand for the given PcodeOp. More... | |
void | opSwapInput (PcodeOp *op, int4 slot1, int4 slot2) |
Swap two input operands in the given PcodeOp. More... | |
void | opUnsetInput (PcodeOp *op, int4 slot) |
Clear an input operand slot for the given PcodeOp. More... | |
void | opInsert (PcodeOp *op, BlockBasic *bl, list< PcodeOp *>::iterator iter) |
Insert the given PcodeOp at specific point in a basic block. More... | |
void | opUninsert (PcodeOp *op) |
Remove the given PcodeOp from its basic block. More... | |
void | opUnlink (PcodeOp *op) |
Unset inputs/output and remove given PcodeOP from its basic block. More... | |
void | opDestroy (PcodeOp *op) |
Remove given PcodeOp and destroy its Varnode operands. More... | |
void | opDestroyRaw (PcodeOp *op) |
Remove the given raw PcodeOp. More... | |
void | opDeadAndGone (PcodeOp *op) |
Free resources for the given dead PcodeOp. | |
void | opSetAllInput (PcodeOp *op, const vector< Varnode *> &vvec) |
Set all input Varnodes for the given PcodeOp simultaneously. More... | |
void | opRemoveInput (PcodeOp *op, int4 slot) |
Remove a specific input slot for the given PcodeOp. More... | |
void | opInsertInput (PcodeOp *op, Varnode *vn, int4 slot) |
Insert a new Varnode into the operand list for the given PcodeOp. More... | |
void | opMarkStartBasic (PcodeOp *op) |
Mark PcodeOp as starting a basic block. | |
void | opMarkStartInstruction (PcodeOp *op) |
Mark PcodeOp as starting its instruction. | |
void | opMarkNonPrinting (PcodeOp *op) |
Mark PcodeOp as not being printed. | |
void | opMarkSpecialPrint (PcodeOp *op) |
Mark PcodeOp as needing special printing. | |
void | opMarkNoCollapse (PcodeOp *op) |
Mark PcodeOp as not collapsible. | |
void | opMarkCpoolTransformed (PcodeOp *op) |
Mark cpool record was visited. | |
void | opMarkCalculatedBool (PcodeOp *op) |
Mark PcodeOp as having boolean output. | |
void | opMarkSpacebasePtr (PcodeOp *op) |
Mark PcodeOp as LOAD/STORE from spacebase ptr. | |
void | opClearSpacebasePtr (PcodeOp *op) |
Unmark PcodeOp as using spacebase ptr. | |
void | opFlipCondition (PcodeOp *op) |
Flip output condition of given CBRANCH. | |
PcodeOp * | target (const Address &addr) const |
Look up a PcodeOp by an instruction Address. | |
Varnode * | createStackRef (AddrSpace *spc, uintb off, PcodeOp *op, Varnode *stackptr, bool insertafter) |
Create an INT_ADD PcodeOp calculating an offset to the spacebase register. More... | |
Varnode * | opStackLoad (AddrSpace *spc, uintb off, uint4 sz, PcodeOp *op, Varnode *stackptr, bool insertafter) |
Create a LOAD expression at an offset relative to a spacebase register for a given address space. More... | |
PcodeOp * | opStackStore (AddrSpace *spc, uintb off, PcodeOp *op, bool insertafter) |
Create a STORE expression at an offset relative to a spacebase register for a given address space. More... | |
void | opUndoPtradd (PcodeOp *op, bool finalize) |
Convert a CPUI_PTRADD back into a CPUI_INT_ADD. More... | |
list< PcodeOp * >::const_iterator | beginOp (OpCode opc) const |
Start of PcodeOp objects with the given op-code. | |
list< PcodeOp * >::const_iterator | endOp (OpCode opc) const |
End of PcodeOp objects with the given op-code. | |
list< PcodeOp * >::const_iterator | beginOpAlive (void) const |
Start of PcodeOp objects in the alive list. | |
list< PcodeOp * >::const_iterator | endOpAlive (void) const |
End of PcodeOp objects in the alive list. | |
list< PcodeOp * >::const_iterator | beginOpDead (void) const |
Start of PcodeOp objects in the dead list. | |
list< PcodeOp * >::const_iterator | endOpDead (void) const |
End of PcodeOp objects in the dead list. | |
PcodeOpTree::const_iterator | beginOpAll (void) const |
Start of all (alive) PcodeOp objects sorted by sequence number. | |
PcodeOpTree::const_iterator | endOpAll (void) const |
End of all (alive) PcodeOp objects sorted by sequence number. | |
PcodeOpTree::const_iterator | beginOp (const Address &addr) const |
Start of all (alive) PcodeOp objects attached to a specific Address. | |
PcodeOpTree::const_iterator | endOp (const Address &addr) const |
End of all (alive) PcodeOp objects attached to a specific Address. | |
bool | moveRespectingCover (PcodeOp *op, PcodeOp *lastOp) |
Move given op past lastOp respecting covers if possible. More... | |
const ResolvedUnion * | getUnionField (const Datatype *parent, const PcodeOp *op, int4 slot) const |
Get the resolved union field associated with the given edge. More... | |
bool | setUnionField (const Datatype *parent, const PcodeOp *op, int4 slot, const ResolvedUnion &resolve) |
Associate a union field with the given edge. More... | |
void | forceFacingType (Datatype *parent, int4 fieldNum, PcodeOp *op, int4 slot) |
Force a specific union field resolution for the given edge. More... | |
int4 | inheritResolution (Datatype *parent, const PcodeOp *op, int4 slot, PcodeOp *oldOp, int4 oldSlot) |
Copy a read/write facing resolution for a specific data-type from one PcodeOp to another. More... | |
JumpTable * | linkJumpTable (PcodeOp *op) |
Link jump-table with a given BRANCHIND. More... | |
JumpTable * | findJumpTable (const PcodeOp *op) const |
Find a jump-table associated with a given BRANCHIND. More... | |
JumpTable * | installJumpTable (const Address &addr) |
Install a new jump-table for the given Address. More... | |
JumpTable * | recoverJumpTable (Funcdata &partial, PcodeOp *op, FlowInfo *flow, int4 &failuremode) |
Recover control-flow destinations for a BRANCHIND. More... | |
bool | earlyJumpTableFail (PcodeOp *op) |
Try to determine, early, if jump-table analysis will fail. More... | |
int4 | numJumpTables (void) const |
Get the number of jump-tables for this function. | |
JumpTable * | getJumpTable (int4 i) |
Get the i-th jump-table. | |
void | removeJumpTable (JumpTable *jt) |
Remove/delete the given jump-table. More... | |
BlockGraph & | getStructure (void) |
Get the current control-flow structuring hierarchy. | |
const BlockGraph & | getStructure (void) const |
Get the current control-flow structuring hierarchy. | |
const BlockGraph & | getBasicBlocks (void) const |
Get the basic blocks container. | |
void | setBasicBlockRange (BlockBasic *bb, const Address &beg, const Address &end) |
Set the initial ownership range for the given basic block. More... | |
void | removeDoNothingBlock (BlockBasic *bb) |
Remove a basic block from control-flow that performs no operations. More... | |
bool | removeUnreachableBlocks (bool issuewarning, bool checkexistence) |
Remove any unreachable basic blocks. More... | |
void | pushBranch (BlockBasic *bb, int4 slot, BlockBasic *bbnew) |
Move a control-flow edge from one block to another. More... | |
void | removeBranch (BlockBasic *bb, int4 num) |
Remove the indicated branch from a basic block. More... | |
BlockBasic * | nodeJoinCreateBlock (BlockBasic *block1, BlockBasic *block2, BlockBasic *exita, BlockBasic *exitb, bool fora_block1ishigh, bool forb_block1ishigh, const Address &addr) |
Create a new basic block for holding a merged CBRANCH. More... | |
void | nodeSplit (BlockBasic *b, int4 inedge) |
Split control-flow into a basic block, duplicating its p-code into a new block. More... | |
bool | forceGoto (const Address &pcop, const Address &pcdest) |
Force a specific control-flow edge to be marked as unstructured. More... | |
void | removeFromFlowSplit (BlockBasic *bl, bool swap) |
Remove a basic block splitting its control-flow into two distinct paths. More... | |
void | switchEdge (FlowBlock *inblock, BlockBasic *outbefore, FlowBlock *outafter) |
Switch an outgoing edge from the given source block to flow into another block. More... | |
void | spliceBlockBasic (BlockBasic *bl) |
Merge the given basic block with the block it flows into. More... | |
void | installSwitchDefaults (void) |
Make sure default switch cases are properly labeled. | |
bool | replaceLessequal (PcodeOp *op) |
Replace INT_LESSEQUAL and INT_SLESSEQUAL expressions. More... | |
bool | distributeIntMultAdd (PcodeOp *op) |
Distribute constant coefficient to additive input. More... | |
bool | collapseIntMultMult (Varnode *vn) |
Collapse constant coefficients for two chained CPUI_INT_MULT. More... | |
Static Public Member Functions | |
static bool | compareCallspecs (const FuncCallSpecs *a, const FuncCallSpecs *b) |
Compare call specification objects by call site address. More... | |
Private Types | |
enum | { highlevel_on = 1, blocks_generated = 2, blocks_unreachable = 4, processing_started = 8, processing_complete = 0x10, typerecovery_on = 0x20, typerecovery_start = 0x40, no_code = 0x80, jumptablerecovery_on = 0x100, jumptablerecovery_dont = 0x200, restart_pending = 0x400, unimplemented_present = 0x800, baddata_present = 0x1000, double_precis_on = 0x2000 } |
Private Member Functions | |
void | setVarnodeProperties (Varnode *vn) const |
Look-up boolean properties and data-type information. More... | |
HighVariable * | assignHigh (Varnode *vn) |
Assign a new HighVariable to a Varnode. More... | |
Symbol * | handleSymbolConflict (SymbolEntry *entry, Varnode *vn) |
Handle two variables with matching storage. More... | |
bool | syncVarnodesWithSymbol (VarnodeLocSet::const_iterator &iter, uint4 fl, Datatype *ct) |
Update properties (and the data-type) for a set of Varnodes associated with one Symbol. More... | |
bool | descend2Undef (Varnode *vn) |
Transform all reads of the given Varnode to a special undefined constant. More... | |
void | splitUses (Varnode *vn) |
Make all reads of the given Varnode unique. More... | |
Varnode * | cloneVarnode (const Varnode *vn) |
Clone a Varnode (between copies of the function) More... | |
void | destroyVarnode (Varnode *vn) |
Delete the given Varnode from this function. More... | |
void | coverVarnodes (SymbolEntry *entry, vector< Varnode *> &list) |
Make sure every Varnode in the given list has a Symbol it will link to. More... | |
bool | applyUnionFacet (SymbolEntry *entry, DynamicHash &dhash) |
Cache information from a UnionFacetSymbol. More... | |
void | opZeroMulti (PcodeOp *op) |
Transform trivial CPUI_MULTIEQUAL to CPUI_COPY. More... | |
void | blockRemoveInternal (BlockBasic *bb, bool unreachable) |
Remove an active basic block from the function. More... | |
void | branchRemoveInternal (BlockBasic *bb, int4 num) |
Remove an outgoing branch of the given basic block. More... | |
void | pushMultiequals (BlockBasic *bb) |
Push MULTIEQUAL Varnodes of the given block into the output block. More... | |
void | clearBlocks (void) |
Clear all basic blocks. | |
void | structureReset (void) |
Calculate initial basic block structures (after a control-flow change) More... | |
int4 | stageJumpTable (Funcdata &partial, JumpTable *jt, PcodeOp *op, FlowInfo *flow) |
Recover a jump-table for a given BRANCHIND using existing flow information. More... | |
void | switchOverJumpTables (const FlowInfo &flow) |
Convert jump-table addresses to basic block indices. More... | |
void | clearJumpTables (void) |
Clear any jump-table information. More... | |
void | sortCallSpecs (void) |
Sort calls using a dominance based order. More... | |
void | deleteCallSpecs (PcodeOp *op) |
Remove the specification for a particular call. More... | |
void | clearCallSpecs (void) |
Remove all call specifications. | |
BlockBasic * | nodeSplitBlockEdge (BlockBasic *b, int4 inedge) |
Split given basic block b along an in edge. More... | |
PcodeOp * | nodeSplitCloneOp (PcodeOp *op) |
Duplicate the given PcodeOp as part of splitting a block. More... | |
void | nodeSplitCloneVarnode (PcodeOp *op, PcodeOp *newop) |
Duplicate output Varnode of the given p-code op, as part of splitting a block. More... | |
void | nodeSplitRawDuplicate (BlockBasic *b, BlockBasic *bprime) |
Clone all p-code ops from a block into its copy. More... | |
void | nodeSplitInputPatch (BlockBasic *b, BlockBasic *bprime, int4 inedge) |
Patch Varnode inputs to p-code ops in split basic block. More... | |
Static Private Member Functions | |
static bool | descendantsOutside (Varnode *vn) |
Check if given Varnode has any descendants in a dead block. More... | |
static void | encodeVarnode (Encoder &encoder, VarnodeLocSet::const_iterator iter, VarnodeLocSet::const_iterator enditer) |
Encode descriptions for a set of Varnodes to a stream. More... | |
static bool | checkIndirectUse (Varnode *vn) |
Check if the given Varnode only flows into call-based INDIRECT ops. More... | |
static PcodeOp * | findPrimaryBranch (PcodeOpTree::const_iterator iter, PcodeOpTree::const_iterator enditer, bool findbranch, bool findcall, bool findreturn) |
Find the primary branch operation for an instruction. More... | |
Private Attributes | |
uint4 | flags |
Boolean properties associated with this function. | |
uint4 | clean_up_index |
Creation index of first Varnode created after start of cleanup. | |
uint4 | high_level_index |
Creation index of first Varnode created after HighVariables are created. | |
uint4 | cast_phase_index |
Creation index of first Varnode created after ActionSetCasts. | |
uint4 | minLanedSize |
Minimum Varnode size to check as LanedRegister. | |
int4 | size |
Number of bytes of binary data in function body. | |
Architecture * | glb |
Global configuration data. | |
FunctionSymbol * | functionSymbol |
The symbol representing this function. | |
string | name |
Name of function. | |
string | displayName |
Name to display in output. | |
Address | baseaddr |
Starting code address of binary data. | |
FuncProto | funcp |
Prototype of this function. | |
ScopeLocal * | localmap |
Local variables (symbols in the function scope) | |
vector< FuncCallSpecs * > | qlst |
List of calls this function makes. | |
vector< JumpTable * > | jumpvec |
List of jump-tables for this function. | |
VarnodeBank | vbank |
Container of Varnode objects for this function. | |
PcodeOpBank | obank |
Container of PcodeOp objects for this function. | |
BlockGraph | bblocks |
Unstructured basic blocks. | |
BlockGraph | sblocks |
Structured block hierarchy (on top of basic blocks) | |
Heritage | heritage |
Manager for maintaining SSA form. | |
Merge | covermerge |
Variable range intersection algorithms. | |
ParamActive * | activeoutput |
Data for assessing which parameters are passed to this function. | |
Override | localoverride |
Overrides of data-flow, prototypes, etc. that are local to this function. | |
map< VarnodeData, const LanedRegister * > | lanedMap |
Current storage locations which may be laned registers. | |
map< ResolveEdge, ResolvedUnion > | unionMap |
A map from data-flow edges to the resolved field of TypeUnion being accessed. | |
Container for data structures associated with a single function.
This class holds the primary data structures for decompiling a function. In particular it holds control-flow, data-flow, and prototype information, plus class instances to help with constructing SSA form, structure control-flow, recover jump-tables, recover parameters, and merge Varnodes. In most cases it acts as the main API for querying and accessing these structures.
Some important groups of public methods include:
|
private |
Enumerator | |
---|---|
highlevel_on | Set if Varnodes have HighVariables assigned. |
blocks_generated | Set if Basic blocks have been generated. |
blocks_unreachable | Set if at least one basic block is currently unreachable. |
processing_started | Set if processing has started. |
processing_complete | Set if processing completed. |
typerecovery_on | Set if data-type analysis will be performed. |
typerecovery_start | Set if data-type recovery is started. |
no_code | Set if there is no code available for this function. |
jumptablerecovery_on | Set if this Funcdata object is dedicated to jump-table recovery. |
jumptablerecovery_dont | Don't try to recover jump-tables, always truncate. |
restart_pending | Analysis must be restarted (because of new override info) |
unimplemented_present | Set if function contains unimplemented instructions. |
baddata_present | Set if function flowed into bad data. |
double_precis_on | Set if we are performing double precision recovery. |
ghidra::Funcdata::Funcdata | ( | const string & | nm, |
const string & | disp, | ||
Scope * | scope, | ||
const Address & | addr, | ||
FunctionSymbol * | sym, | ||
int4 | sz = 0 |
||
) |
Constructor.
nm | is the (base) name of the function |
scope | is Symbol scope associated with the function |
addr | is the entry address for the function |
sym | is the symbol representing the function |
sz | is the number of bytes (of code) in the function body |
References activeoutput, ghidra::Database::attachScope(), baseaddr, cast_phase_index, clean_up_index, displayName, flags, funcp, functionSymbol, ghidra::Scope::getArch(), ghidra::Symbol::getId(), ghidra::Architecture::getMinimumLanedRegisterSize(), ghidra::Address::getOffset(), ghidra::AddrSpaceManager::getStackSpace(), glb, high_level_index, localmap, minLanedSize, name, ghidra::ScopeLocal::resetLocalWindow(), ghidra::FuncProto::setScope(), size, and ghidra::Architecture::symboltab.
void ghidra::Funcdata::adjustInputVarnodes | ( | const Address & | addr, |
int4 | sz | ||
) |
Adjust input Varnodes contained in the given range.
After this call, a single input Varnode will exist that fills the given range. Any previous input Varnodes contained in this range are redefined using a SUBPIECE op off of the new single input. If an overlapping Varnode isn't fully contained an exception is thrown.
addr | is the starting address of the range |
sz | is the number of bytes in the range |
References bblocks, ghidra::VarnodeBank::beginDef(), ghidra::CPUI_SUBPIECE, deleteVarnode(), ghidra::VarnodeBank::endDef(), ghidra::Varnode::getAddr(), getAddress(), ghidra::BlockGraph::getBlock(), ghidra::Address::getOffset(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::input, ghidra::Varnode::isInput(), ghidra::Address::justifiedContain(), newConstant(), newOp(), newVarnode(), newVarnodeOut(), opInsertBegin(), opSetInput(), opSetOpcode(), setInputVarnode(), ghidra::Varnode::setWriteMask(), totalReplace(), and vbank.
Referenced by ghidra::ActionUnjustifiedParams::apply(), and numVarnodes().
bool ghidra::Funcdata::ancestorOpUse | ( | int4 | maxlevel, |
const Varnode * | invn, | ||
const PcodeOp * | op, | ||
ParamTrial & | trial, | ||
int4 | offset, | ||
uint4 | mainFlags | ||
) | const |
Test if the given trial Varnode is likely only used for parameter passing.
Flow is followed from the Varnode itself and from ancestors the Varnode was copied from to see if it hits anything other than the given CALL or RETURN operation.
maxlevel | is the maximum number of times to recurse through ancestor copies |
invn | is the given trial Varnode to test |
op | is the given CALL or RETURN |
trial | is the associated parameter trial object |
offset | is the offset within the current Varnode of the value ultimately copied into the trial |
mainFlags | describes traversals along the path from invn to op |
References ghidra::PcodeOp::clearMark(), ghidra::PcodeOp::code(), ghidra::CPUI_CALL, ghidra::CPUI_CALLIND, ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_INT_REM, ghidra::CPUI_INT_SREM, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_PIECE, ghidra::CPUI_SUBPIECE, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::getSpace(), ghidra::AddrSpace::getType(), ghidra::TraverseNode::indirect, ghidra::IPTR_INTERNAL, ghidra::PcodeOp::isIncidentalCopy(), ghidra::Varnode::isIncidentalCopy(), ghidra::PcodeOp::isIndirectCreation(), ghidra::Varnode::isInput(), ghidra::PcodeOp::isMark(), ghidra::Varnode::isTypeLock(), ghidra::Varnode::isWritten(), ghidra::PcodeOp::numInput(), onlyOpUse(), ghidra::Varnode::overlap(), and ghidra::PcodeOp::setMark().
Referenced by ghidra::ActionReturnRecovery::apply(), ghidra::FuncCallSpecs::checkInputTrialUse(), and clearLanedAccessMap().
|
private |
Cache information from a UnionFacetSymbol.
The symbol forces a particular union field resolution for the associated PcodeOp and slot, which are extracted from the given dynamic SymbolEntry. The resolution is cached in the unionMap so that it will get picked up by resolveInFlow() methods etc.
entry | is the given SymbolEntry |
dhash | is preallocated storage for calculating the dynamic hash |
References ghidra::DynamicHash::findOp(), ghidra::SymbolEntry::getFirstUseAddress(), ghidra::SymbolEntry::getHash(), ghidra::DynamicHash::getSlotFromHash(), ghidra::SymbolEntry::getSymbol(), ghidra::Symbol::getType(), glb, ghidra::ResolvedUnion::setLock(), setUnionField(), and ghidra::Architecture::types.
Referenced by attemptDynamicMapping(), and attemptDynamicMappingLate().
|
private |
Assign a new HighVariable to a Varnode.
If HighVariables are enabled, make sure the given Varnode has one assigned. Allocate a dedicated HighVariable, that contains only the one Varnode if necessary.
vn | is the given Varnode |
References ghidra::Varnode::calcCover(), flags, ghidra::Varnode::hasCover(), highlevel_on, and ghidra::Varnode::isAnnotation().
Referenced by newCodeRef(), newConstant(), newUnique(), newUniqueOut(), newVarnode(), newVarnodeCallSpecs(), newVarnodeIop(), newVarnodeOut(), newVarnodeSpace(), and setHighLevel().
bool ghidra::Funcdata::attemptDynamicMapping | ( | SymbolEntry * | entry, |
DynamicHash & | dhash | ||
) |
Map properties of a dynamic symbol to a Varnode.
Given a dynamic mapping, try to find the mapped Varnode, then adjust (type and flags) to reflect this mapping.
entry | is the (dynamic) Symbol entry |
dhash | is the dynamic mapping information |
References applyUnionFacet(), ghidra::DynamicHash::clear(), ghidra::Symbol::equate, ghidra::DynamicHash::findVarnode(), ghidra::Symbol::getCategory(), ghidra::SymbolEntry::getFirstUseAddress(), ghidra::SymbolEntry::getHash(), ghidra::Symbol::getScope(), ghidra::SymbolEntry::getSize(), ghidra::Varnode::getSize(), ghidra::SymbolEntry::getSymbol(), ghidra::Varnode::getSymbolEntry(), localmap, ghidra::Varnode::setSymbolEntry(), ghidra::Varnode::setSymbolProperties(), and ghidra::Symbol::union_facet.
Referenced by ghidra::ActionDynamicMapping::apply(), and clearDeadOps().
bool ghidra::Funcdata::attemptDynamicMappingLate | ( | SymbolEntry * | entry, |
DynamicHash & | dhash | ||
) |
Map the name of a dynamic symbol to a Varnode.
Given a dynamic mapping, try to find the mapped Varnode, then attach the Symbol to the Varnode. The name of the Symbol is used, but the data-type and possibly other properties are not put on the Varnode.
entry | is the (dynamic) Symbol entry |
dhash | is the dynamic mapping information |
References applyUnionFacet(), ghidra::DynamicHash::clear(), ghidra::PcodeOp::code(), ghidra::CPUI_CAST, ghidra::Symbol::equate, ghidra::DynamicHash::findVarnode(), ghidra::Symbol::getCategory(), ghidra::Varnode::getDef(), ghidra::SymbolEntry::getFirstUseAddress(), ghidra::SymbolEntry::getHash(), ghidra::PcodeOp::getIn(), ghidra::Symbol::getName(), ghidra::PcodeOp::getOut(), ghidra::SymbolEntry::getSize(), ghidra::Varnode::getSize(), ghidra::SymbolEntry::getSymbol(), ghidra::Varnode::getSymbolEntry(), ghidra::Varnode::getType(), ghidra::Symbol::getType(), ghidra::Varnode::isExplicit(), ghidra::Varnode::isImplied(), ghidra::Symbol::isNameUndefined(), ghidra::Symbol::isTypeLocked(), ghidra::Varnode::isWritten(), localmap, ghidra::Varnode::loneDescend(), ghidra::ScopeInternal::retypeSymbol(), ghidra::Varnode::setSymbolEntry(), ghidra::Symbol::union_facet, and warningHeader().
Referenced by ghidra::ActionDynamicSymbols::apply(), and clearDeadOps().
|
private |
Remove an active basic block from the function.
PcodeOps in the block are deleted. Data-flow and control-flow are otherwise patched up. Most of the work is patching up MULTIEQUALs and other remaining references to Varnodes flowing through the block to be removed.
If descendant Varnodes are stranded by removing the block, either an exception is thrown, or optionally, the descendant Varnodes can be replaced with constants and a warning is printed.
bb | is the given basic block |
unreachable | is true if the caller wants a warning for stranded Varnodes |
References bblocks, ghidra::BlockBasic::beginOp(), ghidra::PcodeOp::code(), ghidra::CPUI_BRANCHIND, ghidra::CPUI_MULTIEQUAL, deleteCallSpecs(), descend2Undef(), descendantsOutside(), ghidra::BlockBasic::endOp(), findJumpTable(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::FlowBlock::getInIndex(), ghidra::PcodeOp::getOut(), ghidra::FlowBlock::getOut(), ghidra::PcodeOp::getParent(), ghidra::PcodeOp::isAssignment(), ghidra::PcodeOp::isCall(), ghidra::FlowBlock::isDead(), ghidra::Varnode::isWritten(), ghidra::BlockBasic::lastOp(), ghidra::PcodeOp::numInput(), opDestroy(), opInsertInput(), opRemoveInput(), opZeroMulti(), pushMultiequals(), ghidra::BlockGraph::removeBlock(), ghidra::BlockGraph::removeFromFlow(), removeJumpTable(), ghidra::FlowBlock::sizeIn(), ghidra::FlowBlock::sizeOut(), and warningHeader().
Referenced by removeDoNothingBlock(), and removeUnreachableBlocks().
|
private |
Remove an outgoing branch of the given basic block.
MULTIEQUAL p-code ops (in other blocks) that take inputs from the outgoing branch are patched appropriately.
bb | is the given basic block |
num | is the index of the outgoing edge to remove |
References bblocks, ghidra::BlockBasic::beginOp(), ghidra::PcodeOp::code(), ghidra::CPUI_MULTIEQUAL, ghidra::BlockBasic::endOp(), ghidra::FlowBlock::getInIndex(), ghidra::FlowBlock::getOut(), ghidra::BlockBasic::lastOp(), opDestroy(), opRemoveInput(), opZeroMulti(), ghidra::BlockGraph::removeEdge(), and ghidra::FlowBlock::sizeOut().
Referenced by removeBranch(), and removeUnreachableBlocks().
void ghidra::Funcdata::buildDynamicSymbol | ( | Varnode * | vn | ) |
Build a dynamic Symbol associated with the given Varnode.
If a Symbol is already attached, no change is made. Otherwise a special dynamic Symbol is created that is associated with the Varnode via a hash of its local data-flow (rather than its storage address).
vn | is the given Varnode |
References ghidra::Scope::addDynamicSymbol(), ghidra::Scope::addEquateSymbol(), ghidra::Symbol::force_hex, ghidra::DynamicHash::getAddress(), ghidra::Symbol::getFirstWholeMap(), ghidra::DynamicHash::getHash(), ghidra::Varnode::getHigh(), ghidra::Varnode::getOffset(), ghidra::HighVariable::getSymbol(), ghidra::HighVariable::getType(), ghidra::Varnode::isConstant(), isHighOn(), ghidra::Varnode::isNameLock(), ghidra::Varnode::isTypeLock(), localmap, ghidra::Varnode::setSymbolEntry(), and ghidra::DynamicHash::uniqueHash().
Referenced by clearDeadOps(), and handleSymbolConflict().
void ghidra::Funcdata::calcNZMask | ( | void | ) |
Calculate non-zero masks for all Varnodes.
All Varnodes are initialized assuming that all its bits are possibly non-zero. This method looks for situations where a p-code produces a value that is known to have some bits that are guaranteed to be zero. It updates the state of the output Varnode then tries to push the information forward through the data-flow until additional changes are apparent.
References ghidra::Varnode::beginDescend(), beginOpAlive(), ghidra::calc_mask(), ghidra::PcodeOp::clearMark(), ghidra::PcodeOp::code(), ghidra::CPUI_MULTIEQUAL, ghidra::Varnode::endDescend(), endOpAlive(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getNZMaskLocal(), ghidra::Varnode::getOffset(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Varnode::isConstant(), ghidra::PcodeOp::isMark(), ghidra::Varnode::isSpacebase(), ghidra::Varnode::isWritten(), ghidra::Varnode::nzm, and ghidra::PcodeOp::setMark().
Referenced by ghidra::ActionNonzeroMask::apply(), and getActiveOutput().
bool ghidra::Funcdata::checkCallDoubleUse | ( | const PcodeOp * | opmatch, |
const PcodeOp * | op, | ||
const Varnode * | vn, | ||
uint4 | fl, | ||
const ParamTrial & | trial | ||
) | const |
Test for legitimate double use of a parameter trial.
The given trial is a putative input to first CALL, but can also trace its data-flow into a second CALL. Return false if this leads us to conclude that the trial is not a likely parameter.
opmatch | is the first CALL linked to the trial |
op | is the second CALL |
vn | is the Varnode parameter for the second CALL |
fl | indicates what p-code ops were crossed to reach vn |
trial | is the given parameter trial |
References ghidra::PcodeOp::code(), ghidra::CPUI_CALL, ghidra::FuncCallSpecs::getActiveInput(), ghidra::ParamTrial::getAddress(), getCallSpecs(), ghidra::FuncCallSpecs::getEntryAddress(), ghidra::PcodeOp::getIn(), ghidra::SeqNum::getOrder(), ghidra::PcodeOp::getParent(), ghidra::PcodeOp::getSeqNum(), ghidra::PcodeOp::getSlot(), ghidra::ParamActive::getTrialForInputVarnode(), ghidra::TraverseNode::isAlternatePathValid(), and ghidra::FuncCallSpecs::isInputActive().
Referenced by clearLanedAccessMap(), and onlyOpUse().
void ghidra::Funcdata::checkForLanedRegister | ( | int4 | sz, |
const Address & | addr | ||
) |
Check for a potential laned register.
Check if the given storage range is a potential laned register. If so, record the storage with the matching laned register record.
sz | is the size of the storage range in bytes |
addr | is the starting address of the storage range |
References ghidra::Architecture::getLanedRegister(), ghidra::Address::getOffset(), ghidra::Address::getSpace(), glb, lanedMap, ghidra::VarnodeData::offset, ghidra::VarnodeData::size, and ghidra::VarnodeData::space.
Referenced by endDef(), newUnique(), newUniqueOut(), newVarnode(), and newVarnodeOut().
|
staticprivate |
Check if the given Varnode only flows into call-based INDIRECT ops.
Flow is only followed through MULTIEQUAL ops.
vn | is the given Varnode |
References ghidra::Varnode::beginDescend(), ghidra::PcodeOp::code(), ghidra::CPUI_INDIRECT, ghidra::CPUI_MULTIEQUAL, ghidra::Varnode::endDescend(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::isIndirectStore(), ghidra::Varnode::isMark(), and ghidra::Varnode::setMark().
Referenced by markIndirectOnly().
void ghidra::Funcdata::clearDeadVarnodes | ( | void | ) |
Delete any dead Varnodes.
Free any Varnodes not attached to anything. This is only performed at fixed times so that editing operations can detach (and then reattach) Varnodes without losing them.
References ghidra::VarnodeBank::beginLoc(), ghidra::Varnode::clearCover(), ghidra::VarnodeBank::destroy(), ghidra::VarnodeBank::endLoc(), ghidra::Varnode::hasNoDescend(), ghidra::Varnode::isFree(), ghidra::Varnode::isInput(), ghidra::Varnode::isLockedInput(), ghidra::VarnodeBank::makeFree(), and vbank.
Referenced by ghidra::ActionDeadCode::apply(), ghidra::ActionInputPrototype::apply(), and getActiveOutput().
|
private |
Clear any jump-table information.
Any override information is preserved.
References ghidra::JumpTable::clear(), ghidra::JumpTable::isOverride(), and jumpvec.
Referenced by clear().
Make a clone of the given PcodeOp, copying control-flow properties as well. The data-type is not cloned.
op | is the PcodeOp to clone |
seq | is the (possibly custom) sequence number to associate with the clone |
References cloneVarnode(), ghidra::PcodeOp::code(), ghidra::PcodeOp::flags, ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), newOp(), ghidra::PcodeOp::numInput(), opSetInput(), opSetOpcode(), opSetOutput(), ghidra::PcodeOp::setFlag(), ghidra::PcodeOp::startbasic, and ghidra::PcodeOp::startmark.
Referenced by getMerge(), ghidra::FlowInfo::inlineClone(), ghidra::FlowInfo::inlineEZClone(), and truncatedFlow().
Clone a Varnode (between copies of the function)
Internal factory for copying Varnodes from another Funcdata object into this.
vn | is the Varnode to clone |
References ghidra::Varnode::addrforce, ghidra::Varnode::addrtied, ghidra::Varnode::annotation, ghidra::VarnodeBank::create(), ghidra::Varnode::externref, ghidra::Varnode::getAddr(), ghidra::Varnode::getFlags(), ghidra::Varnode::getSize(), ghidra::Varnode::getType(), ghidra::Varnode::incidental_copy, ghidra::Varnode::indirect_creation, ghidra::Varnode::mapped, ghidra::Varnode::persist, ghidra::Varnode::readonly, ghidra::Varnode::setFlags(), vbank, and ghidra::Varnode::volatil.
Referenced by cloneOp().
bool ghidra::Funcdata::collapseIntMultMult | ( | Varnode * | vn | ) |
Collapse constant coefficients for two chained CPUI_INT_MULT.
If:
The constants are combined and true is returned. Otherwise no change is made and false is returned.
vn | is the given Varnode |
References ghidra::calc_mask(), ghidra::PcodeOp::code(), ghidra::CPUI_INT_MULT, ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::isConstant(), ghidra::Varnode::isFree(), ghidra::Varnode::isWritten(), newConstant(), and opSetInput().
Referenced by ghidra::AddTreeState::apply(), and setBasicBlockRange().
|
static |
Compare call specification objects by call site address.
a | is the first call specification to compare |
b | is the second call specification |
References ghidra::FlowBlock::getIndex(), ghidra::FuncCallSpecs::getOp(), ghidra::SeqNum::getOrder(), ghidra::PcodeOp::getParent(), and ghidra::PcodeOp::getSeqNum().
Referenced by setBasicBlockRange(), and sortCallSpecs().
|
private |
Make sure every Varnode in the given list has a Symbol it will link to.
This is used when Varnodes overlap a locked Symbol but extend beyond it. An existing Symbol is passed in with a list of possibly overextending Varnodes. The list is in Address order. We check that each Varnode has a Symbol that overlaps its first byte (to guarantee a link). If one doesn't exist it is created.
entry | is the existing Symbol entry |
list | is the list of Varnodes |
References ghidra::Scope::addSymbol(), ghidra::Scope::findContainer(), ghidra::SymbolEntry::getAddr(), ghidra::Varnode::getAddr(), ghidra::Varnode::getHigh(), ghidra::Symbol::getName(), ghidra::Address::getOffset(), ghidra::Varnode::getOffset(), ghidra::Symbol::getScope(), ghidra::Varnode::getSize(), ghidra::SymbolEntry::getSymbol(), ghidra::HighVariable::getType(), ghidra::Varnode::getUsePoint(), and ghidra::Varnode::isAddrTied().
Referenced by mapGlobals().
Varnode * ghidra::Funcdata::createStackRef | ( | AddrSpace * | spc, |
uintb | off, | ||
PcodeOp * | op, | ||
Varnode * | stackptr, | ||
bool | insertafter | ||
) |
Create an INT_ADD PcodeOp calculating an offset to the spacebase register.
The spacebase register is looked up for the given address space, or an optional previously existing register Varnode can be provided. An insertion point op must be provided, and newly generated ops can come either before or after this insertion point.
spc | is the given address space |
off | is the offset to calculate relative to the spacebase register |
op | is the insertion point PcodeOp |
stackptr | is the spacebase register Varnode (if available) |
insertafter | is true if new ops are inserted after the insertion point |
References ghidra::AddrSpace::byteToAddress(), ghidra::CPUI_INT_ADD, ghidra::CPUI_SEGMENTOP, ghidra::PcodeOp::getAddr(), ghidra::AddrSpace::getAddrSize(), ghidra::SegmentOp::getBaseSize(), ghidra::AddrSpace::getContain(), ghidra::AddrSpace::getIndex(), ghidra::UserOpManage::getSegmentOp(), ghidra::Varnode::getSize(), ghidra::AddrSpace::getWordSize(), glb, newConstant(), newOp(), newSpacebasePtr(), newUniqueOut(), newVarnodeSpace(), opInsertAfter(), opInsertBefore(), opSetInput(), opSetOpcode(), and ghidra::Architecture::userops.
Referenced by opStackLoad(), opStackStore(), and target().
|
inline |
Check if dead code removal is allowed for a specific address space.
spc | is the specific address space |
References ghidra::Heritage::deadRemovalAllowed().
Referenced by ghidra::ActionDeadCode::apply().
|
inline |
Check if dead Varnodes have been removed for a specific address space.
spc | is the specific address space |
References ghidra::Heritage::deadRemovalAllowedSeen().
Referenced by ghidra::RuleEarlyRemoval::applyOp().
uint8 ghidra::Funcdata::decode | ( | Decoder & | decoder | ) |
Restore the state of this function from an XML description.
Parse a <function> element, recovering the name, address, prototype, symbol, jump-table, and override information for this function.
decoder | is the stream decoder |
References ghidra::Database::attachScope(), baseaddr, ghidra::Decoder::closeElement(), ghidra::Override::decode(), ghidra::Address::decode(), ghidra::FuncProto::decode(), decodeJumpTable(), ghidra::Database::decodeScope(), displayName, flags, funcp, ghidra::Database::getGlobalScope(), ghidra::Decoder::getNextAttributeId(), ghidra::AddrSpaceManager::getStackSpace(), glb, localmap, localoverride, name, no_code, ghidra::Decoder::openElement(), ghidra::Decoder::peekElement(), ghidra::Decoder::readBool(), ghidra::Decoder::readSignedInteger(), ghidra::Decoder::readString(), ghidra::Decoder::readUnsignedInteger(), ghidra::ScopeLocal::resetLocalWindow(), ghidra::FuncProto::setScope(), size, and ghidra::Architecture::symboltab.
Referenced by ghidra::FunctionSymbol::decode(), and getCleanUpIndex().
void ghidra::Funcdata::decodeJumpTable | ( | Decoder & | decoder | ) |
Decode jump-tables from a stream.
Parse a <jumptablelist> element and build a JumpTable object for each <jumptable> child element.
decoder | is the stream decoder |
References ghidra::Decoder::closeElement(), ghidra::JumpTable::decode(), glb, jumpvec, ghidra::Decoder::openElement(), and ghidra::Decoder::peekElement().
Referenced by decode(), and getCleanUpIndex().
|
private |
Remove the specification for a particular call.
This is used internally if a CALL is removed (because it is unreachable)
op | is the particular specification to remove |
References ghidra::FuncCallSpecs::getOp(), and qlst.
Referenced by blockRemoveInternal().
|
private |
Transform all reads of the given Varnode to a special undefined constant.
All p-code ops that read the Varnode are transformed so that they read a special constant instead (associate with unreachable block removal).
vn | is the given Varnode |
References ghidra::Varnode::beginDescend(), ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_MULTIEQUAL, ghidra::Varnode::endDescend(), ghidra::PcodeOp::getAddr(), ghidra::FlowBlock::getIn(), ghidra::PcodeOp::getParent(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::BlockBasic::getStart(), ghidra::FlowBlock::isDead(), newConstant(), newOp(), newUniqueOut(), opInsertBefore(), opInsertEnd(), opSetInput(), opSetOpcode(), and ghidra::FlowBlock::sizeIn().
Referenced by blockRemoveInternal().
|
staticprivate |
Check if given Varnode has any descendants in a dead block.
Assuming a basic block is marked dead, return true if any PcodeOp reading the Varnode is in the dead block.
vn | is the given Varnode |
References ghidra::Varnode::beginDescend(), and ghidra::Varnode::endDescend().
Referenced by blockRemoveInternal().
|
private |
Delete the given Varnode from this function.
References to the Varnode are replaced with NULL pointers and the object is freed, with no possibility of resuse.
vn | is the Varnode to delete |
References ghidra::Varnode::beginDescend(), ghidra::PcodeOp::clearInput(), ghidra::Varnode::def, ghidra::VarnodeBank::destroy(), ghidra::Varnode::destroyDescend(), ghidra::Varnode::endDescend(), ghidra::PcodeOp::getSlot(), ghidra::PcodeOp::setOutput(), and vbank.
Referenced by opDestroy(), and opDestroyRaw().
bool ghidra::Funcdata::distributeIntMultAdd | ( | PcodeOp * | op | ) |
Distribute constant coefficient to additive input.
If a term has a multiplicative coefficient, but the underlying term is still additive, in some situations we may need to distribute the coefficient before simplifying further. The given PcodeOp is a INT_MULT where the second input is a constant. We also know the first input is formed with INT_ADD. Distribute the coefficient to the INT_ADD inputs.
op | is the given PcodeOp |
References ghidra::calc_mask(), ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_MULT, ghidra::PcodeOp::getAddr(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Varnode::isConstant(), ghidra::Varnode::isFree(), newConstant(), newOp(), newUniqueOut(), opInsertBefore(), opSetInput(), and opSetOpcode().
Referenced by ghidra::AddTreeState::apply(), ghidra::RuleCollectTerms::applyOp(), and setBasicBlockRange().
void ghidra::Funcdata::doLiveInject | ( | InjectPayload * | payload, |
const Address & | addr, | ||
BlockBasic * | bl, | ||
list< PcodeOp *>::iterator | iter | ||
) |
Inject p-code from a payload into this live function.
Raw PcodeOps are generated from the payload within a given basic block at a specific position in this function.
payload | is the injection payload |
addr | is the address at the point of injection |
bl | is the given basic block holding the new ops |
iter | indicates the point of insertion |
References ghidra::PcodeOpBank::beginDead(), ghidra::PcodeOpBank::endDead(), ghidra::PcodeInjectLibrary::getCachedContext(), glb, ghidra::InjectPayload::inject(), ghidra::PcodeOp::isCallOrBranch(), obank, opInsert(), ghidra::Architecture::pcodeinjectlib, and ghidra::PcodeEmitFd::setFuncdata().
Referenced by ghidra::ActionConstbase::apply(), getCleanUpIndex(), and ghidra::FuncCallSpecs::insertPcode().
bool ghidra::Funcdata::earlyJumpTableFail | ( | PcodeOp * | op | ) |
Try to determine, early, if jump-table analysis will fail.
Backtrack from the BRANCHIND, looking for ops that might affect the destination. If a CALLOTHER, which is not injected/inlined in some way, is in the flow path of the destination calculation, we know the jump-table analysis will fail and return true.
op | is the BRANCHIND op |
References beginOpDead(), ghidra::PcodeOp::binary, ghidra::PcodeOp::code(), ghidra::CPUI_CALLOTHER, ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_SUB, ghidra::CPUI_INT_XOR, ghidra::CPUI_STORE, ghidra::PcodeOp::getEvalType(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::UserOpManage::getOp(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), glb, ghidra::PcodeOp::insertiter, ghidra::Varnode::intersects(), ghidra::PcodeOp::isBranch(), ghidra::PcodeOp::isCall(), ghidra::Varnode::isConstant(), ghidra::PcodeOp::special, ghidra::PcodeOp::unary, and ghidra::Architecture::userops.
Referenced by endOp(), and recoverJumpTable().
void ghidra::Funcdata::encode | ( | Encoder & | encoder, |
uint8 | id, | ||
bool | savetree | ||
) | const |
Encode a description of this function to stream.
A description of this function is written to the stream, including name, address, prototype, symbol, jump-table, and override information. If indicated by the caller, a description of the entire PcodeOp and Varnode tree is also emitted.
encoder | is the stream encoder |
id | is the unique id associated with the function symbol |
savetree | is true if the p-code tree should be emitted |
References baseaddr, ghidra::Encoder::closeElement(), ghidra::Override::encode(), ghidra::Address::encode(), ghidra::FuncProto::encode(), encodeHigh(), encodeJumpTable(), ghidra::Scope::encodeRecursive(), encodeTree(), funcp, glb, hasNoCode(), localmap, localoverride, name, ghidra::Encoder::openElement(), size, ghidra::Encoder::writeBool(), ghidra::Encoder::writeSignedInteger(), ghidra::Encoder::writeString(), and ghidra::Encoder::writeUnsignedInteger().
Referenced by ghidra::FunctionSymbol::encode(), getCleanUpIndex(), and ghidra::DecompileAt::rawAction().
void ghidra::Funcdata::encodeHigh | ( | Encoder & | encoder | ) | const |
Encode a description of all HighVariables to stream.
This produces a single <highlist> element, with a <high> child for each high-level variable (HighVariable) currently associated with this function.
encoder | is the stream encoder |
References beginLoc(), ghidra::HighVariable::clearMark(), ghidra::Encoder::closeElement(), ghidra::HighVariable::encode(), endLoc(), ghidra::Varnode::getHigh(), ghidra::Varnode::isAnnotation(), isHighOn(), ghidra::HighVariable::isMark(), ghidra::Encoder::openElement(), and ghidra::HighVariable::setMark().
Referenced by encode(), and getCleanUpIndex().
void ghidra::Funcdata::encodeJumpTable | ( | Encoder & | encoder | ) | const |
Encode a description of jump-tables to stream.
A <jumptablelist> element is written with <jumptable> children describing each jump-table associated with the control-flow of this function.
encoder | is the stream encoder |
References ghidra::Encoder::closeElement(), jumpvec, and ghidra::Encoder::openElement().
Referenced by encode(), and getCleanUpIndex().
void ghidra::Funcdata::encodeTree | ( | Encoder & | encoder | ) | const |
Encode a description of the p-code tree to stream.
A single <ast> element is produced with children describing Varnodes, PcodeOps, and basic blocks making up this function's current syntax tree.
encoder | is the stream encoder |
References bblocks, ghidra::VarnodeBank::beginLoc(), ghidra::BlockBasic::beginOp(), ghidra::Encoder::closeElement(), ghidra::PcodeOp::encode(), ghidra::BlockBasic::encodeBody(), ghidra::FlowBlock::encodeEdges(), encodeVarnode(), ghidra::VarnodeBank::endLoc(), ghidra::BlockBasic::endOp(), ghidra::BlockGraph::getBlock(), ghidra::FlowBlock::getIndex(), ghidra::BlockGraph::getSize(), ghidra::AddrSpaceManager::getSpace(), ghidra::AddrSpace::getType(), glb, ghidra::IPTR_IOP, ghidra::AddrSpaceManager::numSpaces(), ghidra::Encoder::openElement(), ghidra::FlowBlock::sizeIn(), vbank, and ghidra::Encoder::writeSignedInteger().
Referenced by encode(), and getCleanUpIndex().
|
staticprivate |
Encode descriptions for a set of Varnodes to a stream.
This is an internal function for the function's marshaling system. Individual elements are written in sequence for Varnodes in a given set. The set is bounded by iterators using the 'loc' ordering.
encoder | is the stream encoder |
iter | is the beginning of the set |
enditer | is the end of the set |
References ghidra::Varnode::encode().
Referenced by encodeTree().
int4 ghidra::Funcdata::fillinExtrapop | ( | void | ) |
Recover and return the extrapop for this function.
If extrapop is unknown, recover it from what we know about this function and set the value permanently for this Funcdata object. If there is no function body it may be impossible to know the value, in which case this returns the reserved value indicating extrapop is unknown.
References beginOp(), ghidra::CPUI_RETURN, endOp(), ghidra::ProtoModel::extrapop_unknown, funcp, ghidra::PcodeOp::getAddr(), ghidra::FuncProto::getExtraPop(), glb, hasNoCode(), ghidra::Architecture::loader, ghidra::LoadImage::loadFill(), and ghidra::FuncProto::setExtraPop().
Referenced by getCallSpecs().
bool ghidra::Funcdata::fillinReadOnly | ( | Varnode * | vn | ) |
Replace the given Varnode with its (constant) value in the load image.
Treat the given Varnode as read-only, look up its value in LoadImage and replace read references with the value as a constant Varnode.
vn | is the given Varnode |
References ghidra::Varnode::beginDescend(), ghidra::Varnode::clearFlags(), ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::Varnode::endDescend(), ghidra::PcodeOp::getAddr(), ghidra::Varnode::getAddr(), ghidra::Varnode::getDef(), ghidra::AddrSpace::getName(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::Varnode::getSpace(), ghidra::Varnode::getType(), glb, ghidra::Varnode::hasNoDescend(), ghidra::Varnode::isAddrForce(), ghidra::AddrSpace::isBigEndian(), ghidra::PcodeOp::isMarker(), ghidra::Varnode::isTypeLock(), ghidra::PcodeOp::isWarning(), ghidra::Varnode::isWritten(), ghidra::Architecture::loader, ghidra::LoadImage::loadFill(), newConstant(), opRemoveInput(), opSetInput(), opSetOpcode(), ghidra::Address::printRaw(), ghidra::Varnode::readonly, ghidra::PcodeOp::setAdditionalFlag(), ghidra::Varnode::updateType(), ghidra::PcodeOp::warning, and warning().
Referenced by ghidra::ActionVarnodeProps::apply(), and clearLanedAccessMap().
Find the first input Varnode covered by the given range.
s | is the size of the range in bytes |
loc | is the starting address of the range |
References ghidra::VarnodeBank::findCoveredInput().
Referenced by ghidra::ActionLikelyTrash::apply().
Find the input Varnode that contains the given range.
s | is the size of the range in bytes |
loc | is the starting address of the range |
References ghidra::VarnodeBank::findCoveringInput().
Find range covering given Varnode and any intersecting Varnodes.
Find the minimal Address range covering the given Varnode that doesn't split other Varnodes
vn | is the given Varnode |
sz | is used to pass back the size of the resulting range |
References beginLoc(), endLoc(), ghidra::Varnode::getAddr(), ghidra::Address::getOffset(), ghidra::Varnode::getSize(), and ghidra::Varnode::lociter.
Referenced by deleteVarnode(), ghidra::FuncProto::updateInputNoTypes(), and ghidra::FuncProto::updateInputTypes().
HighVariable * ghidra::Funcdata::findHigh | ( | const string & | nm | ) | const |
Find a high-level variable by name.
Look up the Symbol visible in this function's Scope and return the HighVariable associated with it. If the Symbol doesn't exist or there is no Varnode holding at least part of the value of the Symbol, NULL is returned.
nm | is the name to search for |
References findLinkedVarnode(), ghidra::Symbol::getFirstWholeMap(), ghidra::Varnode::getHigh(), localmap, and ghidra::Scope::queryByName().
Referenced by clearLanedAccessMap().
Find a jump-table associated with a given BRANCHIND.
Look up the jump-table object with the matching PcodeOp address
op | is the given BRANCHIND PcodeOp |
References ghidra::PcodeOp::getAddr(), ghidra::JumpTable::getOpAddress(), and jumpvec.
Referenced by ghidra::ActionDeadCode::apply(), ghidra::RuleSwitchSingle::applyOp(), blockRemoveInternal(), ghidra::FlowInfo::collectEdges(), endOp(), and ghidra::FlowBlock::getJumptable().
Varnode * ghidra::Funcdata::findLinkedVarnode | ( | SymbolEntry * | entry | ) | const |
Find a Varnode matching the given Symbol mapping.
Return the (first) Varnode that matches the given SymbolEntry
entry | is the given SymbolEntry |
References ghidra::VarnodeBank::beginLoc(), ghidra::VarnodeBank::endLoc(), ghidra::DynamicHash::findVarnode(), ghidra::SymbolEntry::getAddr(), ghidra::SymbolEntry::getFirstUseAddress(), ghidra::SymbolEntry::getHash(), ghidra::SymbolEntry::getSize(), ghidra::Varnode::getUsePoint(), ghidra::SymbolEntry::inUse(), ghidra::Varnode::isAddrTied(), ghidra::Varnode::isAnnotation(), ghidra::SymbolEntry::isDynamic(), ghidra::Address::isInvalid(), and vbank.
Referenced by clearDeadOps(), and findHigh().
void ghidra::Funcdata::findLinkedVarnodes | ( | SymbolEntry * | entry, |
vector< Varnode *> & | res | ||
) | const |
Find Varnodes that map to the given SymbolEntry.
Look for Varnodes that are (should be) mapped to the given SymbolEntry and add them to the end of the result list.
entry | is the given SymbolEntry to match |
res | is the container holding the result list of matching Varnodes |
References beginLoc(), endLoc(), ghidra::DynamicHash::findVarnode(), ghidra::SymbolEntry::getAddr(), ghidra::SymbolEntry::getFirstUseAddress(), ghidra::SymbolEntry::getHash(), ghidra::SymbolEntry::getSize(), ghidra::Varnode::getUsePoint(), ghidra::SymbolEntry::inUse(), and ghidra::SymbolEntry::isDynamic().
Referenced by clearDeadOps().
|
staticprivate |
Find the primary branch operation for an instruction.
For machine instructions that branch, this finds the primary PcodeOp that performs the branch. The instruction is provided as a list of p-code ops, and the caller can specify whether they expect to see a branch, call, or return operation.
iter | is the start of the operations for the instruction |
enditer | is the end of the operations for the instruction |
findbranch | is true if the caller expects to see a BRANCH, CBRANCH, or BRANCHIND |
findcall | is true if the caller expects to see CALL or CALLIND |
findreturn | is true if the caller expects to see RETURN |
References ghidra::PcodeOp::code(), ghidra::CPUI_BRANCH, ghidra::CPUI_BRANCHIND, ghidra::CPUI_CALL, ghidra::CPUI_CALLIND, ghidra::CPUI_CBRANCH, ghidra::CPUI_RETURN, ghidra::PcodeOp::getIn(), and ghidra::Varnode::isConstant().
Referenced by overrideFlow().
Given an address space, like stack, that is known to have a base register pointing to it, try to locate the unique Varnode that holds the input value of this register.
id | is the stack like address space |
References ghidra::VarnodeBank::findInput(), ghidra::AddrSpace::getSpacebase(), and vbank.
Referenced by ghidra::ScopeLocal::annotateRawStackPtr(), ghidra::ActionInferTypes::apply(), ghidra::AliasChecker::gatherInternal(), and hasBadData().
Find the input Varnode with the given size and storage address.
s | is the size in bytes |
loc | is the storage address |
References ghidra::VarnodeBank::findInput().
Referenced by ghidra::ActionParamDouble::apply(), ghidra::ActionRestrictLocal::apply(), and ghidra::IfaceDecompData::readVarnode().
|
inline |
Find a defined Varnode via its storage address and its definition address.
s | is the size in bytes |
loc | is the storage address |
pc | is the address where the Varnode is defined |
uniq | is an (optional) sequence number to match |
References ghidra::VarnodeBank::find().
Referenced by ghidra::IfaceDecompData::readVarnode().
Generate raw p-code for the function.
Follow flow from the entry point generating PcodeOps for each instruction encountered. The caller can provide a bounding range that constrains where control can flow to.
baddr | is the beginning of the constraining range |
eaddr | is the end of the constraining range |
References baddata_present, bblocks, blocks_generated, ghidra::PcodeOpBank::empty(), flags, ghidra::Architecture::flowoptions, ghidra::FlowInfo::generateBlocks(), ghidra::FlowInfo::generateOps(), ghidra::FlowInfo::getSize(), glb, ghidra::FlowInfo::hasBadData(), ghidra::FlowInfo::hasUnimplemented(), ghidra::Architecture::max_instructions, obank, qlst, ghidra::FlowInfo::setFlags(), ghidra::FlowInfo::setMaximumInstructions(), ghidra::FlowInfo::setRange(), size, switchOverJumpTables(), and unimplemented_present.
Referenced by ghidra::IfaceDecompData::followFlow(), getCleanUpIndex(), ghidra::IfcCallGraphBuild::iterationCallback(), and startProcessing().
void ghidra::Funcdata::forceFacingType | ( | Datatype * | parent, |
int4 | fieldNum, | ||
PcodeOp * | op, | ||
int4 | slot | ||
) |
Force a specific union field resolution for the given edge.
The parent data-type is taken directly from the given Varnode.
parent | is the parent data-type |
fieldNum | is the index of the field to force |
op | is PcodeOp of the edge |
slot | is -1 for the write edge or >=0 indicating the particular read edge |
References ghidra::Datatype::getMetatype(), ghidra::Datatype::getSize(), ghidra::TypeFactory::getTypePointer(), glb, ghidra::Datatype::isPointerRel(), setUnionField(), ghidra::TYPE_PTR, and ghidra::Architecture::types.
Referenced by ghidra::ActionSetCasts::castInput(), ghidra::ActionSetCasts::castOutput(), and endOp().
Force a specific control-flow edge to be marked as unstructured.
The edge is specified by a source and destination Address (of the branch). The resulting control-flow structure will have a goto statement modeling the edge.
References bblocks, ghidra::PcodeOp::getAddr(), ghidra::BlockGraph::getBlock(), ghidra::FlowBlock::getOut(), ghidra::BlockGraph::getSize(), ghidra::FlowBlock::lastOp(), ghidra::FlowBlock::setGotoBranch(), and ghidra::FlowBlock::sizeOut().
Referenced by ghidra::Override::applyForceGoto(), and setBasicBlockRange().
PcodeOp * ghidra::Funcdata::getFirstReturnOp | ( | void | ) | const |
Clone a PcodeOp into this function.
Return the first CPUI_RETURN operation that is not dead or an artificial halt
References beginOp(), ghidra::CPUI_RETURN, endOp(), ghidra::PcodeOp::getHaltType(), and ghidra::PcodeOp::isDead().
Referenced by ghidra::ActionOutputPrototype::apply(), ghidra::PrintC::emitPrototypeOutput(), and getMerge().
const ResolvedUnion * ghidra::Funcdata::getUnionField | ( | const Datatype * | parent, |
const PcodeOp * | op, | ||
int4 | slot | ||
) | const |
Get the resolved union field associated with the given edge.
If there is no field associated with the edge, null is returned
parent | is the data-type being resolved |
op | is the PcodeOp component of the given edge |
slot | is the slot component of the given edge |
References unionMap.
Referenced by endOp(), ghidra::TypePointer::findResolve(), ghidra::TypeArray::findResolve(), ghidra::TypeStruct::findResolve(), ghidra::TypeUnion::findResolve(), ghidra::TypeUnion::findTruncation(), ghidra::PrintC::opPtrsub(), ghidra::PrintC::pushImpliedField(), ghidra::TypePointer::resolveInFlow(), ghidra::TypeArray::resolveInFlow(), ghidra::TypeStruct::resolveInFlow(), ghidra::TypeUnion::resolveInFlow(), ghidra::TypeUnion::resolveTruncation(), and ghidra::ActionSetCasts::resolveUnion().
|
private |
Handle two variables with matching storage.
A Varnode overlaps the given SymbolEntry. Make sure the Varnode is part of the variable underlying the Symbol. If not, remap things so that the Varnode maps to a distinct Symbol. In either case, attach the appropriate Symbol to the Varnode
entry | is the given SymbolEntry |
vn | is the overlapping Varnode |
References beginLoc(), buildDynamicSymbol(), endLoc(), ghidra::SymbolEntry::getAddr(), ghidra::Varnode::getAddr(), ghidra::Varnode::getHigh(), ghidra::SymbolEntry::getSize(), ghidra::Varnode::getSize(), ghidra::SymbolEntry::getSymbol(), ghidra::Varnode::getSymbolEntry(), ghidra::Varnode::isAddrTied(), ghidra::Varnode::isConstant(), ghidra::SymbolEntry::isDynamic(), ghidra::Varnode::isInput(), ghidra::Varnode::isPersist(), and ghidra::Varnode::setSymbolEntry().
Referenced by linkSymbol().
|
inline |
Does this function need to restart its analysis.
References restart_pending.
Referenced by ghidra::ActionRestartGroup::apply().
|
inline |
Does this function have instructions marked as unimplemented.
References unimplemented_present.
int4 ghidra::Funcdata::inheritResolution | ( | Datatype * | parent, |
const PcodeOp * | op, | ||
int4 | slot, | ||
PcodeOp * | oldOp, | ||
int4 | oldSlot | ||
) |
Copy a read/write facing resolution for a specific data-type from one PcodeOp to another.
parent | is the data-type that needs resolution |
op | is the new reading PcodeOp |
slot | is the new slot (-1 for write, >=0 for read) |
oldOp | is the PcodeOp to inherit the resolution from |
oldSlot | is the old slot (-1 for write, >=0 for read) |
References ghidra::PcodeOp::clearAdditionalFlag(), ghidra::PcodeOp::getAddr(), ghidra::PcodeOp::getTime(), glb, ghidra::PcodeOp::isModified(), ghidra::PcodeOp::modified, ghidra::PcodeOp::printDebug(), ghidra::PcodeOp::setAdditionalFlag(), setUnionField(), size, and unionMap.
Referenced by ghidra::RuleStructOffset0::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::AddTreeState::buildTree(), ghidra::ActionSetCasts::castInput(), ghidra::ActionSetCasts::castOutput(), ghidra::RulePieceStructure::convertZextToPiece(), and endOp().
void ghidra::Funcdata::initActiveOutput | ( | void | ) |
Initialize return prototype recovery analysis
References activeoutput, funcp, ghidra::FuncProto::getMaxOutputDelay(), and ghidra::ParamActive::setMaxPass().
Referenced by ghidra::ActionPrototypeTypes::apply(), and getFuncProto().
In-line the p-code from another function into this function.
Raw PcodeOps for the in-line function are generated and then cloned into this function. Depending on the control-flow complexity of the in-line function, the PcodeOps are injected as if they are all part of the call site address (EZModel), or the PcodeOps preserve their address and extra branch instructions are inserted to integrate control-flow of the in-line into the calling function.
inlinefd | is the function to in-line |
flow | is the flow object being injected |
callop | is the site of the injection |
References baseaddr, bblocks, ghidra::FlowInfo::checkEZModel(), ghidra::Architecture::clearAnalysis(), ghidra::PcodeOp::clearFlag(), ghidra::CPUI_BRANCH, ghidra::PcodeOpBank::endDead(), ghidra::FlowInfo::error_outofbounds, ghidra::FlowInfo::error_reinterpreted, ghidra::FlowInfo::error_unimplemented, ghidra::FlowInfo::flow_forinline, ghidra::FlowInfo::forwardRecursion(), ghidra::FlowInfo::generateOps(), ghidra::PcodeOp::getAddr(), getAddress(), getArch(), ghidra::Address::getSpace(), ghidra::PcodeOpBank::getUniqId(), ghidra::FlowInfo::inlineClone(), ghidra::FlowInfo::inlineEZClone(), ghidra::PcodeOp::isBlockStart(), jumpvec, ghidra::PcodeOpBank::moveSequenceDead(), newCodeRef(), ghidra::PcodeOp::numInput(), obank, opDestroyRaw(), opRemoveInput(), opSetInput(), opSetOpcode(), qlst, ghidra::PcodeOp::setFlag(), ghidra::FlowInfo::setFlags(), ghidra::FlowInfo::setRange(), ghidra::PcodeOpBank::setUniqId(), ghidra::PcodeOp::startbasic, and ghidra::FlowInfo::testHardInlineRestrictions().
Referenced by getCleanUpIndex(), and ghidra::FlowInfo::inlineSubFunction().
Install a new jump-table for the given Address.
The given address must have a BRANCHIND op attached to it. This is suitable for installing an override and must be called before flow has been traced.
addr | is the given Address |
References ghidra::JumpTable::getOpAddress(), glb, isProcStarted(), and jumpvec.
Referenced by endOp().
|
inline |
Check if a specific Varnode has been linked in fully to the syntax tree (SSA)
vn | is the specific Varnode |
References ghidra::Varnode::getAddr(), and ghidra::Heritage::heritagePass().
Referenced by ghidra::cseEliminateList().
Link jump-table with a given BRANCHIND.
Look up the jump-table object with the matching PcodeOp address, then attach the given PcodeOp to it.
op | is the given BRANCHIND PcodeOp |
References ghidra::PcodeOp::getAddr(), ghidra::JumpTable::getOpAddress(), jumpvec, and ghidra::JumpTable::setIndirectOp().
Referenced by endOp(), recoverJumpTable(), and ghidra::FlowInfo::xrefInlinedBranch().
void ghidra::Funcdata::linkProtoPartial | ( | Varnode * | vn | ) |
Find or create Symbol and a partial mapping.
PIECE operations put the given Varnode into a larger structure. Find the resulting whole Varnode, make sure it has a symbol assigned, and then assign the same symbol to the given Varnode piece. If the given Varnode has been merged with something else or the whole Varnode can't be found, do nothing.
References ghidra::HighVariable::establishGroupSymbolOffset(), ghidra::PieceNode::findRoot(), ghidra::Symbol::getFirstWholeMap(), ghidra::Varnode::getHigh(), ghidra::HighVariable::getNameRepresentative(), ghidra::HighVariable::getSymbol(), linkSymbol(), and ghidra::Varnode::setSymbolEntry().
Referenced by clearDeadOps(), and linkSymbol().
Find or create Symbol associated with given Varnode.
The Symbol is really attached to the Varnode's HighVariable (which must exist). The only reason a Symbol doesn't get set is if, the HighVariable is global and there is no pre-existing Symbol. (see mapGlobals())
vn | is the given Varnode |
References ghidra::Scope::addSymbol(), ghidra::Varnode::getAddr(), ghidra::Varnode::getHigh(), ghidra::SymbolEntry::getSymbol(), ghidra::HighVariable::getSymbol(), ghidra::HighVariable::getType(), ghidra::Varnode::getUsePoint(), handleSymbolConflict(), ghidra::Varnode::isAddrTied(), ghidra::Varnode::isPersist(), ghidra::Varnode::isProtoPartial(), linkProtoPartial(), localmap, ghidra::Scope::queryProperties(), and ghidra::Varnode::setSymbolEntry().
Referenced by clearDeadOps(), linkProtoPartial(), and ghidra::ActionNameVars::linkSymbols().
Discover and attach Symbol to a constant reference.
A reference to a symbol (i.e. &varname) is typically stored as a PTRSUB operation, where the first input Varnode is a spacebase Varnode indicating whether the symbol is on the stack or at a global RAM location. The second input Varnode is a constant encoding the address of the symbol. This method takes this constant Varnode, recovers the symbol it is referring to, and stores on the HighVariable object attached to the Varnode.
vn | is the constant Varnode (second input) to a PTRSUB operation |
References ghidra::SymbolEntry::getAddr(), ghidra::PcodeOp::getAddr(), ghidra::TypeSpacebase::getAddress(), ghidra::Varnode::getHigh(), ghidra::PcodeOp::getIn(), ghidra::TypeSpacebase::getMap(), ghidra::Datatype::getMetatype(), ghidra::Address::getOffset(), ghidra::SymbolEntry::getOffset(), ghidra::Varnode::getOffset(), ghidra::TypePointer::getPtrTo(), ghidra::Varnode::getSize(), ghidra::SymbolEntry::getSymbol(), ghidra::HighVariable::getType(), ghidra::Address::isInvalid(), ghidra::Varnode::loneDescend(), ghidra::Scope::queryContainer(), ghidra::Varnode::setSymbolReference(), ghidra::TYPE_PTR, and ghidra::TYPE_SPACEBASE.
Referenced by clearDeadOps(), and ghidra::ActionNameVars::linkSpacebaseSymbol().
void ghidra::Funcdata::mapGlobals | ( | void | ) |
Make sure there is a Symbol entry for all global Varnodes.
Search for addrtied Varnodes whose storage falls in the global Scope, then build a new global Symbol if one didn't exist before.
References ghidra::Varnode::addrtied, ghidra::Scope::addSymbol(), ghidra::VarnodeBank::beginLoc(), ghidra::Scope::buildVariableName(), coverVarnodes(), ghidra::Scope::discoverScope(), ghidra::VarnodeBank::endLoc(), ghidra::SymbolEntry::getAddr(), ghidra::Varnode::getAddr(), ghidra::TypeFactory::getBase(), ghidra::Varnode::getHigh(), ghidra::Address::getOffset(), ghidra::SymbolEntry::getSize(), ghidra::Varnode::getSize(), ghidra::Datatype::getSize(), ghidra::Varnode::getSymbolEntry(), ghidra::HighVariable::getType(), glb, ghidra::Varnode::isFree(), ghidra::Varnode::isPersist(), localmap, ghidra::Varnode::persist, ghidra::Scope::queryProperties(), ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, vbank, and warningHeader().
Referenced by ghidra::ActionMapGlobals::apply(), and clearLanedAccessMap().
void ghidra::Funcdata::markIndirectCreation | ( | PcodeOp * | indop, |
bool | possibleOutput | ||
) |
Convert CPUI_INDIRECT into an indirect creation.
Data-flow through the given CPUI_INDIRECT op is marked so that the output Varnode is considered indirectly created. An indirectly created Varnode effectively has no data-flow before the INDIRECT op that defines it, and the value contained by the Varnode is not explicitly calculable.
indop | is the given CPUI_INDIRECT op |
possibleOutput | is true if INDIRECT should be marked as a possible call output |
References ghidra::PcodeOp::flags, ghidra::Varnode::flags, ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::indirect_creation, ghidra::Varnode::indirect_creation, and ghidra::Varnode::isConstant().
Referenced by ghidra::ActionLikelyTrash::apply(), and getMerge().
void ghidra::Funcdata::markIndirectOnly | ( | void | ) |
Mark illegal input Varnodes used only in INDIRECTs.
The illegal inputs are additionally marked as indirectonly and isIndirectOnly() returns true.
References beginDef(), checkIndirectUse(), endDef(), ghidra::Varnode::indirectonly, ghidra::Varnode::input, ghidra::Varnode::isIllegalInput(), and ghidra::Varnode::setFlags().
Referenced by ghidra::ActionMarkIndirectOnly::apply(), and clearLanedAccessMap().
Move given op past lastOp respecting covers if possible.
This routine should be called only after Varnode merging and explicit/implicit attributes have been calculated. Determine if the given op can be moved (only within its basic block) to after lastOp. The output of any PcodeOp moved across must not be involved, directly or indirectly, with any variable in the expression rooted at the given op. If the move is possible, perform the move.
References ghidra::PcodeOp::code(), ghidra::CPUI_CAST, ghidra::CPUI_COPY, ghidra::Varnode::getDef(), ghidra::Varnode::getHigh(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::Varnode::isAddrTied(), ghidra::PcodeOp::isCall(), ghidra::Varnode::isExplicit(), ghidra::HighVariable::isMark(), ghidra::Varnode::isWritten(), ghidra::HighVariable::markExpression(), ghidra::PcodeOp::nextOp(), opInsertAfter(), opUninsert(), and ghidra::PcodeOp::previousOp().
Referenced by endOp(), and ghidra::BlockWhileDo::testTerminal().
Create a code address annotation Varnode.
A reference to a specific Address is encoded in a Varnode. The Varnode is an annotation in the sense that it will hold no value in the data-flow, it will will only hold a reference to an address. This is used specifically by the branch p-code operations to hold destination addresses.
m | is the Address to encode |
References ghidra::Varnode::annotation, assignHigh(), ghidra::VarnodeBank::create(), ghidra::TypeFactory::getTypeCode(), glb, ghidra::Varnode::setFlags(), ghidra::Architecture::types, and vbank.
Referenced by ghidra::RuleSwitchSingle::applyOp(), ghidra::FlowInfo::checkContainedCall(), ghidra::FlowInfo::inlineClone(), inlineFlow(), nodeSplitInputPatch(), numVarnodes(), and replaceVolatile().
Varnode * ghidra::Funcdata::newConstant | ( | int4 | s, |
uintb | constant_val | ||
) |
Create a new constant Varnode.
A Varnode is allocated which represents the indicated constant value. Its storage address is in the constant address space.
s | is the size of the Varnode in bytes |
constant_val | is the indicated constant value |
References assignHigh(), ghidra::VarnodeBank::create(), ghidra::TypeFactory::getBase(), ghidra::AddrSpaceManager::getConstant(), glb, ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and vbank.
Referenced by adjustInputVarnodes(), ghidra::ActionStackPtrFlow::adjustLoad(), ghidra::ActionStackPtrFlow::analyzeExtraPop(), ghidra::ScopeLocal::annotateRawStackPtr(), ghidra::ActionSegmentize::apply(), ghidra::ActionConstbase::apply(), ghidra::ActionPrototypeTypes::apply(), ghidra::ActionExtraPopSetup::apply(), ghidra::ActionLikelyTrash::apply(), ghidra::RuleCollectTerms::applyOp(), ghidra::RuleAndMask::applyOp(), ghidra::RuleAndOrLump::applyOp(), ghidra::RuleNegateIdentity::applyOp(), ghidra::RuleShiftBitops::applyOp(), ghidra::RuleEquality::applyOp(), ghidra::RuleHighOrderAnd::applyOp(), ghidra::RuleLessOne::applyOp(), ghidra::RuleRangeMeld::applyOp(), ghidra::RuleFloatRange::applyOp(), ghidra::RuleAndPiece::applyOp(), ghidra::RuleAndCompare::applyOp(), ghidra::RuleDoubleSub::applyOp(), ghidra::RuleDoubleShift::applyOp(), ghidra::RuleDoubleArithShift::applyOp(), ghidra::RuleConcatShift::applyOp(), ghidra::RuleLeftRight::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleTrivialArith::applyOp(), ghidra::RuleTrivialBool::applyOp(), ghidra::RuleZextEliminate::applyOp(), ghidra::RuleZextSless::applyOp(), ghidra::RuleBitUndistribute::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RuleSborrow::applyOp(), ghidra::RuleTrivialShift::applyOp(), ghidra::RuleSignShift::applyOp(), ghidra::RuleTestSign::applyOp(), ghidra::RuleShift2Mult::applyOp(), ghidra::RuleTransformCpool::applyOp(), ghidra::Rule2Comp2Mult::applyOp(), ghidra::RuleCarryElim::applyOp(), ghidra::RuleSub2Add::applyOp(), ghidra::RuleXorCollapse::applyOp(), ghidra::RuleAddMultCollapse::applyOp(), ghidra::RuleSubExtComm::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleConcatCommute::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleConcatZero::applyOp(), ghidra::RuleConcatLeftShift::applyOp(), ghidra::RuleSubZext::applyOp(), ghidra::RuleSubCancel::applyOp(), ghidra::RuleShiftSub::applyOp(), ghidra::RuleHumptyDumpty::applyOp(), ghidra::RuleDumptyHump::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleLess2Zero::applyOp(), ghidra::RuleLessEqual2Zero::applyOp(), ghidra::RuleSLess2Zero::applyOp(), ghidra::RuleEqual2Constant::applyOp(), ghidra::RuleStructOffset0::applyOp(), ghidra::RuleAddUnsigned::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::RulePtrsubCharConstant::applyOp(), ghidra::RuleSubNormal::applyOp(), ghidra::RuleDivTermAdd::applyOp(), ghidra::RuleDivTermAdd2::applyOp(), ghidra::RuleDivOpt::applyOp(), ghidra::RuleSignDiv2::applyOp(), ghidra::RuleDivChain::applyOp(), ghidra::RuleSignForm::applyOp(), ghidra::RuleSignNearMult::applyOp(), ghidra::RuleModOpt::applyOp(), ghidra::RuleSignMod2nOpt::applyOp(), ghidra::RuleSignMod2Opt::applyOp(), ghidra::RuleSignMod2nOpt2::applyOp(), ghidra::RuleSegment::applyOp(), ghidra::RuleConditionalMove::applyOp(), ghidra::RuleIgnoreNan::applyOp(), ghidra::RuleThreeWayCompare::applyOp(), ghidra::RulePopcountBoolXor::applyOp(), ghidra::RuleOrMultiBool::applyOp(), ghidra::RuleLzcountShiftBool::applyOp(), ghidra::FlowInfo::artificialHalt(), ghidra::AddTreeState::buildDegenerate(), ghidra::AddTreeState::buildExtra(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::AddTreeState::buildMultiples(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::FuncCallSpecs::buildParam(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::AddTreeState::buildTree(), ghidra::FuncCallSpecs::checkInputTrialUse(), collapseIntMultMult(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::RuleConditionalMove::BoolExpress::constructBool(), ghidra::RulePieceStructure::convertZextToPiece(), ghidra::TransformVar::createReplacement(), createStackRef(), ghidra::cseElimination(), descend2Undef(), distributeIntMultAdd(), ghidra::SubvariableFlow::doReplacement(), fillinReadOnly(), ghidra::JumpBasic::foldInOneGuard(), ghidra::SubvariableFlow::getReplaceVarnode(), ghidra::ActionSetCasts::insertPtrsubZero(), ghidra::ActionDeadCode::neverConsumed(), newIndirectCreation(), nodeSplitInputPatch(), numVarnodes(), opSetInput(), opUndoPtradd(), overrideFlow(), ghidra::RulePtrsubCharConstant::pushConstFurther(), ghidra::RulePullsubMulti::replaceDescendants(), replaceLessequal(), replaceVolatile(), spacebaseConstant(), totalReplaceConstant(), ghidra::RulePtrFlow::truncatePointer(), and ghidra::SegmentOp::unify().
PcodeOp * ghidra::Funcdata::newIndirectCreation | ( | PcodeOp * | indeffect, |
const Address & | addr, | ||
int4 | sz, | ||
bool | possibleout | ||
) |
Build a CPUI_INDIRECT op that indirectly creates a Varnode.
An indirectly created Varnode effectively has no data-flow before the INDIRECT op that defines it, and the value contained by the Varnode is not explicitly calculable. The new Varnode is allocated with a given storage range.
indeffect | is the p-code causing the indirect effect |
addr | is the starting address of the given storage range |
sz | is the number of bytes in the storage range |
possibleout | is true if the output should be treated as a directwrite. |
References ghidra::CPUI_INDIRECT, ghidra::PcodeOp::flags, ghidra::Varnode::flags, ghidra::PcodeOp::getAddr(), ghidra::PcodeOp::indirect_creation, ghidra::Varnode::indirect_creation, newConstant(), newOp(), newVarnodeIop(), newVarnodeOut(), opInsertBefore(), opSetInput(), and opSetOpcode().
Referenced by ghidra::RulePullsubIndirect::applyOp(), ghidra::FuncCallSpecs::commitNewOutputs(), and getMerge().
PcodeOp * ghidra::Funcdata::newIndirectOp | ( | PcodeOp * | indeffect, |
const Address & | addr, | ||
int4 | sz, | ||
uint4 | extraFlags | ||
) |
Find a representative CPUI_RETURN op for this function.
Create a new CPUI_INDIRECT around a PcodeOp with an indirect effect.
Typically this is used to annotate data-flow, for the given storage range, passing through a CALL or STORE. An output Varnode is automatically created.
indeffect | is the PcodeOp with the indirect effect |
addr | is the starting address of the storage range to protect |
sz | is the number of bytes in the storage range |
extraFlags | are extra boolean properties to put on the INDIRECT |
References ghidra::CPUI_INDIRECT, ghidra::PcodeOp::flags, ghidra::PcodeOp::getAddr(), newOp(), newVarnode(), newVarnodeIop(), newVarnodeOut(), opInsertBefore(), opSetInput(), and opSetOpcode().
Referenced by getMerge().
inputs | is the number of operands the new op will have |
pc | is the Address associated with the new op |
References ghidra::PcodeOpBank::create(), and obank.
Referenced by adjustInputVarnodes(), ghidra::ActionConstbase::apply(), ghidra::ActionPrototypeTypes::apply(), ghidra::ActionExtraPopSetup::apply(), ghidra::RuleCollectTerms::applyOp(), ghidra::RuleOrPredicate::applyOp(), ghidra::RulePullsubMulti::applyOp(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleNotDistribute::applyOp(), ghidra::RuleAndDistribute::applyOp(), ghidra::RuleAndCommute::applyOp(), ghidra::RuleAndPiece::applyOp(), ghidra::RuleAndCompare::applyOp(), ghidra::RuleConcatShift::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleBitUndistribute::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleSignShift::applyOp(), ghidra::RuleShiftPiece::applyOp(), ghidra::RuleSub2Add::applyOp(), ghidra::RuleAddMultCollapse::applyOp(), ghidra::RuleSubExtComm::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleConcatCommute::applyOp(), ghidra::RuleConcatZext::applyOp(), ghidra::RuleZextCommute::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleConcatZero::applyOp(), ghidra::RuleConcatLeftShift::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleCondNegate::applyOp(), ghidra::RulePushPtr::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::RuleSubNormal::applyOp(), ghidra::RuleDivTermAdd::applyOp(), ghidra::RuleDivTermAdd2::applyOp(), ghidra::RuleDivOpt::applyOp(), ghidra::RuleSignNearMult::applyOp(), ghidra::RuleOrMultiBool::applyOp(), ghidra::RuleLzcountShiftBool::applyOp(), ghidra::FlowInfo::artificialHalt(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::FuncCallSpecs::buildParam(), ghidra::ActionReturnRecovery::buildReturnOutput(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::ActionSetCasts::castInput(), ghidra::ActionSetCasts::castOutput(), cloneOp(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::RuleConditionalMove::BoolExpress::constructBool(), ghidra::RuleConditionalMove::constructNegate(), ghidra::TransformOp::createReplacement(), createStackRef(), ghidra::cseElimination(), descend2Undef(), distributeIntMultAdd(), ghidra::SubvariableFlow::doReplacement(), ghidra::RulePushPtr::duplicateNeed(), ghidra::ActionPrototypeTypes::extendInput(), ghidra::ActionFuncLink::funcLinkOutput(), getMerge(), ghidra::FlowInfo::inlineClone(), ghidra::ActionSetCasts::insertPtrsubZero(), newIndirectCreation(), newIndirectOp(), newOpBefore(), nodeSplitCloneOp(), opStackLoad(), opStackStore(), opUndoPtradd(), overrideFlow(), ghidra::ActionConditionalConst::placeCopy(), pushMultiequals(), replaceVolatile(), spacebaseConstant(), ghidra::SplitDatatype::splitCopy(), ghidra::SplitDatatype::splitLoad(), ghidra::SplitDatatype::splitStore(), splitUses(), totalReplaceConstant(), and ghidra::RulePtrFlow::truncatePointer().
PcodeOp * ghidra::Funcdata::newOpBefore | ( | PcodeOp * | follow, |
OpCode | opc, | ||
Varnode * | in1, | ||
Varnode * | in2, | ||
Varnode * | in3 = (Varnode *)0 |
||
) |
Allocate a new PcodeOp with sequence number.
Create new PcodeOp with 2 or 3 given operands.
The new op will have a unique space output Varnode and will be inserted before the given follow op.
follow | is the follow up to insert the new PcodeOp before |
opc | is the op-code of the new PcodeOp |
in1 | is the first operand |
in2 | is the second operand |
in3 | is the optional third param |
References ghidra::PcodeOp::getAddr(), ghidra::Varnode::getSize(), newOp(), newUniqueOut(), opInsertBefore(), opSetInput(), and opSetOpcode().
Referenced by ghidra::ScopeLocal::annotateRawStackPtr(), ghidra::RuleStructOffset0::applyOp(), ghidra::AddTreeState::buildExtra(), ghidra::AddTreeState::buildMultiples(), ghidra::AddTreeState::buildTree(), and getMerge().
Construct a new spacebase register for a given address space.
Given an address space, like stack, that is known to have a base register pointing to it, construct a Varnode representing that register.
id | is the stack like address space |
References ghidra::AddrSpace::getSpacebase(), and newVarnode().
Referenced by createStackRef(), and hasBadData().
Create a new temporary Varnode.
A new temporary register storage location is allocated from the unique address space
s | is the size of the Varnode in bytes |
ct | is an optional data-type to associated with the Varnode |
References assignHigh(), checkForLanedRegister(), ghidra::VarnodeBank::createUnique(), ghidra::Varnode::getAddr(), ghidra::TypeFactory::getBase(), glb, minLanedSize, ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and vbank.
Referenced by ghidra::RuleSubZext::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::ActionSetCasts::castOutput(), ghidra::TransformVar::createReplacement(), ghidra::SubvariableFlow::getReplaceVarnode(), numVarnodes(), pushMultiequals(), ghidra::SubvariableFlow::replaceInput(), and replaceVolatile().
Create a new temporary output Varnode.
Allocate a new register from the unique address space and create a new Varnode object representing it as an output to the given PcodeOp
References assignHigh(), checkForLanedRegister(), ghidra::VarnodeBank::createDefUnique(), ghidra::Varnode::getAddr(), ghidra::TypeFactory::getBase(), glb, minLanedSize, ghidra::PcodeOp::setOutput(), ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and vbank.
Referenced by ghidra::RuleCollectTerms::applyOp(), ghidra::RuleOrPredicate::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleNotDistribute::applyOp(), ghidra::RuleAndDistribute::applyOp(), ghidra::RuleAndCommute::applyOp(), ghidra::RuleAndPiece::applyOp(), ghidra::RuleAndCompare::applyOp(), ghidra::RuleConcatShift::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleBitUndistribute::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleSignShift::applyOp(), ghidra::RuleShiftPiece::applyOp(), ghidra::RuleSub2Add::applyOp(), ghidra::RuleAddMultCollapse::applyOp(), ghidra::RuleSubExtComm::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleConcatCommute::applyOp(), ghidra::RuleConcatZext::applyOp(), ghidra::RuleZextCommute::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleConcatZero::applyOp(), ghidra::RuleConcatLeftShift::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleCondNegate::applyOp(), ghidra::RulePushPtr::applyOp(), ghidra::RuleSubNormal::applyOp(), ghidra::RuleDivTermAdd::applyOp(), ghidra::RuleDivTermAdd2::applyOp(), ghidra::RuleDivOpt::applyOp(), ghidra::RuleSignNearMult::applyOp(), ghidra::RuleOrMultiBool::applyOp(), ghidra::RuleLzcountShiftBool::applyOp(), ghidra::FuncCallSpecs::buildParam(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::RulePushPtr::buildVarnodeOut(), ghidra::RuleSubCommute::cancelExtensions(), ghidra::ActionSetCasts::castInput(), ghidra::RuleConditionalMove::BoolExpress::constructBool(), ghidra::RuleConditionalMove::constructNegate(), ghidra::TransformVar::createReplacement(), createStackRef(), descend2Undef(), distributeIntMultAdd(), ghidra::SubvariableFlow::doReplacement(), ghidra::ActionSetCasts::insertPtrsubZero(), newOpBefore(), numVarnodes(), opStackLoad(), opUndoPtradd(), ghidra::ActionConditionalConst::placeCopy(), replaceVolatile(), spacebaseConstant(), ghidra::SplitDatatype::splitStore(), totalReplaceConstant(), and ghidra::RulePtrFlow::truncatePointer().
Create a new unattached Varnode object.
s | is the size of the new Varnode in bytes |
m | is the storage Address of the Varnode |
ct | is a data-type to associate with the Varnode |
References assignHigh(), checkForLanedRegister(), ghidra::VarnodeBank::create(), ghidra::Varnode::getAddr(), ghidra::TypeFactory::getBase(), ghidra::Varnode::getSize(), glb, localmap, minLanedSize, ghidra::Scope::queryProperties(), ghidra::Varnode::setFlags(), ghidra::Varnode::setSymbolProperties(), ghidra::TYPE_UNKNOWN, ghidra::Varnode::typelock, ghidra::Architecture::types, and vbank.
Referenced by adjustInputVarnodes(), ghidra::ActionPrototypeTypes::apply(), ghidra::ActionExtraPopSetup::apply(), ghidra::ActionInputPrototype::apply(), ghidra::RuleCollapseConstants::applyOp(), ghidra::RuleLoadVarnode::applyOp(), ghidra::RuleEqual2Zero::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::FuncCallSpecs::buildParam(), ghidra::TransformVar::createReplacement(), ghidra::ActionFuncLink::funcLinkInput(), ghidra::ActionFuncLink::funcLinkOutput(), ghidra::SubvariableFlow::getReplaceVarnode(), newIndirectOp(), newSpacebasePtr(), newVarnode(), numVarnodes(), opZeroMulti(), pushMultiequals(), and splitUses().
Varnode * ghidra::Funcdata::newVarnodeCallSpecs | ( | FuncCallSpecs * | fc | ) |
Create a call specification annotation Varnode.
A call specification (FuncCallSpecs) is encoded into an annotation Varnode. The Varnode is used specifically as an input to CPUI_CALL ops to speed up access to their associated call specification.
fc | is the call specification to encode |
References assignHigh(), ghidra::VarnodeBank::create(), ghidra::TypeFactory::getBase(), ghidra::AddrSpaceManager::getFspecSpace(), glb, ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and vbank.
Referenced by ghidra::FuncCallSpecs::deindirect(), numVarnodes(), ghidra::FlowInfo::setupCallindSpecs(), ghidra::FlowInfo::setupCallSpecs(), and truncatedFlow().
Create a PcodeOp annotation Varnode.
Create a special annotation Varnode that holds a pointer reference to a specific PcodeOp. This is used specifically to let a CPUI_INDIRECT op refer to the PcodeOp it is holding an indirect effect for.
op | is the PcodeOp to encode in the annotation |
References assignHigh(), ghidra::VarnodeBank::create(), ghidra::TypeFactory::getBase(), ghidra::AddrSpaceManager::getIopSpace(), glb, ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and vbank.
Referenced by ghidra::ActionExtraPopSetup::apply(), ghidra::RulePullsubIndirect::applyOp(), ghidra::TransformVar::createReplacement(), newIndirectCreation(), newIndirectOp(), and numVarnodes().
Create a new output Varnode.
Create a new Varnode which is already defined as output of a given PcodeOp. This if more efficient as it avoids the initial insertion of the free form of the Varnode into the tree, and queryProperties only needs to be called once.
s | is the size of the new Varnode in bytes |
m | is the storage Address of the Varnode |
op | is the given PcodeOp whose output is created |
References assignHigh(), checkForLanedRegister(), ghidra::VarnodeBank::createDef(), ghidra::PcodeOp::getAddr(), ghidra::TypeFactory::getBase(), glb, localmap, minLanedSize, ghidra::Scope::queryProperties(), ghidra::Varnode::setFlags(), ghidra::PcodeOp::setOutput(), ghidra::Varnode::setSymbolProperties(), ghidra::TYPE_UNKNOWN, ghidra::Varnode::typelock, ghidra::Architecture::types, and vbank.
Referenced by adjustInputVarnodes(), ghidra::ActionConstbase::apply(), ghidra::ActionPrototypeTypes::apply(), ghidra::ActionExtraPopSetup::apply(), ghidra::RulePullsubMulti::applyOp(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleLeftRight::applyOp(), ghidra::RuleStoreVarnode::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::ActionReturnRecovery::buildReturnOutput(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::RulePushPtr::buildVarnodeOut(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::TransformVar::createReplacement(), ghidra::cseElimination(), ghidra::ActionPrototypeTypes::extendInput(), ghidra::ActionFuncLink::funcLinkOutput(), newIndirectCreation(), newIndirectOp(), nodeSplitCloneVarnode(), numVarnodes(), and ghidra::RulePtrFlow::truncatePointer().
Create a constant Varnode referring to an address space.
A reference to a particular address space is encoded as a constant Varnode. These are used for LOAD and STORE p-code ops in particular.
spc | is the address space to encode |
References assignHigh(), ghidra::VarnodeBank::create(), ghidra::AddrSpaceManager::createConstFromSpace(), ghidra::TypeFactory::getBase(), glb, ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and vbank.
Referenced by ghidra::ActionSegmentize::apply(), createStackRef(), numVarnodes(), opStackLoad(), opStackStore(), ghidra::SplitDatatype::splitLoad(), and ghidra::SplitDatatype::splitStore().
BlockBasic * ghidra::Funcdata::nodeJoinCreateBlock | ( | BlockBasic * | block1, |
BlockBasic * | block2, | ||
BlockBasic * | exita, | ||
BlockBasic * | exitb, | ||
bool | fora_block1ishigh, | ||
bool | forb_block1ishigh, | ||
const Address & | addr | ||
) |
Create a new basic block for holding a merged CBRANCH.
This is used by ConditionalJoin to do the low-level control-flow manipulation to merge identical conditional branches. Given basic blocks containing the two CBRANCH ops to merge, the new block gets one of the two out edges from each block, and the remaining out edges are changed to point into the new block.
block1 | is the basic block containing the first CBRANCH to merge |
block2 | is the basic block containing the second CBRANCH |
exita | is the first common exit block for the CBRANCHs |
exitb | is the second common exit block |
fora_block1ishigh | designates which edge is moved for exita |
forb_block1ishigh | designates which edge is moved for exitb |
addr | is the Address associated with (1 of the) CBRANCH ops |
References ghidra::BlockGraph::addEdge(), bblocks, ghidra::FlowBlock::f_joined_block, ghidra::FlowBlock::getOutIndex(), ghidra::BlockGraph::moveOutEdge(), ghidra::BlockGraph::newBlockBasic(), ghidra::BlockGraph::removeEdge(), ghidra::FlowBlock::setFlag(), ghidra::BlockBasic::setInitialRange(), and structureReset().
Referenced by setBasicBlockRange().
void ghidra::Funcdata::nodeSplit | ( | BlockBasic * | b, |
int4 | inedge | ||
) |
Split control-flow into a basic block, duplicating its p-code into a new block.
P-code is duplicated into another block, and control-flow is modified so that the new block takes over flow from one input edge to the original block.
b | is the basic block to be duplicated and split |
inedge | is the index of the input edge to move to the duplicate block |
References ghidra::FlowBlock::clearMark(), ghidra::FlowBlock::getIn(), ghidra::FlowBlock::isMark(), nodeSplitBlockEdge(), nodeSplitInputPatch(), nodeSplitRawDuplicate(), ghidra::FlowBlock::setMark(), ghidra::FlowBlock::sizeIn(), ghidra::FlowBlock::sizeOut(), and structureReset().
Referenced by ghidra::ActionReturnSplit::apply(), and setBasicBlockRange().
|
private |
Split given basic block b along an in edge.
A copy of the block is made, inheriting the same out edges but only the one indicated in edge, which is removed from the original block. Other data-flow is not affected.
b | is the given basic block |
inedge | is the index of the indicated in edge |
References ghidra::BlockGraph::addEdge(), bblocks, ghidra::BlockBasic::copyRange(), ghidra::FlowBlock::f_duplicate_block, ghidra::FlowBlock::getIn(), ghidra::FlowBlock::getOut(), ghidra::BlockGraph::newBlockBasic(), ghidra::FlowBlock::setFlag(), ghidra::FlowBlock::sizeOut(), and ghidra::BlockGraph::switchEdge().
Referenced by nodeSplit().
Duplicate the given PcodeOp as part of splitting a block.
Make a basic clone of the p-code op copying its basic control-flow properties
op | is the given PcodeOp |
References ghidra::PcodeOp::code(), ghidra::CPUI_BRANCH, ghidra::PcodeOp::flags, ghidra::PcodeOp::getAddr(), ghidra::PcodeOp::isBranch(), newOp(), ghidra::PcodeOp::nocollapse, ghidra::PcodeOp::numInput(), opSetOpcode(), ghidra::PcodeOp::setFlag(), ghidra::PcodeOp::startbasic, and ghidra::PcodeOp::startmark.
Referenced by nodeSplitRawDuplicate().
Duplicate output Varnode of the given p-code op, as part of splitting a block.
Make a basic clone of the Varnode and its basic flags. The clone is created as an output of a previously cloned PcodeOp.
op | is the given op whose output should be cloned |
newop | is the cloned version |
References ghidra::Varnode::addrforce, ghidra::Varnode::addrtied, ghidra::Varnode::externref, ghidra::Varnode::getAddr(), ghidra::Varnode::getFlags(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::Varnode::incidental_copy, newVarnodeOut(), ghidra::Varnode::persist, ghidra::Varnode::readonly, ghidra::Varnode::setFlags(), and ghidra::Varnode::volatil.
Referenced by nodeSplitRawDuplicate().
|
private |
Patch Varnode inputs to p-code ops in split basic block.
Map Varnodes that are inputs for PcodeOps in the original basic block to the input slots of the cloned ops in the split block. Constants and code ref Varnodes need to be duplicated, other Varnodes are shared between the ops. This routine also pulls an input Varnode out of riginal MULTIEQUAL ops and adds it back to the cloned MULTIEQUAL ops.
b | is the original basic block |
bprime | is the split clone of the block |
inedge | is the incoming edge index that was split on |
References ghidra::BlockBasic::beginOp(), ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_MULTIEQUAL, ghidra::BlockBasic::endOp(), ghidra::Varnode::getAddr(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::getParent(), ghidra::Varnode::getSize(), ghidra::Varnode::isAnnotation(), ghidra::PcodeOp::isCall(), ghidra::Varnode::isConstant(), ghidra::Varnode::isFree(), ghidra::Varnode::isWritten(), newCodeRef(), newConstant(), ghidra::PcodeOp::numInput(), opRemoveInput(), opSetInput(), opSetOpcode(), and ghidra::PcodeOp::setNumInputs().
Referenced by nodeSplit().
|
private |
Clone all p-code ops from a block into its copy.
P-code in a basic block is cloned into the split version of the block. Only the output Varnodes are cloned, not the inputs.
b | is the original basic block |
bprime | is the cloned block |
References ghidra::BlockBasic::beginOp(), ghidra::BlockBasic::endOp(), nodeSplitCloneOp(), nodeSplitCloneVarnode(), and opInsertEnd().
Referenced by nodeSplit().
|
inline |
Get the number of heritage passes performed for the given address space.
spc | is the address space |
References ghidra::Heritage::numHeritagePasses().
Referenced by ghidra::ActionConditionalConst::apply().
bool ghidra::Funcdata::onlyOpUse | ( | const Varnode * | invn, |
const PcodeOp * | opmatch, | ||
const ParamTrial & | trial, | ||
uint4 | mainFlags | ||
) | const |
Test if the given Varnode seems to only be used by a CALL.
Part of testing whether a Varnode makes sense as parameter passing storage is looking for different explicit uses.
invn | is the given Varnode |
opmatch | is the putative CALL op using the Varnode for parameter passing |
trial | is the parameter trial object associated with the Varnode |
mainFlags | are flags describing traversals along the main path, from invn to opmatch |
References ghidra::TraverseNode::actionalt, activeoutput, checkCallDoubleUse(), ghidra::Varnode::clearMark(), ghidra::PcodeOp::code(), ghidra::TraverseNode::concat_high, ghidra::CPUI_BRANCH, ghidra::CPUI_BRANCHIND, ghidra::CPUI_CALL, ghidra::CPUI_CALLIND, ghidra::CPUI_CAST, ghidra::CPUI_CBRANCH, ghidra::CPUI_COPY, ghidra::CPUI_INDIRECT, ghidra::CPUI_INT_SEXT, ghidra::CPUI_INT_ZEXT, ghidra::CPUI_LOAD, ghidra::CPUI_MULTIEQUAL, ghidra::CPUI_PIECE, ghidra::CPUI_RETURN, ghidra::CPUI_STORE, ghidra::CPUI_SUBPIECE, ghidra::Varnode::descend, ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::PcodeOp::getOut(), ghidra::ParamTrial::getSlot(), ghidra::Varnode::getSpace(), ghidra::AddrSpace::getType(), ghidra::TraverseNode::indirectalt, ghidra::IPTR_INTERNAL, ghidra::TraverseNode::isAlternatePathValid(), ghidra::PcodeOp::isIncidentalCopy(), ghidra::Varnode::isIncidentalCopy(), ghidra::Varnode::isMark(), ghidra::Varnode::isPersist(), ghidra::TraverseNode::lsb_truncated, and ghidra::Varnode::setMark().
Referenced by ancestorOpUse(), and clearLanedAccessMap().
void ghidra::Funcdata::opDestroy | ( | PcodeOp * | op | ) |
Remove given PcodeOp and destroy its Varnode operands.
All input and output Varnodes to the op are destroyed (their object resources freed), and the op is permanently moved to the dead list. To call this routine, make sure that either:
op | is the given PcodeOp |
References destroyVarnode(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::getParent(), ghidra::PcodeOpBank::markDead(), ghidra::PcodeOp::numInput(), obank, opUnsetInput(), and ghidra::BlockBasic::removeOp().
Referenced by ghidra::FuncCallSpecs::abortSpacebaseRelative(), ghidra::ActionDeadCode::apply(), ghidra::RuleEarlyRemoval::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RuleMultiCollapse::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RulePushPtr::applyOp(), ghidra::Rule2Comp2Sub::applyOp(), ghidra::RulePtrsubCharConstant::applyOp(), blockRemoveInternal(), branchRemoveInternal(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::AddTreeState::buildTree(), ghidra::cseElimination(), ghidra::RulePushPtr::duplicateNeed(), ghidra::JumpAssisted::foldInNormalization(), ghidra::SplitDatatype::RootPointer::freePointerChain(), ghidra::ActionDeadCode::neverConsumed(), ghidra::opFlipInPlaceExecute(), opHeritage(), ghidra::ActionMultiCse::processBlock(), spliceBlockBasic(), ghidra::SplitDatatype::splitCopy(), ghidra::SplitDatatype::splitLoad(), and ghidra::SplitDatatype::splitStore().
void ghidra::Funcdata::opDestroyRaw | ( | PcodeOp * | op | ) |
Remove the given raw PcodeOp.
This is a specialized routine for deleting an op during flow generation that has been replaced by something else. The op is expected to be dead with none of its inputs or outputs linked to anything else. Both the PcodeOp and all the input/output Varnodes are destroyed.
op | is the given PcodeOp |
References ghidra::PcodeOpBank::destroy(), destroyVarnode(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::PcodeOp::numInput(), and obank.
Referenced by ghidra::FlowInfo::deleteRemainingOps(), ghidra::FlowInfo::doInjection(), inlineFlow(), and opHeritage().
void ghidra::Funcdata::opInsert | ( | PcodeOp * | op, |
BlockBasic * | bl, | ||
list< PcodeOp *>::iterator | iter | ||
) |
Insert the given PcodeOp at specific point in a basic block.
The PcodeOp is removed from the dead list and is inserted immediately before the specified iterator.
op | is the given PcodeOp |
bl | is the basic block being inserted into |
iter | indicates exactly where the op is inserted |
References ghidra::BlockBasic::insert(), ghidra::PcodeOpBank::markAlive(), and obank.
Referenced by doLiveInject(), opHeritage(), opInsertAfter(), opInsertBefore(), opInsertBegin(), opInsertEnd(), ghidra::ActionConditionalConst::placeCopy(), and ghidra::FlowInfo::splitBasic().
Insert given PcodeOp after a specific op.
The given PcodeOp is inserted immediately after the prev op except:
op | is the given PcodeOp to insert |
prev | is the op to insert after |
References ghidra::PcodeOp::code(), ghidra::CPUI_INDIRECT, ghidra::CPUI_MULTIEQUAL, ghidra::BlockBasic::endOp(), ghidra::Varnode::getAddr(), ghidra::PcodeOp::getBasicIter(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOpFromConst(), ghidra::PcodeOp::getParent(), ghidra::Varnode::getSpace(), ghidra::AddrSpace::getType(), ghidra::IPTR_IOP, ghidra::PcodeOp::isDead(), ghidra::PcodeOp::isMarker(), and opInsert().
Referenced by ghidra::ActionExtraPopSetup::apply(), ghidra::RulePushMulti::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::ActionSetCasts::castOutput(), ghidra::FuncCallSpecs::commitNewOutputs(), createStackRef(), ghidra::SubvariableFlow::doReplacement(), ghidra::BlockWhileDo::finalTransform(), findOp(), ghidra::ActionFuncLink::funcLinkOutput(), moveRespectingCover(), opStackLoad(), opStackStore(), replaceVolatile(), ghidra::SplitDatatype::splitStore(), and totalReplaceConstant().
Insert given PcodeOp before a specific op.
The given PcodeOp is inserted immediately before the follow op except:
op | is the given PcodeOp to insert |
follow | is the op to insert before |
References ghidra::BlockBasic::beginOp(), ghidra::PcodeOp::code(), ghidra::CPUI_INDIRECT, ghidra::PcodeOp::getBasicIter(), ghidra::PcodeOp::getParent(), and opInsert().
Referenced by ghidra::ActionExtraPopSetup::apply(), ghidra::RuleCollectTerms::applyOp(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RuleNotDistribute::applyOp(), ghidra::RuleAndDistribute::applyOp(), ghidra::RuleAndCommute::applyOp(), ghidra::RuleAndPiece::applyOp(), ghidra::RuleAndCompare::applyOp(), ghidra::RuleConcatShift::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleBitUndistribute::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleSignShift::applyOp(), ghidra::RuleShiftPiece::applyOp(), ghidra::RuleSub2Add::applyOp(), ghidra::RuleAddMultCollapse::applyOp(), ghidra::RuleSubExtComm::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleConcatCommute::applyOp(), ghidra::RuleConcatZext::applyOp(), ghidra::RuleZextCommute::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleConcatZero::applyOp(), ghidra::RuleConcatLeftShift::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleCondNegate::applyOp(), ghidra::RulePushPtr::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::RuleSubNormal::applyOp(), ghidra::RuleDivTermAdd::applyOp(), ghidra::RuleDivTermAdd2::applyOp(), ghidra::RuleDivOpt::applyOp(), ghidra::RuleSignNearMult::applyOp(), ghidra::RuleOrMultiBool::applyOp(), ghidra::RuleLzcountShiftBool::applyOp(), ghidra::TransformOp::attemptInsertion(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::FuncCallSpecs::buildParam(), ghidra::ActionReturnRecovery::buildReturnOutput(), ghidra::ActionSetCasts::castInput(), ghidra::RuleConditionalMove::BoolExpress::constructBool(), ghidra::RuleConditionalMove::constructNegate(), ghidra::TransformOp::createReplacement(), createStackRef(), descend2Undef(), distributeIntMultAdd(), ghidra::SubvariableFlow::doReplacement(), ghidra::RulePushPtr::duplicateNeed(), findOp(), ghidra::ActionSetCasts::insertPtrsubZero(), newIndirectCreation(), newIndirectOp(), newOpBefore(), opUndoPtradd(), replaceVolatile(), spacebaseConstant(), ghidra::SplitDatatype::splitCopy(), ghidra::SplitDatatype::splitLoad(), ghidra::SplitDatatype::splitStore(), splitUses(), and ghidra::RulePtrFlow::truncatePointer().
void ghidra::Funcdata::opInsertBegin | ( | PcodeOp * | op, |
BlockBasic * | bl | ||
) |
Insert given PcodeOp at the beginning of a basic block.
The given PcodeOp is inserted as the first op in the basic block except:
op | is the given PcodeOp to insert |
bl | is the basic block to insert into |
References ghidra::BlockBasic::beginOp(), ghidra::PcodeOp::code(), ghidra::CPUI_MULTIEQUAL, ghidra::BlockBasic::endOp(), and opInsert().
Referenced by adjustInputVarnodes(), ghidra::ActionConstbase::apply(), ghidra::ActionPrototypeTypes::apply(), ghidra::RuleOrPredicate::applyOp(), ghidra::RulePullsubMulti::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleMultiCollapse::applyOp(), ghidra::RuleConditionalMove::applyOp(), ghidra::TransformOp::attemptInsertion(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::TransformOp::createReplacement(), ghidra::ActionPrototypeTypes::extendInput(), findOp(), pushMultiequals(), and totalReplaceConstant().
void ghidra::Funcdata::opInsertEnd | ( | PcodeOp * | op, |
BlockBasic * | bl | ||
) |
Insert given PcodeOp at the end of a basic block.
The given PcodeOp is inserted as the last op in the basic block except:
op | is the given PcodeOp to insert |
bl | is the basic block to insert into |
References ghidra::BlockBasic::beginOp(), ghidra::BlockBasic::endOp(), and opInsert().
Referenced by ghidra::cseElimination(), descend2Undef(), findOp(), and nodeSplitRawDuplicate().
Insert a new Varnode into the operand list for the given PcodeOp.
The given Varnode is set into the given operand slot. Any existing input Varnodes with slot indices equal to or greater than the specified slot are pushed into the next slot.
op | is the given PcodeOp |
vn | is the given Varnode to insert |
slot | is the input index to insert at |
References ghidra::PcodeOp::insertInput(), and opSetInput().
Referenced by ghidra::ActionPrototypeTypes::apply(), ghidra::ActionParamDouble::apply(), ghidra::RuleNotDistribute::applyOp(), ghidra::RuleTransformCpool::applyOp(), ghidra::Rule2Comp2Mult::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleSubZext::applyOp(), blockRemoveInternal(), ghidra::RulePieceStructure::convertZextToPiece(), ghidra::FuncCallSpecs::createPlaceholder(), ghidra::TransformOp::createReplacement(), ghidra::ActionFuncLink::funcLinkInput(), opDeadAndGone(), and opZeroMulti().
void ghidra::Funcdata::opMarkHalt | ( | PcodeOp * | op, |
uint4 | flag | ||
) |
Mark given CPUI_RETURN op as a special halt.
op | is the given CPUI_RETURN op |
flag | is one of halt, badinstruction, unimplemented, noreturn, or missing. |
References ghidra::PcodeOp::badinstruction, ghidra::PcodeOp::code(), ghidra::CPUI_RETURN, ghidra::PcodeOp::halt, ghidra::PcodeOp::missing, ghidra::PcodeOp::noreturn, ghidra::PcodeOp::setFlag(), and ghidra::PcodeOp::unimplemented.
Referenced by ghidra::FlowInfo::artificialHalt(), and opHeritage().
void ghidra::Funcdata::opRemoveInput | ( | PcodeOp * | op, |
int4 | slot | ||
) |
Remove a specific input slot for the given PcodeOp.
The Varnode in the specified slot is unlinked from the op and the slot itself is removed. The slot index for any remaining input Varnodes coming after the specified slot is decreased by one.
op | is the given PcodeOp |
slot | is the index of the specified slot to remove |
References opUnsetInput(), and ghidra::PcodeOp::removeInput().
Referenced by ghidra::FuncCallSpecs::abortSpacebaseRelative(), ghidra::ActionStackPtrFlow::adjustLoad(), ghidra::ActionSegmentize::apply(), ghidra::ActionSetCasts::apply(), ghidra::ActionParamDouble::apply(), ghidra::RulePiece2Zext::applyOp(), ghidra::RulePiece2Sext::applyOp(), ghidra::RuleOrMask::applyOp(), ghidra::RuleAndMask::applyOp(), ghidra::RuleOrConsume::applyOp(), ghidra::RuleOrCollapse::applyOp(), ghidra::RuleNegateIdentity::applyOp(), ghidra::RuleOrPredicate::applyOp(), ghidra::RuleEquality::applyOp(), ghidra::RuleHighOrderAnd::applyOp(), ghidra::RuleRangeMeld::applyOp(), ghidra::RuleAndZext::applyOp(), ghidra::RuleDoubleShift::applyOp(), ghidra::RuleConcatShift::applyOp(), ghidra::RuleLeftRight::applyOp(), ghidra::RuleLessEqual::applyOp(), ghidra::RuleTrivialArith::applyOp(), ghidra::RuleTrivialBool::applyOp(), ghidra::RuleBitUndistribute::applyOp(), ghidra::RuleBooleanNegate::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RuleSborrow::applyOp(), ghidra::RuleTrivialShift::applyOp(), ghidra::RuleIdentityEl::applyOp(), ghidra::RuleShiftPiece::applyOp(), ghidra::RuleCollapseConstants::applyOp(), ghidra::RuleTransformCpool::applyOp(), ghidra::RuleCarryElim::applyOp(), ghidra::RuleLoadVarnode::applyOp(), ghidra::RuleStoreVarnode::applyOp(), ghidra::RuleSubExtComm::applyOp(), ghidra::RuleConcatZext::applyOp(), ghidra::RuleZextCommute::applyOp(), ghidra::RuleShiftAnd::applyOp(), ghidra::RuleSubCancel::applyOp(), ghidra::RuleHumptyDumpty::applyOp(), ghidra::RuleDumptyHump::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleLess2Zero::applyOp(), ghidra::RuleLessEqual2Zero::applyOp(), ghidra::RuleMultNegOne::applyOp(), ghidra::RulePtrsubCharConstant::applyOp(), ghidra::RuleSubNormal::applyOp(), ghidra::RuleSegment::applyOp(), ghidra::RuleConditionalMove::applyOp(), ghidra::RuleIgnoreNan::applyOp(), ghidra::RuleFuncPtrEncoding::applyOp(), ghidra::RulePopcountBoolXor::applyOp(), ghidra::RuleOrMultiBool::applyOp(), ghidra::RuleXorSwap::applyOp(), ghidra::RuleLzcountShiftBool::applyOp(), blockRemoveInternal(), branchRemoveInternal(), ghidra::RuleOrPredicate::checkSingle(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::TransformOp::createReplacement(), ghidra::SubvariableFlow::doReplacement(), fillinReadOnly(), inlineFlow(), nodeSplitInputPatch(), opDeadAndGone(), opUndoPtradd(), ghidra::FuncCallSpecs::paramshiftModifyStop(), pushBranch(), ghidra::RulePtrsubCharConstant::pushConstFurther(), and ghidra::RulePullsubMulti::replaceDescendants().
Set all input Varnodes for the given PcodeOp simultaneously.
All previously existing input Varnodes are unset. The input slots for the op are resized and then filled in from the specified array.
op | is the given PcodeOp to set |
vvec | is the specified array of new input Varnodes |
References ghidra::PcodeOp::getIn(), ghidra::PcodeOp::numInput(), opSetInput(), opUnsetInput(), and ghidra::PcodeOp::setNumInputs().
Referenced by ghidra::ActionStackPtrFlow::analyzeExtraPop(), ghidra::ActionShadowVar::apply(), ghidra::RulePullsubMulti::applyOp(), ghidra::RuleMultiCollapse::applyOp(), ghidra::AddTreeState::buildDegenerate(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::ActionReturnRecovery::buildReturnOutput(), ghidra::FuncCallSpecs::commitNewInputs(), ghidra::SubvariableFlow::doReplacement(), opDeadAndGone(), and pushMultiequals().
Set a specific input operand for the given PcodeOp.
op | is the given PcodeOp |
vn | is the operand Varnode to set |
slot | is the input slot where the Varnode is placed |
References ghidra::Varnode::addDescend(), ghidra::Varnode::copySymbol(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::hasNoDescend(), ghidra::Varnode::isConstant(), ghidra::Varnode::isSpacebase(), newConstant(), opUnsetInput(), and ghidra::PcodeOp::setInput().
Referenced by adjustInputVarnodes(), ghidra::ActionStackPtrFlow::adjustLoad(), ghidra::ScopeLocal::annotateRawStackPtr(), ghidra::ActionSegmentize::apply(), ghidra::ActionConstbase::apply(), ghidra::ActionPrototypeTypes::apply(), ghidra::ActionExtraPopSetup::apply(), ghidra::ActionParamDouble::apply(), ghidra::ActionLikelyTrash::apply(), ghidra::RuleCollectTerms::applyOp(), ghidra::RuleOrMask::applyOp(), ghidra::RuleAndMask::applyOp(), ghidra::RuleAndOrLump::applyOp(), ghidra::RuleNegateIdentity::applyOp(), ghidra::RuleShiftBitops::applyOp(), ghidra::RuleRightShiftAnd::applyOp(), ghidra::RuleOrPredicate::applyOp(), ghidra::RuleEquality::applyOp(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleNotDistribute::applyOp(), ghidra::RuleHighOrderAnd::applyOp(), ghidra::RuleAndDistribute::applyOp(), ghidra::RuleLessOne::applyOp(), ghidra::RuleRangeMeld::applyOp(), ghidra::RuleFloatRange::applyOp(), ghidra::RuleAndCommute::applyOp(), ghidra::RuleAndPiece::applyOp(), ghidra::RuleAndZext::applyOp(), ghidra::RuleAndCompare::applyOp(), ghidra::RuleDoubleSub::applyOp(), ghidra::RuleDoubleShift::applyOp(), ghidra::RuleDoubleArithShift::applyOp(), ghidra::RuleConcatShift::applyOp(), ghidra::RuleLeftRight::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleLessEqual::applyOp(), ghidra::RuleLessNotEqual::applyOp(), ghidra::RuleTrivialArith::applyOp(), ghidra::RuleTrivialBool::applyOp(), ghidra::RuleZextEliminate::applyOp(), ghidra::RuleZextSless::applyOp(), ghidra::RuleBitUndistribute::applyOp(), ghidra::RuleBooleanNegate::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RuleSborrow::applyOp(), ghidra::RuleTrivialShift::applyOp(), ghidra::RuleSignShift::applyOp(), ghidra::RuleTestSign::applyOp(), ghidra::RuleShift2Mult::applyOp(), ghidra::RuleShiftPiece::applyOp(), ghidra::RuleCollapseConstants::applyOp(), ghidra::RuleTransformCpool::applyOp(), ghidra::RulePropagateCopy::applyOp(), ghidra::RuleCarryElim::applyOp(), ghidra::RuleSub2Add::applyOp(), ghidra::RuleXorCollapse::applyOp(), ghidra::RuleAddMultCollapse::applyOp(), ghidra::RuleLoadVarnode::applyOp(), ghidra::RuleSubExtComm::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleConcatCommute::applyOp(), ghidra::RuleConcatZext::applyOp(), ghidra::RuleZextCommute::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleConcatZero::applyOp(), ghidra::RuleConcatLeftShift::applyOp(), ghidra::RuleSubZext::applyOp(), ghidra::RuleSubCancel::applyOp(), ghidra::RuleShiftSub::applyOp(), ghidra::RuleHumptyDumpty::applyOp(), ghidra::RuleDumptyHump::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleSwitchSingle::applyOp(), ghidra::RuleCondNegate::applyOp(), ghidra::RuleLess2Zero::applyOp(), ghidra::RuleLessEqual2Zero::applyOp(), ghidra::RuleSLess2Zero::applyOp(), ghidra::RuleEqual2Zero::applyOp(), ghidra::RuleEqual2Constant::applyOp(), ghidra::RuleStructOffset0::applyOp(), ghidra::RulePushPtr::applyOp(), ghidra::RuleAddUnsigned::applyOp(), ghidra::Rule2Comp2Sub::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::RulePtrsubCharConstant::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::RuleSubNormal::applyOp(), ghidra::RuleDivTermAdd::applyOp(), ghidra::RuleDivTermAdd2::applyOp(), ghidra::RuleDivOpt::applyOp(), ghidra::RuleSignDiv2::applyOp(), ghidra::RuleDivChain::applyOp(), ghidra::RuleSignForm::applyOp(), ghidra::RuleSignForm2::applyOp(), ghidra::RuleSignNearMult::applyOp(), ghidra::RuleModOpt::applyOp(), ghidra::RuleSignMod2nOpt::applyOp(), ghidra::RuleSignMod2Opt::applyOp(), ghidra::RuleSignMod2nOpt2::applyOp(), ghidra::RuleSegment::applyOp(), ghidra::RuleNegateNegate::applyOp(), ghidra::RuleConditionalMove::applyOp(), ghidra::RuleFloatCast::applyOp(), ghidra::RuleIgnoreNan::applyOp(), ghidra::RuleThreeWayCompare::applyOp(), ghidra::RulePopcountBoolXor::applyOp(), ghidra::RuleOrMultiBool::applyOp(), ghidra::RuleXorSwap::applyOp(), ghidra::RuleLzcountShiftBool::applyOp(), ghidra::FlowInfo::artificialHalt(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::FuncCallSpecs::buildParam(), ghidra::ActionReturnRecovery::buildReturnOutput(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::RuleSubCommute::cancelExtensions(), ghidra::ActionSetCasts::castInput(), ghidra::ActionSetCasts::castOutput(), ghidra::FlowInfo::checkContainedCall(), ghidra::FuncCallSpecs::checkInputTrialUse(), ghidra::RuleOrPredicate::checkSingle(), cloneOp(), collapseIntMultMult(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::RuleConditionalMove::BoolExpress::constructBool(), ghidra::RuleConditionalMove::constructNegate(), createStackRef(), ghidra::cseElimination(), ghidra::FuncCallSpecs::deindirect(), descend2Undef(), distributeIntMultAdd(), ghidra::SubvariableFlow::doReplacement(), ghidra::RulePushPtr::duplicateNeed(), ghidra::ActionPrototypeTypes::extendInput(), fillinReadOnly(), ghidra::JumpBasic::foldInNormalization(), ghidra::JumpAssisted::foldInNormalization(), ghidra::JumpBasic::foldInOneGuard(), ghidra::ActionFuncLink::funcLinkOutput(), ghidra::ActionConditionalConst::handlePhiNodes(), ghidra::FlowInfo::inlineClone(), inlineFlow(), ghidra::ActionSetCasts::insertPtrsubZero(), ghidra::RuleDivOpt::moveSignBitExtraction(), ghidra::ActionDeadCode::neverConsumed(), newIndirectCreation(), newIndirectOp(), newOpBefore(), nodeSplitInputPatch(), ghidra::opFlipInPlaceExecute(), opHeritage(), opInsertInput(), opSetAllInput(), opStackLoad(), opStackStore(), opUndoPtradd(), overrideFlow(), ghidra::ActionConditionalConst::placeCopy(), ghidra::ActionConditionalConst::placeMultipleConstants(), ghidra::ActionConditionalConst::propagateConstant(), ghidra::RulePtrsubCharConstant::pushConstFurther(), pushMultiequals(), ghidra::RulePullsubMulti::replaceDescendants(), replaceLessequal(), replaceVolatile(), ghidra::FlowInfo::setupCallindSpecs(), ghidra::FlowInfo::setupCallSpecs(), spacebaseConstant(), ghidra::SplitDatatype::splitCopy(), ghidra::SplitDatatype::splitLoad(), ghidra::SplitDatatype::splitStore(), splitUses(), totalReplace(), totalReplaceConstant(), truncatedFlow(), and ghidra::RulePtrFlow::truncatePointer().
Set the op-code for a specific PcodeOp.
op | is the given PcodeOp |
opc | is the op-code to set |
References ghidra::PcodeOpBank::changeOpcode(), glb, ghidra::Architecture::inst, and obank.
Referenced by adjustInputVarnodes(), ghidra::ActionStackPtrFlow::adjustLoad(), ghidra::ActionStackPtrFlow::analyzeExtraPop(), ghidra::ActionSegmentize::apply(), ghidra::ActionShadowVar::apply(), ghidra::ActionConstbase::apply(), ghidra::ActionSetCasts::apply(), ghidra::ActionPrototypeTypes::apply(), ghidra::ActionExtraPopSetup::apply(), ghidra::RuleCollectTerms::applyOp(), ghidra::RulePiece2Zext::applyOp(), ghidra::RulePiece2Sext::applyOp(), ghidra::RuleBxor2NotEqual::applyOp(), ghidra::RuleOrMask::applyOp(), ghidra::RuleAndMask::applyOp(), ghidra::RuleOrConsume::applyOp(), ghidra::RuleOrCollapse::applyOp(), ghidra::RuleNegateIdentity::applyOp(), ghidra::RuleOrPredicate::applyOp(), ghidra::RuleEquality::applyOp(), ghidra::RulePullsubMulti::applyOp(), ghidra::RulePullsubIndirect::applyOp(), ghidra::RulePushMulti::applyOp(), ghidra::RuleNotDistribute::applyOp(), ghidra::RuleHighOrderAnd::applyOp(), ghidra::RuleAndDistribute::applyOp(), ghidra::RuleLessOne::applyOp(), ghidra::RuleRangeMeld::applyOp(), ghidra::RuleFloatRange::applyOp(), ghidra::RuleAndCommute::applyOp(), ghidra::RuleAndPiece::applyOp(), ghidra::RuleAndZext::applyOp(), ghidra::RuleAndCompare::applyOp(), ghidra::RuleDoubleShift::applyOp(), ghidra::RuleConcatShift::applyOp(), ghidra::RuleLeftRight::applyOp(), ghidra::RuleShiftCompare::applyOp(), ghidra::RuleLessEqual::applyOp(), ghidra::RuleLessNotEqual::applyOp(), ghidra::RuleTrivialArith::applyOp(), ghidra::RuleTrivialBool::applyOp(), ghidra::RuleSlessToLess::applyOp(), ghidra::RuleZextSless::applyOp(), ghidra::RuleBitUndistribute::applyOp(), ghidra::RuleBooleanNegate::applyOp(), ghidra::RuleBoolZext::applyOp(), ghidra::RuleLogic2Bool::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RuleMultiCollapse::applyOp(), ghidra::RuleSborrow::applyOp(), ghidra::RuleTrivialShift::applyOp(), ghidra::RuleSignShift::applyOp(), ghidra::RuleTestSign::applyOp(), ghidra::RuleIdentityEl::applyOp(), ghidra::RuleShift2Mult::applyOp(), ghidra::RuleShiftPiece::applyOp(), ghidra::RuleCollapseConstants::applyOp(), ghidra::RuleTransformCpool::applyOp(), ghidra::Rule2Comp2Mult::applyOp(), ghidra::RuleCarryElim::applyOp(), ghidra::RuleSub2Add::applyOp(), ghidra::RuleAddMultCollapse::applyOp(), ghidra::RuleLoadVarnode::applyOp(), ghidra::RuleStoreVarnode::applyOp(), ghidra::RuleSubExtComm::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleConcatCommute::applyOp(), ghidra::RuleConcatZext::applyOp(), ghidra::RuleZextCommute::applyOp(), ghidra::RuleZextShiftZext::applyOp(), ghidra::RuleShiftAnd::applyOp(), ghidra::RuleConcatZero::applyOp(), ghidra::RuleConcatLeftShift::applyOp(), ghidra::RuleSubZext::applyOp(), ghidra::RuleSubCancel::applyOp(), ghidra::RuleHumptyDumpty::applyOp(), ghidra::RuleDumptyHump::applyOp(), ghidra::RuleHumptyOr::applyOp(), ghidra::RuleSwitchSingle::applyOp(), ghidra::RuleCondNegate::applyOp(), ghidra::RuleBoolNegate::applyOp(), ghidra::RuleLess2Zero::applyOp(), ghidra::RuleLessEqual2Zero::applyOp(), ghidra::RuleSLess2Zero::applyOp(), ghidra::RulePushPtr::applyOp(), ghidra::RulePtrsubUndo::applyOp(), ghidra::RuleMultNegOne::applyOp(), ghidra::RuleAddUnsigned::applyOp(), ghidra::Rule2Comp2Sub::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::RulePtrsubCharConstant::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::RuleSubNormal::applyOp(), ghidra::RulePositiveDiv::applyOp(), ghidra::RuleDivTermAdd::applyOp(), ghidra::RuleDivTermAdd2::applyOp(), ghidra::RuleDivOpt::applyOp(), ghidra::RuleSignDiv2::applyOp(), ghidra::RuleSignForm::applyOp(), ghidra::RuleSignNearMult::applyOp(), ghidra::RuleModOpt::applyOp(), ghidra::RuleSignMod2nOpt::applyOp(), ghidra::RuleSignMod2Opt::applyOp(), ghidra::RuleSignMod2nOpt2::applyOp(), ghidra::RuleSegment::applyOp(), ghidra::RuleNegateNegate::applyOp(), ghidra::RuleConditionalMove::applyOp(), ghidra::RuleFloatCast::applyOp(), ghidra::RuleIgnoreNan::applyOp(), ghidra::RuleFuncPtrEncoding::applyOp(), ghidra::RuleThreeWayCompare::applyOp(), ghidra::RulePopcountBoolXor::applyOp(), ghidra::RuleOrMultiBool::applyOp(), ghidra::RuleXorSwap::applyOp(), ghidra::RuleLzcountShiftBool::applyOp(), ghidra::FlowInfo::artificialHalt(), ghidra::AddTreeState::buildDegenerate(), ghidra::FuncCallSpecs::buildInputFromTrials(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::FuncCallSpecs::buildParam(), ghidra::ActionReturnRecovery::buildReturnOutput(), ghidra::RulePullsubMulti::buildSubpiece(), ghidra::ActionSetCasts::castInput(), ghidra::ActionSetCasts::castOutput(), ghidra::FlowInfo::checkContainedCall(), ghidra::RuleOrPredicate::checkSingle(), cloneOp(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::RuleConditionalMove::BoolExpress::constructBool(), ghidra::RuleConditionalMove::constructNegate(), ghidra::RulePieceStructure::convertZextToPiece(), ghidra::TransformOp::createReplacement(), createStackRef(), ghidra::cseElimination(), ghidra::FuncCallSpecs::deindirect(), descend2Undef(), distributeIntMultAdd(), ghidra::SubvariableFlow::doReplacement(), ghidra::RulePushPtr::duplicateNeed(), ghidra::ActionPrototypeTypes::extendInput(), fillinReadOnly(), ghidra::ActionFuncLink::funcLinkOutput(), ghidra::FlowInfo::inlineClone(), inlineFlow(), ghidra::ActionSetCasts::insertPtrsubZero(), newIndirectCreation(), newIndirectOp(), newOpBefore(), nodeSplitCloneOp(), nodeSplitInputPatch(), ghidra::opFlipInPlaceExecute(), opHeritage(), opStackLoad(), opStackStore(), opUndoPtradd(), opZeroMulti(), overrideFlow(), ghidra::ActionConditionalConst::placeCopy(), pushBranch(), ghidra::RulePtrsubCharConstant::pushConstFurther(), pushMultiequals(), ghidra::RulePullsubMulti::replaceDescendants(), replaceLessequal(), replaceVolatile(), ghidra::FlowInfo::setupCallindSpecs(), spacebaseConstant(), ghidra::SplitDatatype::splitCopy(), ghidra::SplitDatatype::splitLoad(), ghidra::SplitDatatype::splitStore(), splitUses(), totalReplaceConstant(), ghidra::FlowInfo::truncateIndirectJump(), and ghidra::RulePtrFlow::truncatePointer().
Set a specific output Varnode for the given PcodeOp.
References ghidra::Varnode::getDef(), ghidra::PcodeOp::getOut(), opUnsetOutput(), ghidra::VarnodeBank::setDef(), ghidra::PcodeOp::setOutput(), setVarnodeProperties(), and vbank.
Referenced by ghidra::RulePushMulti::applyOp(), ghidra::RuleSubCommute::applyOp(), ghidra::RuleSubZext::applyOp(), ghidra::RuleSubRight::applyOp(), ghidra::RulePieceStructure::applyOp(), ghidra::FuncCallSpecs::buildOutputFromTrials(), ghidra::AddTreeState::buildTree(), ghidra::ActionSetCasts::castOutput(), cloneOp(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::SubvariableFlow::doReplacement(), opHeritage(), pushMultiequals(), replaceVolatile(), ghidra::SplitDatatype::splitCopy(), ghidra::SplitDatatype::splitLoad(), and splitUses().
Varnode * ghidra::Funcdata::opStackLoad | ( | AddrSpace * | spc, |
uintb | off, | ||
uint4 | sz, | ||
PcodeOp * | op, | ||
Varnode * | stackref, | ||
bool | insertafter | ||
) |
Create a LOAD expression at an offset relative to a spacebase register for a given address space.
The spacebase register is looked up for the given address space, or an optional previously existing register Varnode can be provided. An insertion point op must be provided, and newly generated ops can come either before or after this insertion point.
spc | is the given address space |
off | is the offset to calculate relative to the spacebase register |
sz | is the size of the desire LOAD in bytes |
op | is the insertion point PcodeOp |
stackref | is the spacebase register Varnode (if available) |
insertafter | is true if new ops are inserted after the insertion point |
References ghidra::CPUI_LOAD, createStackRef(), ghidra::PcodeOp::getAddr(), ghidra::AddrSpace::getContain(), ghidra::Varnode::getDef(), newOp(), newUniqueOut(), newVarnodeSpace(), opInsertAfter(), opSetInput(), and opSetOpcode().
Referenced by ghidra::FuncCallSpecs::buildParam(), ghidra::FuncCallSpecs::createPlaceholder(), ghidra::ActionFuncLink::funcLinkInput(), and target().
PcodeOp * ghidra::Funcdata::opStackStore | ( | AddrSpace * | spc, |
uintb | off, | ||
PcodeOp * | op, | ||
bool | insertafter | ||
) |
Create a STORE expression at an offset relative to a spacebase register for a given address space.
The spacebase register is looked up for the given address space. An insertion point op must be provided, and newly generated ops can come either before or after this insertion point. The Varnode value being stored must still be set on the returned PcodeOp.
spc | is the given address space |
off | is the offset to calculate relative to the spacebase register |
op | is the insertion point PcodeOp |
insertafter | is true if new ops are inserted after the insertion point |
References ghidra::CPUI_STORE, createStackRef(), ghidra::PcodeOp::getAddr(), ghidra::AddrSpace::getContain(), ghidra::Varnode::getDef(), newOp(), newVarnodeSpace(), opInsertAfter(), opSetInput(), and opSetOpcode().
Referenced by target().
void ghidra::Funcdata::opSwapInput | ( | PcodeOp * | op, |
int4 | slot1, | ||
int4 | slot2 | ||
) |
Swap two input operands in the given PcodeOp.
This is convenience method that is more efficient than call opSetInput() twice.
op | is the given PcodeOp |
slot1 | is the first input slot being switched |
slot2 | is the second input slot |
References ghidra::PcodeOp::getIn(), and ghidra::PcodeOp::setInput().
Referenced by ghidra::ActionConstantPtr::apply(), ghidra::RuleTermOrder::applyOp(), ghidra::RuleBoolNegate::applyOp(), ghidra::opFlipInPlaceExecute(), and opHeritage().
void ghidra::Funcdata::opUndoPtradd | ( | PcodeOp * | op, |
bool | finalize | ||
) |
Convert a CPUI_PTRADD back into a CPUI_INT_ADD.
Convert the given CPUI_PTRADD into the equivalent CPUI_INT_ADD. This may involve inserting a CPUI_INT_MULT PcodeOp. If finalization is requested and a new PcodeOp is needed, the output Varnode is marked as implicit and has its data-type set
op | is the given PTRADD |
finalize | is true if finalization is needed for any new PcodeOp |
References ghidra::calc_mask(), ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_MULT, ghidra::PcodeOp::getAddr(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), ghidra::Varnode::getType(), ghidra::Varnode::getTypeReadFacing(), ghidra::Varnode::isConstant(), newConstant(), newOp(), newUniqueOut(), opInsertBefore(), opRemoveInput(), opSetInput(), opSetOpcode(), ghidra::Varnode::setImplied(), and ghidra::Varnode::updateType().
Referenced by ghidra::ActionSetCasts::apply(), ghidra::RulePtraddUndo::applyOp(), and target().
void ghidra::Funcdata::opUninsert | ( | PcodeOp * | op | ) |
Remove the given PcodeOp from its basic block.
The op is taken out of its basic block and put into the dead list. If the removal is permanent the input and output Varnodes should be unset.
op | is the given PcodeOp |
References ghidra::PcodeOp::getParent(), ghidra::PcodeOpBank::markDead(), obank, and ghidra::BlockBasic::removeOp().
Referenced by ghidra::RulePushMulti::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RuleMultiCollapse::applyOp(), ghidra::RuleConditionalMove::applyOp(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::BlockWhileDo::finalTransform(), moveRespectingCover(), opHeritage(), and opUnlink().
void ghidra::Funcdata::opUnlink | ( | PcodeOp * | op | ) |
Unset inputs/output and remove given PcodeOP from its basic block.
The op is extricated from all its Varnode connections to the functions data-flow and removed from its basic block. This will not change block connections. The PcodeOp objects remains in the dead list.
op | is the given PcodeOp |
References ghidra::PcodeOp::getParent(), ghidra::PcodeOp::numInput(), opUninsert(), opUnsetInput(), and opUnsetOutput().
Referenced by ghidra::RuleSubRight::applyOp(), ghidra::FuncCallSpecs::commitNewOutputs(), and opHeritage().
void ghidra::Funcdata::opUnsetInput | ( | PcodeOp * | op, |
int4 | slot | ||
) |
Clear an input operand slot for the given PcodeOp.
The input Varnode is unlinked from the op.
op | is the given PcodeOp |
slot | is the input slot to clear |
References ghidra::PcodeOp::clearInput(), ghidra::Varnode::eraseDescend(), and ghidra::PcodeOp::getIn().
Referenced by ghidra::RuleLeftRight::applyOp(), ghidra::TransformOp::createReplacement(), opDestroy(), opHeritage(), opRemoveInput(), opSetAllInput(), opSetInput(), and opUnlink().
void ghidra::Funcdata::opUnsetOutput | ( | PcodeOp * | op | ) |
Remove output Varnode from the given PcodeOp.
The output Varnode becomes free but is not immediately deleted.
op | is the given PcodeOp |
References ghidra::Varnode::clearCover(), ghidra::PcodeOp::getOut(), ghidra::VarnodeBank::makeFree(), ghidra::PcodeOp::setOutput(), and vbank.
Referenced by ghidra::ActionDeadCode::apply(), ghidra::RuleLeftRight::applyOp(), ghidra::RuleSubCommute::cancelExtensions(), ghidra::FuncCallSpecs::commitNewOutputs(), ghidra::ActionFuncLink::funcLinkOutput(), ghidra::ActionDeadCode::neverConsumed(), opHeritage(), opSetOutput(), and opUnlink().
|
private |
Transform trivial CPUI_MULTIEQUAL to CPUI_COPY.
If the MULTIEQUAL has no inputs, presumably the basic block is unreachable, so we treat the p-code op as a COPY from a new input Varnode. If there is 1 input, the MULTIEQUAL is transformed directly into a COPY.
op | is the given MULTIEQUAL |
References ghidra::CPUI_COPY, ghidra::Varnode::getAddr(), ghidra::PcodeOp::getIn(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), newVarnode(), ghidra::PcodeOp::numInput(), opInsertInput(), opSetOpcode(), and setInputVarnode().
Referenced by blockRemoveInternal(), and branchRemoveInternal().
void ghidra::Funcdata::overrideFlow | ( | const Address & | addr, |
uint4 | type | ||
) |
Override the control-flow p-code for a particular instruction.
P-code in this function is modified to change the control-flow of the instruction at the given address, based on the Override type.
addr | is the given address of the instruction to modify |
type | is the Override type |
References beginOp(), ghidra::Override::BRANCH, ghidra::Override::CALL, ghidra::Override::CALL_RETURN, ghidra::PcodeOp::code(), ghidra::CPUI_BRANCH, ghidra::CPUI_BRANCHIND, ghidra::CPUI_CALL, ghidra::CPUI_CALLIND, ghidra::CPUI_CBRANCH, ghidra::CPUI_RETURN, endOp(), findPrimaryBranch(), ghidra::PcodeOp::isDead(), newConstant(), newOp(), opDeadInsertAfter(), opSetInput(), opSetOpcode(), and ghidra::Override::RETURN.
Referenced by getCleanUpIndex(), and ghidra::FlowInfo::processInstruction().
void ghidra::Funcdata::prepareThisPointer | ( | void | ) |
Prepare for recovery of the "this" pointer.
Make sure that if a Varnode exists representing the "this" pointer for the function, that it is treated as pointer data-type.
References ghidra::ScopeLocal::addTypeRecommendation(), funcp, ghidra::AddrSpace::getAddrSize(), ghidra::AddrSpaceManager::getDefaultDataSpace(), ghidra::FuncProto::getParam(), ghidra::FuncProto::getThisPointerStorage(), ghidra::TypeFactory::getTypePointer(), ghidra::TypeFactory::getTypeVoid(), ghidra::AddrSpace::getWordSize(), glb, ghidra::ScopeLocal::hasTypeRecommendations(), ghidra::ProtoParameter::isThisPointer(), ghidra::ProtoParameter::isTypeLocked(), localmap, ghidra::FuncProto::numParams(), and ghidra::Architecture::types.
Referenced by ghidra::ActionPrototypeTypes::apply(), and clearLanedAccessMap().
void ghidra::Funcdata::printBlockTree | ( | ostream & | s | ) | const |
Print a description of control-flow structuring to a stream.
A description of each block in the current structure hierarchy is printed to stream. This is suitable for a console mode or debug view of the state of control-flow structuring at any point during analysis.
s | is the output stream |
References ghidra::BlockGraph::getSize(), ghidra::BlockGraph::printTree(), and sblocks.
Referenced by getCleanUpIndex().
void ghidra::Funcdata::printLocalRange | ( | ostream & | s | ) | const |
Print description of memory ranges associated with local scopes.
Each scope has a set of memory ranges associated with it, encompassing storage locations of variables that are assumed to be in the scope. Each range for each local scope is printed.
s | is the output stream |
References ghidra::Scope::childrenBegin(), ghidra::Scope::childrenEnd(), localmap, and ghidra::Scope::printBounds().
Referenced by getCleanUpIndex().
void ghidra::Funcdata::printRaw | ( | ostream & | s | ) | const |
Print raw p-code op descriptions to a stream.
A representation of all PcodeOps in the function body are printed to the stream. Depending on the state of analysis, PcodeOps are grouped into their basic blocks, and within a block, ops are displayed sequentially. Basic labeling of branch destinations is also printed. This is suitable for a console mode or debug view of the state of the function at any given point in its analysis.
s | is the output stream |
References bblocks, ghidra::PcodeOpBank::beginAll(), ghidra::PcodeOpBank::empty(), ghidra::PcodeOpBank::endAll(), ghidra::BlockGraph::getSize(), obank, and ghidra::BlockGraph::printRaw().
Referenced by getCleanUpIndex().
void ghidra::Funcdata::printVarnodeTree | ( | ostream & | s | ) | const |
Print a description of all Varnodes to a stream.
A description of each Varnode currently involved in the data-flow of this function is printed to the output stream. This is suitable as part of a console mode or debug view of the function at any point during its analysis
s | is the output stream |
References ghidra::VarnodeBank::beginDef(), ghidra::VarnodeBank::endDef(), ghidra::Varnode::printInfo(), and vbank.
Referenced by getCleanUpIndex().
void ghidra::Funcdata::pushBranch | ( | BlockBasic * | bb, |
int4 | slot, | ||
BlockBasic * | bbnew | ||
) |
Move a control-flow edge from one block to another.
This is intended for eliminating switch guard artifacts. The edge must be for a conditional jump and must be moved to a block hosting multiple out edges for a BRANCHIND.
bb | is the basic block out of which the edge to move flows |
slot | is the index of the (out) edge |
bbnew | is the basic block where the edge should get moved to |
References bblocks, ghidra::PcodeOp::code(), ghidra::CPUI_BRANCH, ghidra::CPUI_BRANCHIND, ghidra::CPUI_CBRANCH, ghidra::BlockBasic::lastOp(), ghidra::BlockGraph::moveOutEdge(), opRemoveInput(), opSetOpcode(), ghidra::FlowBlock::sizeOut(), and structureReset().
Referenced by ghidra::JumpBasic::foldInOneGuard(), and setBasicBlockRange().
|
private |
Push MULTIEQUAL Varnodes of the given block into the output block.
Assuming the given basic block is being removed, force any Varnode defined by a MULTIEQUAL in the block to be defined in the output block instead. This is used as part of the basic block removal process to patch up data-flow.
bb | is the given basic block |
References ghidra::Varnode::beginDescend(), ghidra::BlockBasic::beginOp(), ghidra::PcodeOp::code(), ghidra::CPUI_MULTIEQUAL, ghidra::Varnode::descend, ghidra::Varnode::endDescend(), ghidra::BlockBasic::endOp(), ghidra::Varnode::getAddr(), ghidra::PcodeOp::getIn(), ghidra::FlowBlock::getIn(), ghidra::PcodeOp::getOut(), ghidra::FlowBlock::getOut(), ghidra::FlowBlock::getOutRevIndex(), ghidra::PcodeOp::getParent(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::BlockBasic::getStart(), ghidra::Varnode::hasNoDescend(), ghidra::Varnode::isAddrTied(), newOp(), newUnique(), newVarnode(), ghidra::PcodeOp::numInput(), opInsertBegin(), opSetAllInput(), opSetInput(), opSetOpcode(), opSetOutput(), ghidra::FlowBlock::sizeIn(), ghidra::FlowBlock::sizeOut(), and warningHeader().
Referenced by blockRemoveInternal().
JumpTable * ghidra::Funcdata::recoverJumpTable | ( | Funcdata & | partial, |
PcodeOp * | op, | ||
FlowInfo * | flow, | ||
int4 & | failuremode | ||
) |
Recover control-flow destinations for a BRANCHIND.
If an existing and complete JumpTable exists for the BRANCHIND, it is returned immediately. Otherwise an attempt is made to analyze the current partial function and recover the set of destination addresses, which if successful will be returned as a new JumpTable object.
partial | is the Funcdata copy to perform analysis on if necessary |
op | is the given BRANCHIND PcodeOp |
flow | is current flow information for this function |
failuremode | will hold the final success/failure code (0=success) |
References earlyJumpTableFail(), flags, ghidra::JumpTable::getStage(), glb, ghidra::JumpTable::isOverride(), jumptablerecovery_dont, jumpvec, linkJumpTable(), ghidra::JumpTable::setIndirectOp(), and stageJumpTable().
Referenced by endOp(), and ghidra::FlowInfo::recoverJumpTables().
void ghidra::Funcdata::remapDynamicVarnode | ( | Varnode * | vn, |
Symbol * | sym, | ||
const Address & | usepoint, | ||
uint8 | hash | ||
) |
Remap a Symbol to a given Varnode using a new dynamic mapping.
Any previous links between the Symbol, the Varnode, and the associate HighVariable are removed. Then a new dynamic link is created.
vn | is the given Varnode |
sym | is the Symbol the Varnode maps to |
usepoint | is the code Address where the Varnode is defined |
hash | is the hash for the new dynamic mapping |
References ghidra::Varnode::clearSymbolLinks(), localmap, ghidra::ScopeLocal::remapSymbolDynamic(), and ghidra::Varnode::setSymbolEntry().
Referenced by clearDeadOps().
Remap a Symbol to a given Varnode using a static mapping.
Any previous links between the Symbol, the Varnode, and the associate HighVariable are removed. Then a new link is created.
vn | is the given Varnode |
sym | is the Symbol the Varnode maps to |
usepoint | is the desired usepoint for the mapping |
References ghidra::Varnode::clearSymbolLinks(), ghidra::Varnode::getAddr(), localmap, ghidra::ScopeLocal::remapSymbol(), and ghidra::Varnode::setSymbolEntry().
Referenced by clearDeadOps().
void ghidra::Funcdata::removeBranch | ( | BlockBasic * | bb, |
int4 | num | ||
) |
Remove the indicated branch from a basic block.
The edge is removed from control-flow and affected MULTIEQUAL ops are adjusted.
bb | is the basic block |
num | is the index of the out edge to remove |
References branchRemoveInternal(), and structureReset().
Referenced by ghidra::ActionRedundBranch::apply(), ghidra::ActionDeterminedBranch::apply(), and setBasicBlockRange().
void ghidra::Funcdata::removeDoNothingBlock | ( | BlockBasic * | bb | ) |
Remove a basic block from control-flow that performs no operations.
The block must contain only marker operations (MULTIEQUAL) and possibly a single unconditional branch operation. The block and its PcodeOps are completely removed from the current control-flow and data-flow. This forces a reset of the control-flow structuring hierarchy.
bb | is the given basic block |
References blockRemoveInternal(), ghidra::FlowBlock::setDead(), ghidra::FlowBlock::sizeOut(), and structureReset().
Referenced by ghidra::ActionDoNothing::apply(), and setBasicBlockRange().
void ghidra::Funcdata::removeFromFlowSplit | ( | BlockBasic * | bl, |
bool | swap | ||
) |
Remove a basic block splitting its control-flow into two distinct paths.
This is used by ConditionalExecution to eliminate unnecessary control-flow joins. The given block must have 2 inputs and 2 outputs, (and no operations). The block is removed, and control-flow is adjusted so that In(0) flows to Out(0) and In(1) flows to Out(1), or vice versa.
bl | is the given basic block |
swap | is true to force In(0)->Out(1) and In(1)->Out(0) |
References bblocks, ghidra::BlockBasic::emptyOp(), ghidra::BlockGraph::removeBlock(), ghidra::BlockGraph::removeFromFlowSplit(), and structureReset().
Referenced by setBasicBlockRange().
void ghidra::Funcdata::removeJumpTable | ( | JumpTable * | jt | ) |
Remove/delete the given jump-table.
The JumpTable object is freed, and the associated BRANCHIND is no longer marked as a switch point.
jt | is the given JumpTable object |
References ghidra::FlowBlock::clearFlag(), ghidra::FlowBlock::f_switch_out, ghidra::JumpTable::getIndirectOp(), ghidra::PcodeOp::getParent(), and jumpvec.
Referenced by ghidra::RuleSwitchSingle::applyOp(), blockRemoveInternal(), and getJumpTable().
bool ghidra::Funcdata::removeUnreachableBlocks | ( | bool | issuewarning, |
bool | checkexistence | ||
) |
Remove any unreachable basic blocks.
A quick check for unreachable blocks can optionally be made, otherwise the cached state is checked via hasUnreachableBlocks(), which is turned on during analysis by calling the structureReset() method.
issuewarning | is true if warning comments are desired |
checkexistence | is true to force an active search for unreachable blocks |
References bblocks, blockRemoveInternal(), branchRemoveInternal(), ghidra::BlockGraph::collectReachable(), ghidra::BlockGraph::getBlock(), ghidra::FlowBlock::getImmedDom(), ghidra::AddrSpace::getName(), ghidra::BlockGraph::getSize(), ghidra::Address::getSpace(), ghidra::BlockBasic::getStart(), hasUnreachableBlocks(), ghidra::FlowBlock::isEntryPoint(), ghidra::Address::printRaw(), ghidra::FlowBlock::sizeOut(), structureReset(), and warningHeader().
Referenced by ghidra::ActionUnreachable::apply(), ghidra::FlowInfo::generateBlocks(), and setBasicBlockRange().
bool ghidra::Funcdata::replaceLessequal | ( | PcodeOp * | op | ) |
Replace INT_LESSEQUAL and INT_SLESSEQUAL expressions.
Do in-place replacement of
c <= x
with c-1 < x
ORx <= c
with x < c+1
op | is comparison PcodeOp |
References ghidra::calc_mask(), ghidra::PcodeOp::code(), ghidra::Varnode::copySymbol(), ghidra::CPUI_INT_LESS, ghidra::CPUI_INT_SLESS, ghidra::CPUI_INT_SLESSEQUAL, ghidra::PcodeOp::getIn(), ghidra::Varnode::getOffset(), ghidra::Varnode::getSize(), newConstant(), opSetInput(), and opSetOpcode().
Referenced by ghidra::RuleIntLessEqual::applyOp(), ghidra::opFlipInPlaceExecute(), and setBasicBlockRange().
bool ghidra::Funcdata::replaceVolatile | ( | Varnode * | vn | ) |
Replace accesses of the given Varnode with volatile operations.
The Varnode is assumed not fully linked. The read or write action is modeled by inserting a special user op that represents the action. The given Varnode is replaced by a temporary Varnode within the data-flow, and the original address becomes a parameter to the user op.
vn | is the given Varnode to model as volatile |
References ghidra::CPUI_CALLOTHER, ghidra::PcodeOp::getAddr(), ghidra::Varnode::getAddr(), ghidra::Varnode::getDef(), ghidra::UserPcodeOp::getDisplay(), ghidra::UserPcodeOp::getIndex(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::UserOpManage::getVolatileRead(), ghidra::UserOpManage::getVolatileWrite(), glb, ghidra::Varnode::hasNoDescend(), ghidra::Varnode::isTypeLock(), ghidra::Varnode::isWritten(), ghidra::Varnode::loneDescend(), newCodeRef(), newConstant(), newOp(), newUnique(), newUniqueOut(), opInsertAfter(), opInsertBefore(), opSetInput(), opSetOpcode(), opSetOutput(), ghidra::PcodeOp::setAdditionalFlag(), ghidra::Varnode::setFlags(), ghidra::PcodeOp::setHoldOutput(), ghidra::PcodeOp::special_prop, ghidra::Architecture::userops, and ghidra::Varnode::volatil.
Referenced by ghidra::ActionVarnodeProps::apply(), and clearLanedAccessMap().
|
inline |
Mark that dead Varnodes have been seen in a specific address space.
spc | is the address space to mark |
References ghidra::Heritage::seenDeadCode().
Referenced by ghidra::ActionDeadCode::apply().
|
inline |
Set the initial ownership range for the given basic block.
bb | is the given basic block |
beg | is the beginning Address of the owned code range |
end | is the ending Address of the owned code range |
References collapseIntMultMult(), compareCallspecs(), distributeIntMultAdd(), forceGoto(), installSwitchDefaults(), nodeJoinCreateBlock(), nodeSplit(), pushBranch(), removeBranch(), removeDoNothingBlock(), removeFromFlowSplit(), removeUnreachableBlocks(), replaceLessequal(), ghidra::BlockBasic::setInitialRange(), spliceBlockBasic(), and switchEdge().
Referenced by ghidra::FlowInfo::generateBlocks(), and ghidra::FlowInfo::splitBasic().
|
inline |
Set a delay before removing dead code for a specific address space.
spc | is the specific address space |
delay | is the number of passes to delay |
References ghidra::Heritage::setDeadCodeDelay().
Referenced by ghidra::Override::applyDeadCodeDelay().
|
inline |
Toggle whether double precision analysis is used.
val | is true if double precision analysis is enabled |
References double_precis_on.
Mark a Varnode as an input to the function.
An input Varnode has a special designation within SSA form as not being defined by a p-code operation and is a formal input to the data-flow of the function. It is not necessarily a formal function parameter.
The given Varnode to be marked is also returned unless there is an input Varnode that already exists which overlaps the given Varnode. If the Varnodes have the same size and storage address, the preexisting input Varnode is returned instead. Otherwise an exception is thrown.
vn | is the given Varnode to mark as an input |
References ghidra::VarnodeBank::beginDef(), funcp, ghidra::Varnode::getAddr(), ghidra::Varnode::getSize(), ghidra::FuncProto::hasEffect(), ghidra::Varnode::input, ghidra::Varnode::isInput(), ghidra::Varnode::overlap(), ghidra::EffectRecord::return_address, ghidra::VarnodeBank::setInput(), ghidra::Varnode::setReturnAddress(), ghidra::Varnode::setUnaffected(), setVarnodeProperties(), ghidra::EffectRecord::unaffected, and vbank.
Referenced by adjustInputVarnodes(), ghidra::ActionPrototypeTypes::apply(), ghidra::ActionInputPrototype::apply(), ghidra::SubvariableFlow::getReplaceVarnode(), numVarnodes(), opZeroMulti(), and ghidra::SubvariableFlow::replaceInput().
|
inline |
Toggle whether this is being used for jump-table recovery.
val | is true to indicate a jump-table is being recovered |
References jumptablerecovery_dont.
|
inline |
Toggle whether analysis needs to be restarted for this function.
val | is true if a reset is required |
References restart_pending.
Referenced by ghidra::ActionSwitchNorm::apply(), ghidra::FuncCallSpecs::deindirect(), and ghidra::FuncCallSpecs::forceSet().
|
inline |
Toggle whether data-type recovery will be performed on this function.
val | is true if data-type analysis is enabled |
References typerecovery_on.
Referenced by ghidra::ActionStartTypes::reset().
bool ghidra::Funcdata::setUnionField | ( | const Datatype * | parent, |
const PcodeOp * | op, | ||
int4 | slot, | ||
const ResolvedUnion & | resolve | ||
) |
Associate a union field with the given edge.
If there was a previous association, it is overwritten unless it was locked. The method returns true except in this case where a previous locked association exists.
parent | is the parent union data-type |
op | is the PcodeOp component of the given edge |
slot | is the slot component of the given edge |
resolve | is the resolved union |
References ghidra::PcodeOp::code(), ghidra::CPUI_MULTIEQUAL, ghidra::PcodeOp::getIn(), ghidra::PcodeOp::numInput(), and unionMap.
Referenced by applyUnionFacet(), ghidra::ActionSetCasts::castOutput(), endOp(), forceFacingType(), inheritResolution(), ghidra::TypePointer::resolveInFlow(), ghidra::TypeArray::resolveInFlow(), ghidra::TypeStruct::resolveInFlow(), ghidra::TypeUnion::resolveInFlow(), ghidra::TypeUnion::resolveTruncation(), ghidra::ActionSetCasts::resolveUnion(), and ghidra::ActionSetCasts::tryResolutionAdjustment().
|
private |
Look-up boolean properties and data-type information.
Properties of a given storage location are gathered from symbol information and applied to the given Varnode.
vn | is the given Varnode |
References ghidra::Varnode::calcCover(), ghidra::Varnode::cover, ghidra::Varnode::getAddr(), ghidra::Varnode::getSize(), ghidra::Varnode::getUsePoint(), isHighOn(), ghidra::Varnode::isMapped(), localmap, ghidra::Scope::queryProperties(), ghidra::Varnode::setFlags(), ghidra::Varnode::setSymbolProperties(), and ghidra::Varnode::typelock.
Referenced by opSetOutput(), and setInputVarnode().
|
private |
Sort calls using a dominance based order.
Calls are put in dominance order so that earlier calls get evaluated first. Order affects parameter analysis.
References compareCallspecs(), and qlst.
Referenced by startProcessing().
void ghidra::Funcdata::spacebase | ( | void | ) |
Mark registers that map to a virtual address space.
This routine searches for an marks Varnode objects, like stack-pointer registers, that are used as a base address for a virtual address space. Each Varnode gets a special data-type and is marked so that Varnode::isSpacebase() returns true.
References ghidra::VarnodeBank::beginLoc(), ghidra::PcodeOp::code(), ghidra::CPUI_INT_ADD, ghidra::VarnodeBank::endLoc(), getAddress(), ghidra::Varnode::getDef(), ghidra::AddrSpaceManager::getSpace(), ghidra::AddrSpace::getSpacebase(), ghidra::TypeFactory::getTypePointer(), ghidra::TypeFactory::getTypeSpacebase(), ghidra::AddrSpace::getWordSize(), glb, ghidra::Varnode::isFree(), ghidra::Varnode::isInput(), ghidra::Varnode::isSpacebase(), ghidra::AddrSpace::numSpacebase(), ghidra::AddrSpaceManager::numSpaces(), ghidra::Varnode::setFlags(), ghidra::Varnode::spacebase, splitUses(), ghidra::Architecture::types, ghidra::Varnode::updateType(), and vbank.
Referenced by ghidra::ActionSpacebase::apply(), and hasBadData().
void ghidra::Funcdata::spacebaseConstant | ( | PcodeOp * | op, |
int4 | slot, | ||
SymbolEntry * | entry, | ||
const Address & | rampoint, | ||
uintb | origval, | ||
int4 | origsize | ||
) |
Convert a constant pointer into a ram CPUI_PTRSUB.
A constant known to be a pointer into an address space like ram is converted into a Varnode defined by CPUI_PTRSUB, which triggers a Symbol lookup at points during analysis. The constant must point to a known Symbol.
The PTRSUB takes the constant 0 as its first input, which is marked as a spacebase to indicate this situation. The second input to PTRSUB becomes the offset to the Symbol within the address space. An additional INT_SUB may be inserted to get from the start of the Symbol to the address indicated by the original constant pointer.
op | is the PcodeOp referencing the constant pointer |
slot | is the input slot of the constant pointer |
entry | is the Symbol being pointed (in)to |
rampoint | is the constant pointer interpreted as an Address |
origval | is the constant |
origsize | is the size of the constant |
References ghidra::AddrSpace::byteToAddress(), ghidra::PcodeOp::code(), ghidra::CPUI_COPY, ghidra::CPUI_INT_ADD, ghidra::CPUI_INT_ZEXT, ghidra::CPUI_PTRSUB, ghidra::CPUI_SUBPIECE, ghidra::SymbolEntry::getAddr(), ghidra::PcodeOp::getAddr(), ghidra::Address::getAddrSize(), ghidra::Datatype::getMetatype(), ghidra::Address::getOffset(), ghidra::PcodeOp::getOut(), ghidra::Address::getSpace(), ghidra::SymbolEntry::getSymbol(), ghidra::Symbol::getType(), ghidra::TypeFactory::getTypePointer(), ghidra::TypeFactory::getTypePointerStripArray(), ghidra::TypeFactory::getTypeSpacebase(), ghidra::AddrSpace::getWordSize(), glb, ghidra::PcodeOp::insertInput(), ghidra::AddrSpace::isTruncated(), ghidra::Symbol::isTypeLocked(), newConstant(), newOp(), newUniqueOut(), opInsertBefore(), opSetInput(), opSetOpcode(), ghidra::Varnode::setFlags(), ghidra::Varnode::setPtrCheck(), ghidra::Varnode::spacebase, ghidra::TYPE_UNKNOWN, ghidra::Architecture::types, and ghidra::Varnode::updateType().
Referenced by ghidra::ActionConstantPtr::apply(), and hasBadData().
void ghidra::Funcdata::spliceBlockBasic | ( | BlockBasic * | bl | ) |
Merge the given basic block with the block it flows into.
The given block must have a single output block, which will be removed. The given block has the p-code from the output block concatenated to its own, and it inherits the output block's out edges.
bl | is the given basic block |
References bblocks, ghidra::BlockBasic::beginOp(), ghidra::PcodeOp::clearFlag(), ghidra::PcodeOp::code(), ghidra::CPUI_MULTIEQUAL, ghidra::BlockBasic::endOp(), ghidra::FlowBlock::getOut(), ghidra::PcodeOp::isBranch(), ghidra::BlockBasic::mergeRange(), ghidra::BlockBasic::op, opDestroy(), ghidra::BlockBasic::setOrder(), ghidra::PcodeOp::setParent(), ghidra::FlowBlock::sizeIn(), ghidra::FlowBlock::sizeOut(), ghidra::BlockGraph::spliceBlock(), ghidra::PcodeOp::startbasic, and structureReset().
Referenced by ghidra::ActionRedundBranch::apply(), and setBasicBlockRange().
|
private |
Make all reads of the given Varnode unique.
For the given Varnode, duplicate its defining PcodeOp at each read of the Varnode so that the read becomes a new unique Varnode. This operation should not be performed on any PcodeOp with side effects like CPUI_CALL.
vn | is the given Varnode |
References ghidra::PcodeOp::code(), ghidra::Varnode::descend, ghidra::PcodeOp::getAddr(), ghidra::Varnode::getAddr(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getIn(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::Varnode::getType(), newOp(), newVarnode(), ghidra::PcodeOp::numInput(), opInsertBefore(), opSetInput(), opSetOpcode(), and opSetOutput().
Referenced by spacebase().
|
private |
Recover a jump-table for a given BRANCHIND using existing flow information.
A partial function (copy) is built using the flow info. Simplification is performed on the partial function (using the "jumptable" strategy), then destination addresses of the branch are recovered by examining the simplified data-flow. The jump-table object is populated with the recovered addresses. An integer value is returned:
partial | is a function object for caching analysis |
jt | is the jump-table object to populate |
op | is the BRANCHIND p-code op to analyze |
flow | is the existing flow information |
References ghidra::Architecture::allacts, ghidra::PcodeOp::code(), ghidra::CPUI_BRANCHIND, ghidra::FlowInfo::doesJumpRecord(), ghidra::LowlevelError::explain, findOp(), flags, ghidra::PcodeOp::getAddr(), ghidra::ActionDatabase::getCurrent(), ghidra::ActionDatabase::getCurrentName(), ghidra::PcodeOp::getSeqNum(), ghidra::JumpTable::getStage(), glb, ghidra::PcodeOp::isDead(), isJumptableRecoveryOn(), jumptablerecovery_on, ghidra::Action::perform(), ghidra::JumpTable::recoverAddresses(), ghidra::JumpTable::recoverMultistage(), ghidra::Action::reset(), ghidra::ActionDatabase::setCurrent(), ghidra::JumpTable::setIndirectOp(), ghidra::JumpTable::setLoadCollect(), truncatedFlow(), and warning().
Referenced by recoverJumpTable().
void ghidra::Funcdata::startProcessing | ( | void | ) |
Start processing for this function.
This routine does basic set-up for analyzing the function. In particular, it generates the raw p-code, builds basic blocks, and generates the call specification objects.
References ghidra::Override::applyDeadCodeDelay(), baseaddr, ghidra::Heritage::buildInfoList(), ghidra::ScopeInternal::clearUnlocked(), ghidra::FuncProto::clearUnlockedOutput(), flags, followFlow(), funcp, ghidra::Address::getSpace(), heritage, ghidra::FuncProto::isInline(), localmap, localoverride, processing_started, sortCallSpecs(), structureReset(), and warningHeader().
Referenced by ghidra::ActionStart::apply(), and hasNoStructBlocks().
|
private |
Calculate initial basic block structures (after a control-flow change)
For the current control-flow graph, (re)calculate the loop structure and dominance. This can be called multiple times as changes are made to control-flow. The structured hierarchy is also reset.
References bblocks, blocks_unreachable, ghidra::BlockGraph::calcForwardDominator(), ghidra::BlockGraph::clear(), flags, ghidra::Heritage::forceRestructure(), ghidra::JumpTable::getIndirectOp(), heritage, ghidra::PcodeOp::isDead(), jumpvec, sblocks, ghidra::BlockGraph::structureLoops(), and warningHeader().
Referenced by nodeJoinCreateBlock(), nodeSplit(), pushBranch(), removeBranch(), removeDoNothingBlock(), removeFromFlowSplit(), removeUnreachableBlocks(), spliceBlockBasic(), startProcessing(), and switchEdge().
void ghidra::Funcdata::switchEdge | ( | FlowBlock * | inblock, |
BlockBasic * | outbefore, | ||
FlowBlock * | outafter | ||
) |
Switch an outgoing edge from the given source block to flow into another block.
This does not adjust MULTIEQUAL data-flow.
inblock | is the given source block |
outbefore | is the other side of the desired edge |
outafter | is the new destination block desired |
References bblocks, structureReset(), and ghidra::BlockGraph::switchEdge().
Referenced by setBasicBlockRange().
|
private |
Convert jump-table addresses to basic block indices.
For each jump-table, for each address, the corresponding basic block index is computed. This also calculates the default branch for each jump-table.
flow | is the flow object (mapping addresses to p-code ops) |
References jumpvec.
Referenced by followFlow().
|
private |
Update properties (and the data-type) for a set of Varnodes associated with one Symbol.
The set of Varnodes with the same size and address all have their boolean properties updated to the given values. The set is specified by providing an iterator reference to the first Varnode in the set assuming a 'loc' ordering. This iterator is updated to point to the first Varnode after the affected set.
The only properties that can be effectively changed with this routine are mapped, addrtied, addrforce, and nolocalalias. HighVariable splits must occur if addrtied is cleared.
If the given data-type is non-null, an attempt is made to update all the Varnodes to this data-type. The typelock and namelock properties cannot be changed here.
iter | points to the first Varnode in the set |
fl | holds the new set of boolean properties |
ct | is the given data-type to set (or NULL) |
References ghidra::Varnode::addrforce, ghidra::Varnode::addrtied, ghidra::Varnode::clearFlags(), ghidra::VarnodeBank::endLoc(), ghidra::HighVariable::finalizeDatatype(), ghidra::Varnode::getAddr(), ghidra::Varnode::getFlags(), ghidra::Varnode::getHigh(), ghidra::Varnode::getSize(), ghidra::Varnode::isFree(), ghidra::Varnode::mapentry, ghidra::Varnode::mapped, ghidra::Varnode::nolocalalias, ghidra::Varnode::setFlags(), ghidra::Varnode::updateType(), and vbank.
Referenced by syncVarnodesWithSymbols().
bool ghidra::Funcdata::syncVarnodesWithSymbols | ( | const ScopeLocal * | lm, |
bool | updateDatatypes, | ||
bool | unmappedAliasCheck | ||
) |
Update Varnode properties based on (new) Symbol information.
Boolean properties addrtied, addrforce, and nolocalalias for Varnodes are updated based on new Symbol information they map to. The caller can elect to update data-type information as well, where Varnodes and their associated HighVariables have their data-type finalized based symbols.
lm | is the Symbol scope within which to search for mapped Varnodes |
updateDatatypes | is true if the caller wants to update data-types |
unmappedAliasCheck | is true if an alias check should be performed on unmapped Varnodes |
References ghidra::Varnode::addrtied, ghidra::VarnodeBank::beginLoc(), ghidra::VarnodeBank::endLoc(), ghidra::ScopeInternal::findOverlap(), ghidra::Varnode::getAddr(), ghidra::SymbolEntry::getAllFlags(), ghidra::Datatype::getMetatype(), ghidra::SymbolEntry::getSize(), ghidra::Varnode::getSize(), ghidra::SymbolEntry::getSizedType(), ghidra::ScopeLocal::getSpaceId(), ghidra::Varnode::getUsePoint(), ghidra::Scope::inScope(), ghidra::ScopeLocal::isUnmappedUnaliased(), ghidra::Varnode::mapped, ghidra::Varnode::namelock, ghidra::Varnode::nolocalalias, syncVarnodesWithSymbol(), ghidra::TYPE_UNKNOWN, ghidra::Varnode::typelock, and vbank.
Referenced by ghidra::ActionRestructureVarnode::apply(), ghidra::ActionRestructureHigh::apply(), and clearLanedAccessMap().
Replace all read references to the first Varnode with a second Varnode.
References ghidra::Varnode::beginDescend(), ghidra::Varnode::endDescend(), ghidra::PcodeOp::getSlot(), and opSetInput().
Referenced by adjustInputVarnodes(), ghidra::RulePushMulti::applyOp(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::RuleMultiCollapse::applyOp(), clearLanedAccessMap(), ghidra::cseElimination(), ghidra::ActionMultiCse::processBlock(), and ghidra::SubvariableFlow::replaceInput().
void ghidra::Funcdata::totalReplaceConstant | ( | Varnode * | vn, |
uintb | val | ||
) |
Replace every read reference of the given Varnode with a constant value.
A new constant Varnode is created for each read site. If there are any marker ops (MULTIEQUAL) a single COPY op is inserted and the marker input is set to be the output of the COPY.
vn | is the given Varnode |
val | is the constant value to replace it with |
References ghidra::Varnode::beginDescend(), ghidra::CPUI_COPY, ghidra::Varnode::endDescend(), ghidra::PcodeOp::getAddr(), getBasicBlocks(), ghidra::BlockGraph::getBlock(), ghidra::Varnode::getDef(), ghidra::PcodeOp::getOut(), ghidra::Varnode::getSize(), ghidra::PcodeOp::getSlot(), ghidra::BlockBasic::getStart(), ghidra::PcodeOp::isMarker(), ghidra::Varnode::isWritten(), newConstant(), newOp(), newUniqueOut(), opInsertAfter(), opInsertBegin(), opSetInput(), and opSetOpcode().
Referenced by ghidra::ActionVarnodeProps::apply(), and clearLanedAccessMap().
Copy properties from an existing Varnode to a new Varnode.
The new Varnode is assumed to overlap the storage of the existing Varnode. Properties like boolean flags and consume bits are copied as appropriate.
vn | is the existing Varnode |
newVn | is the new Varnode that has its properties set |
lsbOffset | is the significance offset of the new Varnode within the exising |
References ghidra::Varnode::addrforce, ghidra::calc_mask(), ghidra::Varnode::directwrite, ghidra::Varnode::getConsume(), ghidra::Varnode::getFlags(), ghidra::Varnode::getSize(), ghidra::Varnode::setConsume(), and ghidra::Varnode::setFlags().
Referenced by clearLanedAccessMap(), and ghidra::TransformVar::createReplacement().
Generate a clone with truncated control-flow given a partial function.
Existing p-code is cloned from another function whose flow has not been completely followed. Artificial halt operators are inserted wherever flow is incomplete and basic blocks are generated.
fd | is the partial function to clone |
flow | is partial function's flow information |
References bblocks, ghidra::PcodeOpBank::beginDead(), blocks_generated, ghidra::FlowInfo::clearFlags(), ghidra::FuncCallSpecs::clone(), cloneOp(), deleteVarnode(), ghidra::PcodeOpBank::empty(), ghidra::PcodeOpBank::endDead(), findOp(), flags, ghidra::FlowInfo::generateBlocks(), ghidra::PcodeOp::getIn(), ghidra::FuncCallSpecs::getOp(), ghidra::PcodeOp::getSeqNum(), ghidra::Varnode::getSpace(), ghidra::AddrSpace::getType(), ghidra::PcodeOpBank::getUniqId(), ghidra::FlowInfo::hasInject(), ghidra::FlowInfo::injectPcode(), ghidra::IPTR_FSPEC, jumpvec, newVarnodeCallSpecs(), obank, opSetInput(), ghidra::FlowInfo::possible_unreachable, qlst, ghidra::JumpTable::setIndirectOp(), and ghidra::PcodeOpBank::setUniqId().
Referenced by getCleanUpIndex(), and stageJumpTable().
void ghidra::Funcdata::warning | ( | const string & | txt, |
const Address & | ad | ||
) | const |
Add a warning comment in the function body.
The comment is added to the global database, indexed via its placement address and the entry address of the function. The emitter will attempt to place the comment before the source expression that maps most closely to the address.
txt | is the string body of the comment |
ad | is the placement address |
References ghidra::CommentDatabase::addCommentNoDuplicate(), baseaddr, ghidra::Architecture::commentdb, flags, glb, jumptablerecovery_on, and ghidra::Comment::warning.
Referenced by ghidra::ActionDoNothing::apply(), ghidra::ActionPrototypeWarnings::apply(), ghidra::RuleIndirectCollapse::applyOp(), ghidra::JumpBasic::buildLabels(), ghidra::JumpBasicOverride::buildLabels(), ghidra::AddTreeState::buildTree(), ghidra::FlowInfo::checkContainedCall(), ghidra::FlowInfo::checkForFlowModification(), ghidra::ActionSetCasts::checkPointerIssues(), fillinReadOnly(), ghidra::FlowInfo::handleOutOfBounds(), hasNoStructBlocks(), ghidra::FlowInfo::processInstruction(), ghidra::JumpTable::recoverLabels(), ghidra::JumpTable::recoverMultistage(), ghidra::JumpTable::sanityCheck(), stageJumpTable(), ghidra::FlowInfo::testHardInlineRestrictions(), and ghidra::FlowInfo::truncateIndirectJump().
void ghidra::Funcdata::warningHeader | ( | const string & | txt | ) | const |
Add a warning comment as part of the function header.
The warning will be emitted as part of the block comment printed right before the prototype. The comment is stored in the global comment database, indexed via the function's entry address.
txt | is the string body of the comment |
References ghidra::CommentDatabase::addCommentNoDuplicate(), baseaddr, ghidra::Architecture::commentdb, flags, glb, jumptablerecovery_on, and ghidra::Comment::warningheader.
Referenced by ghidra::ActionStackPtrFlow::analyzeExtraPop(), ghidra::AddTreeState::apply(), ghidra::ActionRestartGroup::apply(), ghidra::ActionInferTypes::apply(), ghidra::ActionPrototypeWarnings::apply(), ghidra::RuleSwitchSingle::applyOp(), attemptDynamicMappingLate(), blockRemoveInternal(), ghidra::FlowInfo::checkContainedCall(), ghidra::FlowInfo::handleOutOfBounds(), hasNoStructBlocks(), ghidra::FlowInfo::injectPcode(), mapGlobals(), ghidra::ScopeLocal::markNotMapped(), ghidra::FlowInfo::processInstruction(), pushMultiequals(), ghidra::FlowInfo::reinterpreted(), removeUnreachableBlocks(), ghidra::FuncCallSpecs::resolveSpacebaseRelative(), startProcessing(), and structureReset().