decompiler  1.0.0
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ParamEntry Class Reference

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 (int4 grp)
 Constructor for use with restoreXml.
 
 ParamEntry (type_metatype t, int4 grp, int4 grpsize, const Address &loc, int4 sz, int4 mnsz, int4 align, bool normalstack)
 Construct entry from components. More...
 
int4 getGroup (void) const
 Get the group id this belongs to.
 
int4 getGroupSize (void) const
 Get the number of groups occupied by this.
 
int4 getSize (void) const
 Get the size of the memory range in bytes.
 
int4 getMinSize (void) const
 Get the minimum size of a logical value contained in this.
 
int4 getAlign (void) const
 Get the alignment of this entry.
 
type_metatype getType (void) const
 Get the data-type class associated with this.
 
bool isExclusion (void) const
 Return true if this holds a single parameter exclusively.
 
bool isReverseStack (void) const
 Return true if parameters are allocated in reverse order.
 
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...
 
AddrSpacegetSpace (void) const
 Get the address space containing this entry.
 
uintb getBase (void) const
 Get the starting offset of this entry.
 
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...
 
bool isParamCheckHigh (void) const
 Return true if there is a high overlap.
 
bool isParamCheckLow (void) const
 Return true if there is a low overlap.
 

Private Member Functions

void resolveJoin (void)
 If the ParamEntry is initialized with a join address, cache the join record.
 
bool isLeftJustified (void) const
 Is the logical value left-justified within its container.
 

Private Attributes

uint4 flags
 Boolean properties of the parameter.
 
type_metatype type
 Data-type class that this entry must match.
 
int4 group
 Group of (mutually exclusive) entries that this entry belongs to.
 
int4 groupsize
 The number of consecutive groups taken by the entry.
 
AddrSpacespaceid
 Address space containing the range.
 
uintb addressbase
 Starting offset of the range.
 
int4 size
 Size of the range in bytes.
 
int4 minsize
 Minimum bytes allowed for the logical value.
 
int4 alignment
 How much alignment (0 means only 1 logical value is allowed)
 
int4 numslots
 (Maximum) number of slots that can store separate parameters
 
JoinRecordjoinrec
 Non-null if this is logical variable from joined pieces.
 

Detailed Description

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:

Member Enumeration Documentation

anonymous enum
Enumerator
force_left_justify 

Big endian values are left justified within their slot.

reverse_stack 

Slots (for non-exlusion entries) are allocated in reverse order.

smallsize_zext 

Assume values that are below the max size are zero extended into this container.

smallsize_sext 

Assume values that are below the max size are sign extended into this container.

smallsize_inttype 

Assume values that are below the max size are sign OR zero extended based on integer type.

smallsize_floatext 

Assume values smaller than max size are floating-point extended to full size.

extracheck_high 

Perform extra checks during parameter recovery on most sig portion of the double.

extracheck_low 

Perform extra checks during parameter recovery on least sig portion of the double.

Constructor & Destructor Documentation

ParamEntry::ParamEntry ( type_metatype  t,
int4  grp,
int4  grpsize,
const Address loc,
int4  sz,
int4  mnsz,
int4  align,
bool  normalstack 
)

Construct entry from components.

Parameters
tis the data-type class (TYPE_UNKNOWN or TYPE_FLOAT)
grpis the group id
grpsizeis the number of consecutive groups occupied
locis the starting address of the memory range
szis the number of bytes in the range
mnszis the smallest size of a logical value
alignis the alignment (0 means the memory range will hold one parameter exclusively)
normalstackis true if parameters are allocated from the front of the range

References addressbase, alignment, flags, Address::getOffset(), Address::getSpace(), group, groupsize, minsize, numslots, resolveJoin(), reverse_stack, size, spaceid, and type.

Member Function Documentation

OpCode ParamEntry::assumedExtension ( const Address addr,
int4  sz,
VarnodeData res 
) const

Calculate the type of extension to expect for the given logical value.

Return:

  • CPUI_COPY if no extensions are assumed for small values in this container
  • CPUI_INT_SEXT indicates a sign extension
  • CPUI_INT_ZEXT indicates a zero extension
  • CPUI_PIECE indicates an integer extension based on type of parameter

(A CPUI_FLOAT2FLOAT=float extension is handled by heritage and JoinRecord) If returning an extension operator, pass back the container being extended.

Parameters
addris the starting address of the logical value
szis the size of the logical value in bytes
reswill hold the passed back containing range
Returns
the type of extension

References addressbase, alignment, CPUI_COPY, CPUI_INT_SEXT, CPUI_INT_ZEXT, CPUI_PIECE, flags, Address::getOffset(), joinrec, justifiedContain(), VarnodeData::offset, VarnodeData::size, size, smallsize_inttype, smallsize_sext, smallsize_zext, VarnodeData::space, and spaceid.

bool ParamEntry::containedBy ( const Address addr,
int4  sz 
) const

Is this entry contained by the given range.

Parameters
addris the starting address of the potential containing range
szis the number of bytes in the range
Returns
true if the entire ParamEntry fits inside the range

References addressbase, Address::getOffset(), Address::getSpace(), size, and spaceid.

Referenced by ParamListStandard::characterizeAsParam(), and ParamListStandard::getBiggestContainedParam().

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.

Parameters
op2is the other entry to compare with this
Returns
true if the other entry is contained

References addressbase, alignment, size, spaceid, type, and TYPE_UNKNOWN.

Referenced by ParamListMerged::foldIn().

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.

Parameters
entryis the full parameter list to check for overlaps with this

References extracheck_high, extracheck_low, flags, JoinRecord::getPiece(), joinrec, and JoinRecord::numPieces().

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.

Parameters
slotnumis a reference to used slots (which will be updated)
szis the size of the parameter to allocated
Returns
the address of the new parameter (or an invalid address)

References addressbase, alignment, AddrSpaceManager::constructFloatExtensionAddress(), flags, AddrSpace::getManager(), isLeftJustified(), isReverseStack(), minsize, numslots, size, smallsize_floatext, and spaceid.

Referenced by ParamListStandard::assignAddress(), and ParamListStandard::buildTrialMap().

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.

Parameters
addris the starting address of the given range
szis the size of the given range in bytes
resis the reference to VarnodeData that will be passed back
Returns
true if the given range is contained at all

References addressbase, alignment, Address::getOffset(), JoinRecord::getPiece(), joinrec, JoinRecord::numPieces(), VarnodeData::offset, Address::overlap(), VarnodeData::size, size, VarnodeData::space, and spaceid.

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.

Parameters
addris the given address
skipis the number of bytes to skip ahead
Returns
the slot index

References addressbase, alignment, Address::getOffset(), group, groupsize, isReverseStack(), and numslots.

Referenced by ParamListStandard::buildTrialMap(), ParamActive::freePlaceholderSlot(), ParamListStandard::possibleParamWithSlot(), and ParamTrial::slotGroup().

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.

Parameters
addris the starting address of the given memory range
szis the size of the given memory range in bytes
Returns
the endian aware alignment or -1 if the given range isn't contained

References addressbase, alignment, flags, force_left_justify, VarnodeData::getAddr(), Address::getOffset(), JoinRecord::getPiece(), Address::getSpace(), isLeftJustified(), joinrec, Address::justifiedContain(), JoinRecord::numPieces(), size, and spaceid.

Referenced by assumedExtension(), ParamListStandard::characterizeAsParam(), ParamListStandardOut::fillinMap(), and ParamListStandard::findEntry().

void ParamEntry::restoreXml ( const Element el,
const AddrSpaceManager manage,
bool  normalstack 
)

Restore the entry from an XML stream.

Parameters
elis the root <pentry> element
manageis a manager to resolve address space references
normalstackis true if the parameters should be allocated from the front of the range

References addressbase, alignment, flags, force_left_justify, Element::getAttributeName(), Element::getAttributeValue(), Element::getChildren(), Element::getNumAttributes(), Address::getOffset(), Address::getSpace(), group, groupsize, minsize, numslots, resolveJoin(), Address::restoreXml(), reverse_stack, size, smallsize_floatext, smallsize_inttype, smallsize_sext, smallsize_zext, spaceid, string2metatype(), type, and TYPE_UNKNOWN.


The documentation for this class was generated from the following files: