Ghidra 11.3.2
Ghidra internal decompiler documentation.
|
A standard model for returning output parameters from a function. More...
#include <fspec.hh>
Public Member Functions | |
ParamListStandardOut (void) | |
Constructor for use with decode() | |
ParamListStandardOut (const ParamListStandardOut &op2) | |
Copy constructor. | |
void | fillinMapFallback (ParamActive *active, bool firstOnly) const |
Find the return value storage using the older fallback method. | |
virtual uint4 | getType (void) const |
Get the type of parameter list. | |
virtual void | assignMap (const PrototypePieces &proto, TypeFactory &typefactory, vector< ParameterPieces > &res) const |
Given list of data-types, map the list positions to storage locations. | |
virtual void | fillinMap (ParamActive *active) const |
Given an unordered list of storage locations, calculate a function prototype. | |
virtual bool | possibleParam (const Address &loc, int4 size) const |
Does the given storage location make sense as a parameter. | |
virtual bool | isAutoKillByCall (void) const |
Return true if ParamEntry locations should automatically be considered killed by call. | |
virtual void | decode (Decoder &decoder, vector< EffectRecord > &effectlist, bool normalstack) |
Restore the model from an <input> or <output> element in the stream. | |
virtual ParamList * | clone (void) const |
Clone this parameter list model. | |
![]() | |
ParamListStandard (void) | |
Construct for use with decode() | |
ParamListStandard (const ParamListStandard &op2) | |
Copy constructor. | |
const list< ParamEntry > & | getEntry (void) const |
Get the list of parameter entries. | |
list< ParamEntry >::const_iterator | getFirstIter (type_class type) const |
Get iterator to first entry in a storage class. | |
const ParamEntry * | getStackEntry (void) const |
Get the stack entry. | |
uint4 | assignAddressFallback (type_class resource, Datatype *tp, bool matchExact, vector< int4 > &status, ParameterPieces ¶m) const |
Assign storage for given parameter class, using the fallback assignment algorithm. | |
uint4 | assignAddress (Datatype *dt, const PrototypePieces &proto, int4 pos, TypeFactory &tlst, vector< int4 > &status, ParameterPieces &res) const |
Fill in the Address and other details for the given parameter. | |
virtual bool | checkJoin (const Address &hiaddr, int4 hisize, const Address &loaddr, int4 losize) const |
Check if the given two storage locations can represent a single logical parameter. | |
virtual bool | checkSplit (const Address &loc, int4 size, int4 splitpoint) const |
Check if it makes sense to split a single storage location into two parameters. | |
virtual int4 | characterizeAsParam (const Address &loc, int4 size) const |
Characterize whether the given range overlaps parameter storage. | |
virtual bool | possibleParamWithSlot (const Address &loc, int4 size, int4 &slot, int4 &slotsize) const |
Pass-back the slot and slot size for the given storage location as a parameter. | |
virtual bool | getBiggestContainedParam (const Address &loc, int4 size, VarnodeData &res) const |
Pass-back the biggest parameter contained within the given range. | |
virtual bool | unjustifiedContainer (const Address &loc, int4 size, VarnodeData &res) const |
Check if the given storage location looks like an unjustified parameter. | |
virtual OpCode | assumedExtension (const Address &addr, int4 size, VarnodeData &res) const |
Get the type of extension and containing parameter for the given storage. | |
virtual AddrSpace * | getSpacebase (void) const |
Get the address space associated with any stack based parameters in this list. | |
virtual bool | isThisBeforeRetPointer (void) const |
Return true if this pointer occurs before an indirect return pointer. | |
virtual void | getRangeList (AddrSpace *spc, RangeList &res) const |
For a given address space, collect all the parameter locations within that space. | |
virtual int4 | getMaxDelay (void) const |
Return the maximum heritage delay across all possible parameters. | |
![]() | |
virtual | ~ParamList (void) |
Destructor. | |
Private Member Functions | |
void | initialize (void) |
Cache ModelRule information. | |
Private Attributes | |
bool | useFillinFallback |
If true, use fillinMapFallback. | |
Additional Inherited Members | |
![]() | |
enum | { p_standard , p_standard_out , p_register , p_register_out , p_merged } |
![]() | |
const ParamEntry * | findEntry (const Address &loc, int4 size, bool just) const |
Given storage location find matching ParamEntry. | |
const ParamEntry * | selectUnreferenceEntry (int4 grp, type_class prefType) const |
Select entry to fill an unreferenced param. | |
void | buildTrialMap (ParamActive *active) const |
Build map from parameter trials to model ParamEntrys. | |
void | separateSections (ParamActive *active, vector< int4 > &trialStart) const |
Calculate the range of trials in each resource sections. | |
void | calcDelay (void) |
Calculate the maximum heritage delay for any potential parameter in this list. | |
void | addResolverRange (AddrSpace *spc, uintb first, uintb last, ParamEntry *paramEntry, int4 position) |
Internal method for adding a single address range to the ParamEntryResolvers. | |
void | populateResolver (void) |
Build the ParamEntry resolver maps. | |
void | parsePentry (Decoder &decoder, vector< EffectRecord > &effectlist, int4 groupid, bool normalstack, bool autokill, bool splitFloat, bool grouped) |
Parse a <pentry> element and add it to this list. | |
void | parseGroup (Decoder &decoder, vector< EffectRecord > &effectlist, int4 groupid, bool normalstack, bool autokill, bool splitFloat) |
Parse a sequence of <pentry> elements that are allocated as a group. | |
![]() | |
static void | markGroupNoUse (ParamActive *active, int4 activeTrial, int4 trialStart) |
Mark all the trials within the indicated groups as not used, except for one specified index. | |
static void | markBestInactive (ParamActive *active, int4 group, int4 groupStart, type_class prefType) |
From among multiple inactive trials, select the most likely to be active and mark others as not used. | |
static void | forceExclusionGroup (ParamActive *active) |
Enforce exclusion rules for the given set of parameter trials. | |
static void | forceNoUse (ParamActive *active, int4 start, int4 stop) |
Mark every trial above the first "definitely not used" as inactive. | |
static void | forceInactiveChain (ParamActive *active, int4 maxchain, int4 start, int4 stop, int4 groupstart) |
Enforce rules about chains of inactive slots. | |
![]() | |
int4 | numgroup |
Number of groups in this parameter convention. | |
int4 | maxdelay |
Maximum heritage delay across all parameters. | |
bool | thisbeforeret |
Does a this parameter come before a hidden return parameter. | |
vector< int4 > | resourceStart |
The starting group for each resource section. | |
list< ParamEntry > | entry |
The ordered list of parameter entries. | |
vector< ParamEntryResolver * > | resolverMap |
Map from space id to resolver. | |
list< ModelRule > | modelRules |
Rules to apply when assigning addresses. | |
AddrSpace * | spacebase |
Address space containing relative offset parameters. | |
A standard model for returning output parameters from a function.
This has a more involved assignment strategy than its parent class. Entries in the resource list are treated as a group, meaning that only one can fit the desired storage size and type attributes of the return value. If no entry fits, the return value is converted to a pointer data-type, storage allocation is attempted again, and the return value is marked as a hidden return parameter to inform the input model.
|
virtual |
Given list of data-types, map the list positions to storage locations.
If we know the function prototype, recover how parameters are actually stored using the model.
proto | is the ordered list of data-types |
typefactory | is the TypeFactory (for constructing pointers) |
res | will contain the storage locations corresponding to the datatypes |
Reimplemented from ghidra::ParamListStandard.
Reimplemented in ghidra::ParamListRegisterOut.
References ghidra::ParamListStandard::assignAddress(), ghidra::ParamListStandard::assignAddressFallback(), ghidra::AssignAction::fail, ghidra::Datatype::flags, ghidra::AddrSpace::getAddrSize(), ghidra::TypeFactory::getArch(), ghidra::AddrSpaceManager::getDefaultDataSpace(), ghidra::Datatype::getMetatype(), ghidra::TypeFactory::getTypePointer(), ghidra::TypeFactory::getTypeVoid(), ghidra::AddrSpace::getWordSize(), ghidra::AssignAction::hiddenret_ptrparam, ghidra::AssignAction::hiddenret_specialreg, ghidra::AssignAction::hiddenret_specialreg_void, ghidra::ParameterPieces::hiddenretparm, ghidra::ParameterPieces::indirectstorage, ghidra::ParamListStandard::numgroup, ghidra::PrototypePieces::outtype, ghidra::ParamListStandard::spacebase, ghidra::TYPE_VOID, and ghidra::TYPECLASS_PTR.
|
virtual |
Clone this parameter list model.
Reimplemented from ghidra::ParamListStandard.
Reimplemented in ghidra::ParamListRegisterOut.
References ParamListStandardOut().
|
virtual |
Restore the model from an <input> or <output> element in the stream.
decoder | is the stream decoder |
effectlist | is a container collecting EffectRecords across all parameters |
normalstack | is true if parameters are pushed on the stack in the normal order |
Reimplemented from ghidra::ParamListStandard.
References ghidra::ParamListStandard::decode(), and initialize().
|
virtual |
Given an unordered list of storage locations, calculate a function prototype.
A list of input (or output) trials is given, which may have holes, invalid inputs etc. Decide on the formal ordered parameter list. Trials within the ParamActive are added, removed, or reordered as needed.
active | is the given list of trials |
Reimplemented from ghidra::ParamListStandard.
References ghidra::ParamListStandard::entry, fillinMapFallback(), ghidra::ParamListStandard::findEntry(), ghidra::ParamTrial::getAddress(), ghidra::ParamActive::getNumTrials(), ghidra::ParamTrial::getSize(), ghidra::ParamActive::getTrial(), ghidra::ParamTrial::isActive(), ghidra::ParamTrial::isIndCreateFormed(), ghidra::ParamTrial::isRemFormed(), ghidra::ParamTrial::markNoUse(), ghidra::ParamTrial::markUsed(), ghidra::ParamListStandard::modelRules, ghidra::ParamTrial::setEntry(), ghidra::ParamActive::sortTrials(), and useFillinFallback.
void ghidra::ParamListStandardOut::fillinMapFallback | ( | ParamActive * | active, |
bool | firstOnly | ||
) | const |
Find the return value storage using the older fallback method.
Given the active set of trial locations that might hold (pieces of) the return value, calculate the best matching ParamEntry from this ParamList and mark all the trials that are contained in the ParamEntry as used. If firstOnly is true, the ParamList is assumed to contain partial storage locations that might get used for return values split storage. In this case, only the first ParamEntry in a storage class is allowed to match.
active | is the set of active trials |
firstOnly | is true if only the first entry in a storage class can match |
References ghidra::ParamListStandard::entry, ghidra::ParamTrial::getAddress(), ghidra::ParamEntry::getAllGroups(), ghidra::ParamTrial::getEntry(), ghidra::ParamActive::getNumTrials(), ghidra::ParamTrial::getOffset(), ghidra::ParamTrial::getSize(), ghidra::ParamActive::getTrial(), ghidra::ParamEntry::getType(), ghidra::ParamTrial::isActive(), ghidra::ParamEntry::isExclusion(), ghidra::ParamEntry::isFirstInClass(), ghidra::ParamTrial::isIndCreateFormed(), ghidra::ParamEntry::isParamCheckHigh(), ghidra::ParamEntry::isParamCheckLow(), ghidra::ParamTrial::isRemFormed(), ghidra::ParamEntry::justifiedContain(), ghidra::ParamTrial::markNoUse(), ghidra::ParamTrial::markUsed(), ghidra::ParamTrial::setEntry(), ghidra::ParamActive::sortTrials(), and ghidra::TYPECLASS_PTR.
Referenced by fillinMap().
|
inlinevirtual |
Get the type of parameter list.
Reimplemented from ghidra::ParamListStandard.
Reimplemented in ghidra::ParamListRegisterOut.
References ghidra::ParamList::p_standard_out.
|
inlinevirtual |
Return true if ParamEntry locations should automatically be considered killed by call.
Reimplemented from ghidra::ParamListStandard.
References useFillinFallback.
|
virtual |
Does the given storage location make sense as a parameter.
Within this model, decide if the storage location can be considered a parameter.
loc | is the starting address of the storage location |
size | is the number of bytes in the storage location |
Reimplemented from ghidra::ParamListStandard.
References ghidra::ParamListStandard::entry.