Refactor ParamEntry look-up allowing "contained by" discovery

This commit is contained in:
caheckman 2019-07-08 13:54:03 -04:00
parent ef12c20829
commit 12d3da029b
13 changed files with 690 additions and 286 deletions

View file

@ -112,7 +112,7 @@ public:
typedef EntrySubsort subsorttype; ///< The sub-sort object for a rangemap
typedef EntryInitData inittype; ///< Initialization data for a SymbolEntry in a rangemap
SymbolEntry(uintb a,uintb b); ///< Construct given just the offset range
SymbolEntry(void) {} ///< Constructor for use with rangemap
SymbolEntry(Symbol *sym,uint4 exfl,uint8 h,int4 off,int4 sz,const RangeList &rnglist); ///< Construct a dynamic SymbolEntry
bool isPiece(void) const { return ((extraflags&(Varnode::precislo|Varnode::precishi))!=0); } ///< Is \b this a high or low piece of the whole Symbol
bool isDynamic(void) const { return addr.isInvalid(); } ///< Is \b storage \e dynamic
@ -122,7 +122,7 @@ public:
uintb getFirst(void) const { return addr.getOffset(); } ///< Get the first offset of \b this storage location
uintb getLast(void) const { return (addr.getOffset()+size-1); } ///< Get the last offset of \b this storage location
subsorttype getSubsort(void) const; ///< Get the sub-sort object
void initialize(const EntryInitData &data); ///< Fully initialize \b this
void initialize(const EntryInitData &data,uintb a,uintb b); ///< Fully initialize \b this
Symbol *getSymbol(void) const { return symbol; } ///< Get the Symbol associated with \b this
const Address &getAddr(void) const { return addr; } ///< Get the starting address of \b this storage
uint8 getHash(void) const { return hash; } ///< Get the hash used to identify \b this storage
@ -577,18 +577,6 @@ public:
/// \return an overlapping SymbolEntry or NULL if none exists
virtual SymbolEntry *findOverlap(const Address &addr,int4 size) const=0;
/// \brief Find first Symbol before (but not containing) a given address
///
/// \param addr is the given address
/// \return the SymbolEntry occurring immediately before or NULL if none exists
virtual SymbolEntry *findBefore(const Address &addr) const=0;
/// \brief Find first Symbol after (but not containing) a given address
///
/// \param addr is the given address
/// \return a SymbolEntry occurring immediately after or NULL if none exists
virtual SymbolEntry *findAfter(const Address &addr) const=0;
/// \brief Find a Symbol by name within \b this Scope
///
/// If there are multiple Symbols with the same name, all are passed back.
@ -741,8 +729,6 @@ public:
virtual ExternRefSymbol *findExternalRef(const Address &addr) const;
virtual LabSymbol *findCodeLabel(const Address &addr) const;
virtual SymbolEntry *findOverlap(const Address &addr,int4 size) const;
virtual SymbolEntry *findBefore(const Address &addr) const;
virtual SymbolEntry *findAfter(const Address &addr) const;
virtual void findByName(const string &name,vector<Symbol *> &res) const;
virtual Funcdata *resolveExternalRefFunction(ExternRefSymbol *sym) const;
@ -786,12 +772,13 @@ private:
Address first; ///< The first address of the range
Address last; ///< The last address of the range
public:
ScopeMapper(Address f,Address l) { first=f; last=l; } ///< Construct given an address range
ScopeMapper(void) {} ///< Constructor for use with rangemap
Address getFirst(void) const { return first; } ///< Get the first address in the range
Address getLast(void) const { return last; } ///< Get the last address in the range
NullSubsort getSubsort(void) const { return NullSubsort(); } ///< Get the sub-subsort object
Scope *getScope(void) const { return scope; } ///< Get the Scope owning this address range
void initialize(const inittype &data) { scope = data; } ///< Initialize the range (with the owning Scope)
void initialize(const inittype &data,const Address &f,const Address &l) {
scope = data; first = f; last = l; } ///< Initialize the range (with the owning Scope)
};
typedef rangemap<ScopeMapper> ScopeResolve; ///< A map from address to the owning Scope