Ghidra Decompiler Analysis Engine
|
A contiguous range of memory that can be used to pass parameters. More...
#include <fspec.hh>
Public Types | |
enum | { force_left_justify = 1, reverse_stack = 2, smallsize_zext = 4, smallsize_sext = 8, smallsize_inttype = 32, smallsize_floatext = 64, extracheck_high = 128, extracheck_low = 256 } |
Public Member Functions | |
ParamEntry (type_metatype t, int4 grp, int4 grpsize, const Address &loc, int4 sz, int4 mnsz, int4 align, bool normalstack) | |
Construct entry from components. More... | |
bool | contains (const ParamEntry &op2) const |
Does this contain the indicated entry. More... | |
bool | containedBy (const Address &addr, int4 sz) const |
Is this entry contained by the given range. More... | |
int4 | justifiedContain (const Address &addr, int4 sz) const |
Calculate endian aware containment. More... | |
bool | getContainer (const Address &addr, int4 sz, VarnodeData &res) const |
Calculate the containing memory range. More... | |
OpCode | assumedExtension (const Address &addr, int4 sz, VarnodeData &res) const |
Calculate the type of extension to expect for the given logical value. More... | |
int4 | getSlot (const Address &addr, int4 skip) const |
Calculate the slot occupied by a specific address. More... | |
Address | getAddrBySlot (int4 &slot, int4 sz) const |
Calculate the storage address assigned when allocating a parameter of a given size. More... | |
void | restoreXml (const Element *el, const AddrSpaceManager *manage, bool normalstack) |
Restore the entry from an XML stream. More... | |
void | extraChecks (list< ParamEntry > &entry) |
Check if this entry represents a joined parameter and requires extra scrutiny. More... | |
A contiguous range of memory that can be used to pass parameters.
This range can be used to pass a single parameter (isExclusion() == true). This is intended to model a parameter passed in a register. The logical value does not have to fill the entire range. The size in bytes can range from a minimum, getMinSize(), to the whole range, getSize(). Justification and extension of the logical value within the range can be specified.
Alternately the range can be used as a resource for multiple parameters (isExclusion() == false). In this case, the parameters are allocated sequentially (usually) starting from the front of the range. The amount of space consumed by each parameter is dictated by an alignment setting in bytes.
A ParamEntry can be associated with a particular class of data-types. Usually:
anonymous enum |
ParamEntry::ParamEntry | ( | type_metatype | t, |
int4 | grp, | ||
int4 | grpsize, | ||
const Address & | loc, | ||
int4 | sz, | ||
int4 | mnsz, | ||
int4 | align, | ||
bool | normalstack | ||
) |
Construct entry from components.
t | is the data-type class (TYPE_UNKNOWN or TYPE_FLOAT) |
grp | is the group id |
grpsize | is the number of consecutive groups occupied |
loc | is the starting address of the memory range |
sz | is the number of bytes in the range |
mnsz | is the smallest size of a logical value |
align | is the alignment (0 means the memory range will hold one parameter exclusively) |
normalstack | is true if parameters are allocated from the front of the range |
OpCode ParamEntry::assumedExtension | ( | const Address & | addr, |
int4 | sz, | ||
VarnodeData & | res | ||
) | const |
Calculate the type of extension to expect for the given logical value.
Return:
(A CPUI_FLOAT2FLOAT=float extension is handled by heritage and JoinRecord) If returning an extension operator, pass back the container being extended.
addr | is the starting address of the logical value |
sz | is the size of the logical value in bytes |
res | will hold the passed back containing range |
bool ParamEntry::containedBy | ( | const Address & | addr, |
int4 | sz | ||
) | const |
Is this entry contained by the given range.
addr | is the starting address of the potential containing range |
sz | is the number of bytes in the range |
bool ParamEntry::contains | ( | const ParamEntry & | op2 | ) | const |
Does this contain the indicated entry.
This entry must properly contain the other memory range, and the entry properties must be compatible.
op2 | is the other entry to compare with this |
void ParamEntry::extraChecks | ( | list< ParamEntry > & | entry | ) |
Check if this entry represents a joined parameter and requires extra scrutiny.
Return value parameter lists allow overlapping entries if one of the overlapping entries is a joined parameter. In this case the return value recovery logic needs to know what portion(s) of the joined parameter are overlapped. This method sets flags on this to indicate the overlap.
entry | is the full parameter list to check for overlaps with this |
Address ParamEntry::getAddrBySlot | ( | int4 & | slotnum, |
int4 | sz | ||
) | const |
Calculate the storage address assigned when allocating a parameter of a given size.
Assume slotnum slots have already been assigned and increment slotnum by the number of slots used. Return an invalid address if the size is too small or if there are not enough slots left.
slotnum | is a reference to used slots (which will be updated) |
sz | is the size of the parameter to allocated |
bool ParamEntry::getContainer | ( | const Address & | addr, |
int4 | sz, | ||
VarnodeData & | res | ||
) | const |
Calculate the containing memory range.
Pass back the VarnodeData (space,offset,size) of the parameter that would contain the given memory range. If this contains the range and is exclusive, just pass back this memory range. Otherwise the passed back range will depend on alignment.
addr | is the starting address of the given range |
sz | is the size of the given range in bytes |
res | is the reference to VarnodeData that will be passed back |
int4 ParamEntry::getSlot | ( | const Address & | addr, |
int4 | skip | ||
) | const |
Calculate the slot occupied by a specific address.
For non-exclusive entries, the memory range can be divided up into slots, which are chunks that take up a full alignment. I.e. for an entry with alignment 4, slot 0 is bytes 0-3 of the range, slot 1 is bytes 4-7, etc. Assuming the given address is contained in this entry, and we skip ahead a number of bytes, return the slot associated with that byte. NOTE: its important that the given address has already been checked for containment.
addr | is the given address |
skip | is the number of bytes to skip ahead |
int4 ParamEntry::justifiedContain | ( | const Address & | addr, |
int4 | sz | ||
) | const |
Calculate endian aware containment.
Check if the given memory range is contained in this. If it is contained, return the endian aware offset of the containment. I.e. if the least significant byte of the given range falls on the least significant byte of the this, return 0. If it intersects the second least significant, return 1, etc.
addr | is the starting address of the given memory range |
sz | is the size of the given memory range in bytes |
void ParamEntry::restoreXml | ( | const Element * | el, |
const AddrSpaceManager * | manage, | ||
bool | normalstack | ||
) |
Restore the entry from an XML stream.
el | is the root <pentry> element |
manage | is a manager to resolve address space references |
normalstack | is true if the parameters should be allocated from the front of the range |