GP-4031 x86 System V ABI

This commit is contained in:
caheckman 2024-02-20 19:13:53 +00:00
parent 362f571b19
commit c674e1f2ec
20 changed files with 1668 additions and 185 deletions

View file

@ -88,12 +88,13 @@ public:
smallsize_zext = 4, ///< Assume values that are below the max \b size are zero extended into this container
smallsize_sext = 8, ///< Assume values that are below the max \b size are sign extended into this container
// is_big_endian = 16, ///< Set if this value should be treated as big endian
smallsize_inttype = 32, ///< Assume values that are below the max \b size are sign OR zero extended based on integer type
smallsize_floatext = 64, ///< Assume values smaller than max \b size are floating-point extended to full size
extracheck_high = 128, ///< Perform extra checks during parameter recovery on most sig portion of the double
extracheck_low = 256, ///< Perform extra checks during parameter recovery on least sig portion of the double
is_grouped = 512, ///< This entry is grouped with other entries
overlapping = 0x100 ///< Overlaps an earlier entry (and doesn't consume additional resource slots)
smallsize_inttype = 0x20, ///< Assume values that are below the max \b size are sign OR zero extended based on integer type
smallsize_floatext = 0x40, ///< Assume values smaller than max \b size are floating-point extended to full size
extracheck_high = 0x80, ///< Perform extra checks during parameter recovery on most sig portion of the double
extracheck_low = 0x100, ///< Perform extra checks during parameter recovery on least sig portion of the double
is_grouped = 0x200, ///< This entry is grouped with other entries
overlapping = 0x400, ///< Overlaps an earlier entry (and doesn't consume additional resource slots)
first_storage = 0x800 ///< Entry is first in its storage class
};
enum {
no_containment, ///< Range neither contains nor is contained by a ParamEntry
@ -113,6 +114,7 @@ private:
int4 numslots; ///< (Maximum) number of slots that can store separate parameters
JoinRecord *joinrec; ///< Non-null if this is logical variable from joined pieces
static const ParamEntry *findEntryByStorage(const list<ParamEntry> &entryList,const VarnodeData &vn);
void resolveFirst(list<ParamEntry> &curList); ///< Mark if \b this is the first ParamEntry in its storage class
void resolveJoin(list<ParamEntry> &curList); ///< Make adjustments for a \e join ParamEntry
void resolveOverlap(list<ParamEntry> &curList); ///< Make adjustments for ParamEntry that overlaps others
@ -132,6 +134,7 @@ public:
bool isReverseStack(void) const { return ((flags & reverse_stack)!=0); } ///< Return \b true if parameters are allocated in reverse order
bool isGrouped(void) const { return ((flags & is_grouped)!=0); } ///< Return \b true if \b this is grouped with other entries
bool isOverlap(void) const { return ((flags & overlapping)!=0); } ///< Return \b true if \b this overlaps another entry
bool isFirstInClass(void) const { return ((flags & first_storage)!=0); } ///< Return \b true if \b this is the first entry in the storage class
bool subsumesDefinition(const ParamEntry &op2) const; ///< Does \b this subsume the definition of the given ParamEntry
bool containedBy(const Address &addr,int4 sz) const; ///< Is this entry contained by the given range
bool intersects(const Address &addr,int4 sz) const; ///< Does \b this intersect the given range in some way
@ -554,6 +557,11 @@ public:
/// \return the maximum number of passes across all parameters in \b this model
virtual int4 getMaxDelay(void) const=0;
/// \brief Return \b true if ParamEntry locations should automatically be considered killed by call
///
/// \return \b true if automatically assume killbycall
virtual bool isAutoKillByCall(void) const=0;
/// \brief Restore the model from an \<input> or \<output> element in the stream
///
/// \param decoder is the stream decoder
@ -583,7 +591,7 @@ protected:
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
const ParamEntry *findEntry(const Address &loc,int4 size) const; ///< Given storage location find matching ParamEntry
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;
@ -604,6 +612,8 @@ public:
ParamListStandard(const ParamListStandard &op2); ///< Copy constructor
virtual ~ParamListStandard(void);
const list<ParamEntry> &getEntry(void) const { return entry; } ///< 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 &param) const;
uint4 assignAddress(Datatype *dt,const PrototypePieces &proto,int4 pos,TypeFactory &tlst,
@ -623,6 +633,7 @@ public:
virtual bool isThisBeforeRetPointer(void) const { return thisbeforeret; }
virtual void getRangeList(AddrSpace *spc,RangeList &res) const;
virtual int4 getMaxDelay(void) const { return maxdelay; }
virtual bool isAutoKillByCall(void) const { return false; }
virtual void decode(Decoder &decoder,vector<EffectRecord> &effectlist,bool normalstack);
virtual ParamList *clone(void) const;
};
@ -636,13 +647,19 @@ public:
/// attempted again, and the return value is marked as a \e hidden return parameter
/// to inform the input model.
class ParamListStandardOut : public ParamListStandard {
bool useFillinFallback; ///< If \b true, use fillinMapFallback
void initialize(void); ///< Cache ModelRule information
public:
ParamListStandardOut(void) : ParamListStandard() {} ///< Constructor for use with decode()
ParamListStandardOut(const ParamListStandardOut &op2) : ParamListStandard(op2) {} ///< Copy constructor
ParamListStandardOut(const ParamListStandardOut &op2) : ParamListStandard(op2) {
useFillinFallback = op2.useFillinFallback; } ///< Copy constructor
void fillinMapFallback(ParamActive *active,bool firstOnly) const;
virtual uint4 getType(void) const { return p_standard_out; }
virtual void assignMap(const PrototypePieces &proto,TypeFactory &typefactory,vector<ParameterPieces> &res) const;
virtual void fillinMap(ParamActive *active) const;
virtual bool possibleParam(const Address &loc,int4 size) const;
virtual bool isAutoKillByCall(void) const { return useFillinFallback; }
virtual void decode(Decoder &decoder,vector<EffectRecord> &effectlist,bool normalstack);
virtual ParamList *clone(void) const;
};
@ -971,6 +988,11 @@ public:
/// \return the maximum number of passes across all output parameters in \b this model
int4 getMaxOutputDelay(void) const { return output->getMaxDelay(); }
/// \brief Does \b this model automatically consider potential output locations as killed by call
///
/// \return \b true if output locations should be considered killed by call
bool isAutoKillByCall(void) const { return output->isAutoKillByCall(); }
/// \brief Is \b this a merged prototype model
///
/// \return \b true if \b this is a merged form of multiple independent prototype models
@ -1323,7 +1345,8 @@ class FuncProto {
is_constructor = 0x200, ///< Function is an (object-oriented) constructor
is_destructor = 0x400, ///< Function is an (object-oriented) destructor
has_thisptr= 0x800, ///< Function is a method with a 'this' pointer as an argument
is_override = 0x1000 ///< Set if \b this prototype is created to override a single call site
is_override = 0x1000, ///< Set if \b this prototype is created to override a single call site
auto_killbycall = 0x2000 ///< Potential output storage should always be considered \e killed \e by \e call
};
ProtoModel *model; ///< Model of for \b this prototype
ProtoStore *store; ///< Storage interface for parameters
@ -1583,6 +1606,8 @@ public:
/// \return the active set of flags for \b this prototype
uint4 getComparableFlags(void) const { return (flags & (dotdotdot | is_constructor | is_destructor | has_thisptr )); }
bool isAutoKillByCall(void) const; ///< Is a potential output automatically considered \e killed \e by \e call
void encode(Encoder &encoder) const;
void decode(Decoder &decoder,Architecture *glb);
};