mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
Adjustments to get rid of some compiler warnings
This commit is contained in:
parent
22769f2234
commit
41d0be6b95
31 changed files with 317 additions and 326 deletions
|
@ -229,7 +229,6 @@ AddrSpace *Architecture::getSpaceBySpacebase(const Address &loc,int4 size) const
|
|||
}
|
||||
}
|
||||
throw LowlevelError("Unable to find entry for spacebase register");
|
||||
return (AddrSpace *)0;
|
||||
}
|
||||
|
||||
/// Look-up the laned register record associated with a specific storage location. Currently, the
|
||||
|
|
|
@ -890,18 +890,18 @@ void BlockGraph::identifyInternal(BlockGraph *ident,const vector<FlowBlock *> &n
|
|||
ident->selfIdentify();
|
||||
}
|
||||
|
||||
/// \param flags is the set of boolean properties
|
||||
void BlockGraph::clearEdgeFlags(uint4 flags)
|
||||
/// \param fl is the set of boolean properties
|
||||
void BlockGraph::clearEdgeFlags(uint4 fl)
|
||||
|
||||
{
|
||||
flags = ~flags;
|
||||
fl = ~fl;
|
||||
int4 size = list.size();
|
||||
for(int4 i=0;i<size;++i) {
|
||||
FlowBlock *bl = list[i];
|
||||
for(int4 j=0;j<size;++j) {
|
||||
FlowBlock *bl = list[j];
|
||||
for(int4 i=0;i<bl->intothis.size();++i)
|
||||
bl->intothis[i].label &= flags;
|
||||
bl->intothis[i].label &= fl;
|
||||
for(int4 i=0;i<bl->outofthis.size();++i)
|
||||
bl->outofthis[i].label &= flags;
|
||||
bl->outofthis[i].label &= fl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3350,8 +3350,8 @@ void BlockSwitch::finalizePrinting(Funcdata &data) const
|
|||
CaseOrder &curcase( caseblocks[i] );
|
||||
if (jump->numIndicesByBlock(curcase.basicblock) > 0) {
|
||||
if (curcase.depth == 0) { // Only set label on chain roots
|
||||
int4 index = jump->getIndexByBlock(curcase.basicblock,0);
|
||||
curcase.label = jump->getLabelByIndex(index);
|
||||
int4 ind = jump->getIndexByBlock(curcase.basicblock,0);
|
||||
curcase.label = jump->getLabelByIndex(ind);
|
||||
int4 j = curcase.chain;
|
||||
int4 depthcount = 1;
|
||||
while(j != -1) {
|
||||
|
|
|
@ -274,7 +274,7 @@ class BlockGraph : public FlowBlock {
|
|||
void forceOutputNum(int4 i); ///< Force number of outputs
|
||||
void selfIdentify(void); ///< Inherit our edges from the edges of our components
|
||||
void identifyInternal(BlockGraph *ident,const vector<FlowBlock *> &nodes);
|
||||
void clearEdgeFlags(uint4 flags); ///< Clear a set of properties from all edges in the graph
|
||||
void clearEdgeFlags(uint4 fl); ///< Clear a set of properties from all edges in the graph
|
||||
static FlowBlock *createVirtualRoot(const vector<FlowBlock *> &rootlist);
|
||||
void findSpanningTree(vector<FlowBlock *> &preorder,vector<FlowBlock *> &rootlist);
|
||||
bool findIrreducible(const vector<FlowBlock *> &preorder,int4 &irreduciblecount);
|
||||
|
|
|
@ -338,10 +338,10 @@ bool ConditionMarker::finalJudgement(Varnode *vn)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool ConditionMarker::verifyCondition(PcodeOp *op,PcodeOp *initop)
|
||||
bool ConditionMarker::verifyCondition(PcodeOp *op,PcodeOp *iop)
|
||||
|
||||
{
|
||||
setupInitOp(initop);
|
||||
setupInitOp(iop);
|
||||
Varnode *matchvn = findMatch(op);
|
||||
if (matchvn == (Varnode *)0) return false;
|
||||
if (!finalJudgement(matchvn)) return false;
|
||||
|
|
|
@ -55,7 +55,7 @@ class ConditionMarker {
|
|||
public:
|
||||
ConditionMarker(void); ///< Constructor
|
||||
~ConditionMarker(void); ///< Destructor
|
||||
bool verifyCondition(PcodeOp *op, PcodeOp *initop); ///< Perform the correlation test on two CBRANCH operations
|
||||
bool verifyCondition(PcodeOp *op, PcodeOp *iop); ///< Perform the correlation test on two CBRANCH operations
|
||||
int4 getMultiSlot(void) const { return multislot; } ///< Get the MULTIEQUAL slot in the critical path
|
||||
bool getFlip(void) const { return matchflip; } ///< Return \b true is the expressions are anti-correlated
|
||||
static bool varnodeSame(Varnode *a,Varnode *b);
|
||||
|
|
|
@ -1895,8 +1895,8 @@ int4 ActionRestrictLocal::apply(Funcdata &data)
|
|||
if (!fc->isInputLocked()) continue;
|
||||
if (fc->getSpacebaseOffset() == FuncCallSpecs::offset_unknown) continue;
|
||||
int4 numparam = fc->numParams();
|
||||
for(int4 i=0;i<numparam;++i) {
|
||||
ProtoParameter *param = fc->getParam(i);
|
||||
for(int4 j=0;j<numparam;++j) {
|
||||
ProtoParameter *param = fc->getParam(j);
|
||||
Address addr = param->getAddress();
|
||||
if (addr.getSpace()->getType() != IPTR_SPACEBASE) continue;
|
||||
uintb off = addr.getSpace()->wrapOffset(fc->getSpacebaseOffset() + addr.getOffset());
|
||||
|
@ -2516,7 +2516,6 @@ void ActionNameVars::lookForFuncParamNames(Funcdata &data,const vector<Varnode *
|
|||
if (!sym->isNameUndefined()) continue;
|
||||
iter = recmap.find(high);
|
||||
if (iter != recmap.end()) {
|
||||
Symbol *sym = high->getSymbol();
|
||||
sym->getScope()->renameSymbol(sym,localmap->makeNameUnique((*iter).second.namerec));
|
||||
}
|
||||
}
|
||||
|
@ -3873,9 +3872,6 @@ void ActionPrototypeTypes::extendInput(Funcdata &data,Varnode *invn,ProtoParamet
|
|||
int4 ActionPrototypeTypes::apply(Funcdata &data)
|
||||
|
||||
{
|
||||
int4 i;
|
||||
PcodeOp *op;
|
||||
Varnode *vn;
|
||||
list<PcodeOp *>::const_iterator iter,iterend;
|
||||
|
||||
// Set the evalutation prototype if we are not already locked
|
||||
|
@ -3891,10 +3887,10 @@ int4 ActionPrototypeTypes::apply(Funcdata &data)
|
|||
// (Because we don't want to see this compiler
|
||||
// mechanism in the high-level C output)
|
||||
for(iter=data.beginOp(CPUI_RETURN);iter!=iterend;++iter) {
|
||||
op = *iter;
|
||||
PcodeOp *op = *iter;
|
||||
if (op->isDead()) continue;
|
||||
if (!op->getIn(0)->isConstant()) {
|
||||
vn = data.newConstant(op->getIn(0)->getSize(),0);
|
||||
Varnode *vn = data.newConstant(op->getIn(0)->getSize(),0);
|
||||
data.opSetInput(op,vn,0);
|
||||
}
|
||||
}
|
||||
|
@ -3903,10 +3899,10 @@ int4 ActionPrototypeTypes::apply(Funcdata &data)
|
|||
ProtoParameter *outparam = data.getFuncProto().getOutput();
|
||||
if (outparam->getType()->getMetatype() != TYPE_VOID) {
|
||||
for(iter=data.beginOp(CPUI_RETURN);iter!=iterend;++iter) {
|
||||
op = *iter;
|
||||
PcodeOp *op = *iter;
|
||||
if (op->isDead()) continue;
|
||||
if (op->getHaltType() != 0) continue;
|
||||
vn = data.newVarnode(outparam->getSize(),outparam->getAddress());
|
||||
Varnode *vn = data.newVarnode(outparam->getSize(),outparam->getAddress());
|
||||
data.opInsertInput(op,vn,op->numInput());
|
||||
vn->updateType(outparam->getType(),true,true);
|
||||
}
|
||||
|
@ -3952,7 +3948,7 @@ int4 ActionPrototypeTypes::apply(Funcdata &data)
|
|||
topbl = (BlockBasic *)data.getBasicBlocks().getBlock(0);
|
||||
|
||||
int4 numparams = data.getFuncProto().numParams();
|
||||
for(i=0;i<numparams;++i) {
|
||||
for(int4 i=0;i<numparams;++i) {
|
||||
ProtoParameter *param = data.getFuncProto().getParam(i);
|
||||
Varnode *vn = data.newVarnode( param->getSize(), param->getAddress());
|
||||
vn = data.setInputVarnode(vn);
|
||||
|
@ -4509,9 +4505,9 @@ bool ActionInferTypes::propagateTypeEdge(TypeFactory *typegrp,PcodeOp *op,int4 i
|
|||
break;
|
||||
case CPUI_NEW:
|
||||
{
|
||||
Varnode *invn = op->getIn(0);
|
||||
if (!invn->isWritten()) return false; // Don't propagate
|
||||
if (invn->getDef()->code() != CPUI_CPOOLREF) return false;
|
||||
Varnode *vn0 = op->getIn(0);
|
||||
if (!vn0->isWritten()) return false; // Don't propagate
|
||||
if (vn0->getDef()->code() != CPUI_CPOOLREF) return false;
|
||||
newtype = alttype; // Propagate cpool result as result of new operator
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -1168,27 +1168,27 @@ Scope::~Scope(void)
|
|||
/// If there are no Symbols in \b this Scope, recurse into the parent Scope.
|
||||
/// If there are 1 (or more) Symbols matching in \b this Scope, add them to
|
||||
/// the result list
|
||||
/// \param name is the name to search for
|
||||
/// \param nm is the name to search for
|
||||
/// \param res is the result list
|
||||
void Scope::queryByName(const string &name,vector<Symbol *> &res) const
|
||||
void Scope::queryByName(const string &nm,vector<Symbol *> &res) const
|
||||
|
||||
{
|
||||
findByName(name,res);
|
||||
findByName(nm,res);
|
||||
if (!res.empty())
|
||||
return;
|
||||
if (parent != (Scope *)0)
|
||||
parent->queryByName(name,res);
|
||||
parent->queryByName(nm,res);
|
||||
}
|
||||
|
||||
/// Starting with \b this Scope, find a function with the given name.
|
||||
/// If there are no Symbols with that name in \b this Scope at all, recurse into the parent Scope.
|
||||
/// \param name if the name to search for
|
||||
/// \param nm if the name to search for
|
||||
/// \return the Funcdata object of the matching function, or NULL if it doesn't exist
|
||||
Funcdata *Scope::queryFunction(const string &name) const
|
||||
Funcdata *Scope::queryFunction(const string &nm) const
|
||||
|
||||
{
|
||||
vector<Symbol *> symList;
|
||||
queryByName(name,symList);
|
||||
queryByName(nm,symList);
|
||||
for(int4 i=0;i<symList.size();++i) {
|
||||
Symbol *sym = symList[i];
|
||||
FunctionSymbol *funcsym = dynamic_cast<FunctionSymbol *>(sym);
|
||||
|
@ -1284,23 +1284,23 @@ LabSymbol *Scope::queryCodeLabel(const Address &addr) const
|
|||
}
|
||||
|
||||
/// Look for the immediate child of \b this with a given name
|
||||
/// \param name is the child's name
|
||||
/// \param nm is the child's name
|
||||
/// \param strategy is \b true if hash of the name determines id
|
||||
/// \return the child Scope or NULL if there is no child with that name
|
||||
Scope *Scope::resolveScope(const string &name,bool strategy) const
|
||||
Scope *Scope::resolveScope(const string &nm,bool strategy) const
|
||||
|
||||
{
|
||||
if (strategy) {
|
||||
uint8 key = hashScopeName(uniqueId, name);
|
||||
uint8 key = hashScopeName(uniqueId, nm);
|
||||
ScopeMap::const_iterator iter = children.find(key);
|
||||
if (iter == children.end()) return (Scope *)0;
|
||||
Scope *scope = (*iter).second;
|
||||
if (scope->name == name)
|
||||
if (scope->name == nm)
|
||||
return scope;
|
||||
}
|
||||
else if (name.length() > 0 && name[0] <= '9' && name[0] >= '0') {
|
||||
else if (nm.length() > 0 && nm[0] <= '9' && nm[0] >= '0') {
|
||||
// Allow the string to directly specify the id
|
||||
istringstream s(name);
|
||||
istringstream s(nm);
|
||||
s.unsetf(ios::dec | ios::hex | ios::oct);
|
||||
uint8 key;
|
||||
s >> key;
|
||||
|
@ -1312,7 +1312,7 @@ Scope *Scope::resolveScope(const string &name,bool strategy) const
|
|||
ScopeMap::const_iterator iter;
|
||||
for(iter=children.begin();iter!=children.end();++iter) {
|
||||
Scope *scope = (*iter).second;
|
||||
if (scope->name == name)
|
||||
if (scope->name == nm)
|
||||
return scope;
|
||||
}
|
||||
}
|
||||
|
@ -1479,15 +1479,15 @@ const Scope *Scope::findDistinguishingScope(const Scope *op2) const
|
|||
}
|
||||
|
||||
/// The Symbol is created and added to any name map, but no SymbolEntry objects are created for it.
|
||||
/// \param name is the name of the new Symbol
|
||||
/// \param nm is the name of the new Symbol
|
||||
/// \param ct is a data-type to assign to the new Symbol
|
||||
/// \return the new Symbol object
|
||||
Symbol *Scope::addSymbol(const string &name,Datatype *ct)
|
||||
Symbol *Scope::addSymbol(const string &nm,Datatype *ct)
|
||||
|
||||
{
|
||||
Symbol *sym;
|
||||
|
||||
sym = new Symbol(owner,name,ct);
|
||||
sym = new Symbol(owner,nm,ct);
|
||||
addSymbolInternal(sym); // Let this scope lay claim to the new object
|
||||
return sym;
|
||||
}
|
||||
|
@ -1497,18 +1497,18 @@ Symbol *Scope::addSymbol(const string &name,Datatype *ct)
|
|||
/// The Symbol object will be created with the given name and data-type. A single mapping (SymbolEntry)
|
||||
/// will be created for the Symbol based on a given storage address for the symbol
|
||||
/// and an address for code that accesses the Symbol at that storage location.
|
||||
/// \param name is the new name of the Symbol
|
||||
/// \param nm is the new name of the Symbol
|
||||
/// \param ct is the data-type of the new Symbol
|
||||
/// \param addr is the starting address of the Symbol storage
|
||||
/// \param usepoint is the point accessing that storage (may be \e invalid)
|
||||
/// \return the SymbolEntry matching the new mapping
|
||||
SymbolEntry *Scope::addSymbol(const string &name,Datatype *ct,
|
||||
SymbolEntry *Scope::addSymbol(const string &nm,Datatype *ct,
|
||||
const Address &addr,
|
||||
const Address &usepoint)
|
||||
{
|
||||
Symbol *sym;
|
||||
|
||||
sym = new Symbol(owner,name,ct);
|
||||
sym = new Symbol(owner,nm,ct);
|
||||
addSymbolInternal(sym);
|
||||
return addMapPoint(sym,addr,usepoint);
|
||||
}
|
||||
|
@ -2344,13 +2344,13 @@ SymbolEntry *ScopeInternal::findOverlap(const Address &addr,int4 size) const
|
|||
return (SymbolEntry *)0;
|
||||
}
|
||||
|
||||
void ScopeInternal::findByName(const string &name,vector<Symbol *> &res) const
|
||||
void ScopeInternal::findByName(const string &nm,vector<Symbol *> &res) const
|
||||
|
||||
{
|
||||
SymbolNameTree::const_iterator iter = findFirstByName(name);
|
||||
SymbolNameTree::const_iterator iter = findFirstByName(nm);
|
||||
while(iter != nametree.end()) {
|
||||
Symbol *sym = *iter;
|
||||
if (sym->name != name) break;
|
||||
if (sym->name != nm) break;
|
||||
res.push_back(sym);
|
||||
++iter;
|
||||
}
|
||||
|
@ -2664,15 +2664,15 @@ void ScopeInternal::insertNameTree(Symbol *sym)
|
|||
|
||||
/// \brief Find an iterator pointing to the first Symbol in the ordering with a given name
|
||||
///
|
||||
/// \param name is the name to search for
|
||||
/// \param nm is the name to search for
|
||||
/// \return iterator pointing to the first Symbol or nametree.end() if there is no matching Symbol
|
||||
SymbolNameTree::const_iterator ScopeInternal::findFirstByName(const string &name) const
|
||||
SymbolNameTree::const_iterator ScopeInternal::findFirstByName(const string &nm) const
|
||||
|
||||
{
|
||||
Symbol sym((Scope *)0,name,(Datatype *)0);
|
||||
Symbol sym((Scope *)0,nm,(Datatype *)0);
|
||||
SymbolNameTree::const_iterator iter = nametree.lower_bound(&sym);
|
||||
if (iter == nametree.end()) return iter;
|
||||
if ((*iter)->getName() != name)
|
||||
if ((*iter)->getName() != nm)
|
||||
return nametree.end();
|
||||
return iter;
|
||||
}
|
||||
|
|
|
@ -605,9 +605,9 @@ public:
|
|||
/// \brief Find a Symbol by name within \b this Scope
|
||||
///
|
||||
/// If there are multiple Symbols with the same name, all are passed back.
|
||||
/// \param name is the name to search for
|
||||
/// \param nm is the name to search for
|
||||
/// \param res will contain any matching Symbols
|
||||
virtual void findByName(const string &name,vector<Symbol *> &res) const=0;
|
||||
virtual void findByName(const string &nm,vector<Symbol *> &res) const=0;
|
||||
|
||||
/// \brief Check if the given name is occurs within the given scope path.
|
||||
///
|
||||
|
@ -671,7 +671,7 @@ public:
|
|||
/// \param ind is the index position to set (within the category)
|
||||
virtual void setCategory(Symbol *sym,int4 cat,int4 ind)=0;
|
||||
|
||||
virtual SymbolEntry *addSymbol(const string &name,Datatype *ct,
|
||||
virtual SymbolEntry *addSymbol(const string &nm,Datatype *ct,
|
||||
const Address &addr,const Address &usepoint);
|
||||
|
||||
const string &getName(void) const { return name; } ///< Get the name of the Scope
|
||||
|
@ -679,8 +679,8 @@ public:
|
|||
bool isGlobal(void) const { return (fd == (Funcdata *)0); } ///< Return \b true if \b this scope is global
|
||||
|
||||
// The main global querying routines
|
||||
void queryByName(const string &name,vector<Symbol *> &res) const; ///< Look-up symbols by name
|
||||
Funcdata *queryFunction(const string &name) const; ///< Look-up a function by name
|
||||
void queryByName(const string &nm,vector<Symbol *> &res) const; ///< Look-up symbols by name
|
||||
Funcdata *queryFunction(const string &nm) const; ///< Look-up a function by name
|
||||
SymbolEntry *queryByAddr(const Address &addr,
|
||||
const Address &usepoint) const; ///< Get Symbol with matching address
|
||||
SymbolEntry *queryContainer(const Address &addr,int4 size,
|
||||
|
@ -691,7 +691,7 @@ public:
|
|||
Funcdata *queryExternalRefFunction(const Address &addr) const; ///< Look-up a function thru an \e external \e reference
|
||||
LabSymbol *queryCodeLabel(const Address &addr) const; ///< Look-up a code label by address
|
||||
|
||||
Scope *resolveScope(const string &name, bool strategy) const; ///< Find a child Scope of \b this
|
||||
Scope *resolveScope(const string &nm, bool strategy) const; ///< Find a child Scope of \b this
|
||||
Scope *discoverScope(const Address &addr,int4 sz,const Address &usepoint); ///< Find the owning Scope of a given memory range
|
||||
ScopeMap::const_iterator childrenBegin() const { return children.begin(); } ///< Beginning iterator of child scopes
|
||||
ScopeMap::const_iterator childrenEnd() const { return children.end(); } ///< Ending iterator of child scopes
|
||||
|
@ -705,7 +705,7 @@ public:
|
|||
const Scope *findDistinguishingScope(const Scope *op2) const; ///< Find first ancestor of \b this not shared by given scope
|
||||
Architecture *getArch(void) const { return glb; } ///< Get the Architecture associated with \b this
|
||||
Scope *getParent(void) const { return parent; } ///< Get the parent Scope (or NULL if \b this is the global Scope)
|
||||
Symbol *addSymbol(const string &name,Datatype *ct); ///< Add a new Symbol \e without mapping it to an address
|
||||
Symbol *addSymbol(const string &nm,Datatype *ct); ///< Add a new Symbol \e without mapping it to an address
|
||||
SymbolEntry *addMapPoint(Symbol *sym,const Address &addr,
|
||||
const Address &usepoint); ///< Map a Symbol to a specific address
|
||||
Symbol *addMapSym(const Element *el); ///< Add a mapped Symbol from a \<mapsym> XML tag
|
||||
|
@ -729,7 +729,7 @@ class ScopeInternal : public Scope {
|
|||
void processHole(const Element *el);
|
||||
void processCollision(const Element *el);
|
||||
void insertNameTree(Symbol *sym);
|
||||
SymbolNameTree::const_iterator findFirstByName(const string &name) const;
|
||||
SymbolNameTree::const_iterator findFirstByName(const string &nm) const;
|
||||
protected:
|
||||
virtual Scope *buildSubScope(uint8 id,const string &nm); ///< Build an unattached Scope to be associated as a sub-scope of \b this
|
||||
virtual void addSymbolInternal(Symbol *sym);
|
||||
|
@ -776,7 +776,7 @@ public:
|
|||
virtual LabSymbol *findCodeLabel(const Address &addr) const;
|
||||
virtual SymbolEntry *findOverlap(const Address &addr,int4 size) const;
|
||||
|
||||
virtual void findByName(const string &name,vector<Symbol *> &res) const;
|
||||
virtual void findByName(const string &nm,vector<Symbol *> &res) const;
|
||||
virtual bool isNameUsed(const string &nm,const Scope *op2) const;
|
||||
virtual Funcdata *resolveExternalRefFunction(ExternRefSymbol *sym) const;
|
||||
|
||||
|
|
|
@ -319,8 +319,8 @@ ExternRefSymbol *ScopeGhidra::findExternalRef(const Address &addr) const
|
|||
Funcdata *ScopeGhidra::findFunction(const Address &addr) const
|
||||
|
||||
{
|
||||
Funcdata *fd = cache->findFunction(addr);
|
||||
if (fd == (Funcdata *)0) {
|
||||
Funcdata *resFd = cache->findFunction(addr);
|
||||
if (resFd == (Funcdata *)0) {
|
||||
// Check if this address has already been queried,
|
||||
// (returning a symbol other than a function_symbol)
|
||||
SymbolEntry *entry = cache->findContainer(addr,1,Address());
|
||||
|
@ -328,10 +328,10 @@ Funcdata *ScopeGhidra::findFunction(const Address &addr) const
|
|||
FunctionSymbol *sym;
|
||||
sym = dynamic_cast<FunctionSymbol *>(removeQuery(addr));
|
||||
if (sym != (FunctionSymbol *)0)
|
||||
fd = sym->getFunction();
|
||||
resFd = sym->getFunction();
|
||||
}
|
||||
}
|
||||
return fd;
|
||||
return resFd;
|
||||
}
|
||||
|
||||
LabSymbol *ScopeGhidra::findCodeLabel(const Address &addr) const
|
||||
|
@ -356,40 +356,40 @@ LabSymbol *ScopeGhidra::findCodeLabel(const Address &addr) const
|
|||
Funcdata *ScopeGhidra::resolveExternalRefFunction(ExternRefSymbol *sym) const
|
||||
|
||||
{
|
||||
Funcdata *fd = (Funcdata *)0;
|
||||
Funcdata *resFd = (Funcdata *)0;
|
||||
const Scope *basescope = ghidra->symboltab->mapScope(this,sym->getRefAddr(),Address());
|
||||
// Truncate search at this scope, we don't want
|
||||
// the usual remote_query if the function isn't in cache
|
||||
// this won't recover external functions, but will just
|
||||
// return the externalref symbol again
|
||||
stackFunction(basescope,this,sym->getRefAddr(),&fd);
|
||||
if (fd == (Funcdata *)0)
|
||||
fd = cache->findFunction(sym->getRefAddr());
|
||||
if (fd == (Funcdata *)0) {
|
||||
stackFunction(basescope,this,sym->getRefAddr(),&resFd);
|
||||
if (resFd == (Funcdata *)0)
|
||||
resFd = cache->findFunction(sym->getRefAddr());
|
||||
if (resFd == (Funcdata *)0) {
|
||||
// If the function isn't in cache, we use the special
|
||||
// getExternalRefXML interface to recover the external function
|
||||
Document *doc;
|
||||
SymbolEntry *entry = sym->getFirstWholeMap();
|
||||
doc = ghidra->getExternalRefXML(entry->getAddr());
|
||||
if (doc != (Document *)0) {
|
||||
FunctionSymbol *sym;
|
||||
FunctionSymbol *funcSym;
|
||||
// Make sure referenced function is cached
|
||||
sym = dynamic_cast<FunctionSymbol *>(dump2Cache(doc));
|
||||
funcSym = dynamic_cast<FunctionSymbol *>(dump2Cache(doc));
|
||||
delete doc;
|
||||
if (sym != (FunctionSymbol *)0)
|
||||
fd = sym->getFunction();
|
||||
if (funcSym != (FunctionSymbol *)0)
|
||||
resFd = funcSym->getFunction();
|
||||
}
|
||||
}
|
||||
return fd;
|
||||
return resFd;
|
||||
}
|
||||
|
||||
SymbolEntry *ScopeGhidra::addSymbol(const string &name,Datatype *ct,
|
||||
SymbolEntry *ScopeGhidra::addSymbol(const string &nm,Datatype *ct,
|
||||
const Address &addr,const Address &usepoint)
|
||||
{
|
||||
// We do not inform Ghidra of the new symbol, we just
|
||||
// stick it in the cache. This allows the mapglobals action
|
||||
// to build global variables that Ghidra knows nothing about
|
||||
return cache->addSymbol(name,ct,addr,usepoint);
|
||||
return cache->addSymbol(nm,ct,addr,usepoint);
|
||||
}
|
||||
|
||||
SymbolEntry *ScopeGhidraNamespace::addMapInternal(Symbol *sym,uint4 exfl,const Address &addr,int4 off,int4 sz,
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
void lockDefaultProperties(void) { flagbaseDefault = ghidra->symboltab->getProperties(); cacheDirty = false; }
|
||||
virtual ~ScopeGhidra(void);
|
||||
virtual void clear(void);
|
||||
virtual SymbolEntry *addSymbol(const string &name,Datatype *ct,
|
||||
virtual SymbolEntry *addSymbol(const string &nm,Datatype *ct,
|
||||
const Address &addr,const Address &usepoint);
|
||||
virtual string buildVariableName(const Address &addr,
|
||||
const Address &pc,
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
virtual Funcdata *resolveExternalRefFunction(ExternRefSymbol *sym) const;
|
||||
|
||||
virtual SymbolEntry *findOverlap(const Address &addr,int4 size) const { throw LowlevelError("findOverlap unimplemented"); }
|
||||
virtual void findByName(const string &name,vector<Symbol *> &res) const { throw LowlevelError("findByName unimplemented"); }
|
||||
virtual void findByName(const string &nm,vector<Symbol *> &res) const { throw LowlevelError("findByName unimplemented"); }
|
||||
virtual bool isNameUsed(const string &nm,const Scope *op2) const { throw LowlevelError("isNameUsed unimplemented"); }
|
||||
|
||||
virtual MapIterator begin(void) const { throw LowlevelError("begin unimplemented"); }
|
||||
|
|
|
@ -178,7 +178,7 @@ bool SplitVarnode::inHandHiOut(Varnode *h)
|
|||
list<PcodeOp *>::const_iterator iter,enditer;
|
||||
iter = h->beginDescend();
|
||||
enditer = h->endDescend();
|
||||
Varnode *lo = (Varnode *)0;
|
||||
Varnode *loTmp = (Varnode *)0;
|
||||
Varnode *outvn = (Varnode *)0;
|
||||
while(iter != enditer) {
|
||||
PcodeOp *pieceop = *iter;
|
||||
|
@ -187,12 +187,12 @@ bool SplitVarnode::inHandHiOut(Varnode *h)
|
|||
if (pieceop->getIn(0) != h) continue;
|
||||
Varnode *l = pieceop->getIn(1);
|
||||
if (!l->isPrecisLo()) continue;
|
||||
if (lo != (Varnode *)0) return false; // Whole is not unique
|
||||
lo = l;
|
||||
if (loTmp != (Varnode *)0) return false; // Whole is not unique
|
||||
loTmp = l;
|
||||
outvn = pieceop->getOut();
|
||||
}
|
||||
if (lo != (Varnode *)0) {
|
||||
initAll(outvn,lo,h);
|
||||
if (loTmp != (Varnode *)0) {
|
||||
initAll(outvn,loTmp,h);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -204,7 +204,7 @@ bool SplitVarnode::inHandLoOut(Varnode *l)
|
|||
list<PcodeOp *>::const_iterator iter,enditer;
|
||||
iter = l->beginDescend();
|
||||
enditer = l->endDescend();
|
||||
Varnode *hi = (Varnode *)0;
|
||||
Varnode *hiTmp = (Varnode *)0;
|
||||
Varnode *outvn = (Varnode *)0;
|
||||
while(iter != enditer) {
|
||||
PcodeOp *pieceop = *iter;
|
||||
|
@ -213,12 +213,12 @@ bool SplitVarnode::inHandLoOut(Varnode *l)
|
|||
if (pieceop->getIn(1) != l) continue;
|
||||
Varnode *h = pieceop->getIn(0);
|
||||
if (!h->isPrecisHi()) continue;
|
||||
if (hi != (Varnode *)0) return false; // Whole is not unique
|
||||
hi = h;
|
||||
if (hiTmp != (Varnode *)0) return false; // Whole is not unique
|
||||
hiTmp = h;
|
||||
outvn = pieceop->getOut();
|
||||
}
|
||||
if (hi != (Varnode *)0) {
|
||||
initAll(outvn,l,hi);
|
||||
if (hiTmp != (Varnode *)0) {
|
||||
initAll(outvn,l,hiTmp);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -1398,11 +1398,11 @@ int4 LogicalForm::findHiMatch(void)
|
|||
// the least significant part, look for a known double precis out, then look for known double
|
||||
// precis in. If the other input is constant, look for a unique op that might be computing the high,
|
||||
// Return 0 if we found an op, return -1, if we can't find an op, return -2 if no op exists
|
||||
Varnode *lo1 = in.getLo();
|
||||
Varnode *vn2 = loop->getIn( 1-loop->getSlot( lo1 ) );
|
||||
Varnode *lo1Tmp = in.getLo();
|
||||
Varnode *vn2 = loop->getIn( 1-loop->getSlot( lo1Tmp ) );
|
||||
|
||||
SplitVarnode out;
|
||||
if (out.inHandLoOut(lo1)) { // If we already know what the double precision output looks like
|
||||
if (out.inHandLoOut(lo1Tmp)) { // If we already know what the double precision output looks like
|
||||
Varnode *hi = out.getHi();
|
||||
if (hi->isWritten()) { // Just look at construction of hi precisi
|
||||
PcodeOp *maybeop = hi->getDef();
|
||||
|
@ -2806,9 +2806,9 @@ bool PhiForm::applyRule(SplitVarnode &i,PcodeOp *hphi,bool workishi,Funcdata &da
|
|||
|
||||
int4 numin = hiphi->numInput();
|
||||
vector<SplitVarnode> inlist;
|
||||
for(int4 i=0;i<numin;++i) {
|
||||
Varnode *vhi = hiphi->getIn(i);
|
||||
Varnode *vlo = lophi->getIn(i);
|
||||
for(int4 j=0;j<numin;++j) {
|
||||
Varnode *vhi = hiphi->getIn(j);
|
||||
Varnode *vlo = lophi->getIn(j);
|
||||
inlist.push_back(SplitVarnode(vlo,vhi));
|
||||
}
|
||||
outvn.initPartial(lophi->getOut(),hiphi->getOut());
|
||||
|
|
|
@ -261,8 +261,8 @@ double FloatFormat::getHostFloat(uintb encoding,floatclass *type) const
|
|||
bool FloatFormat::roundToNearestEven(uintb &signif, int4 lowbitpos)
|
||||
|
||||
{
|
||||
uintb lowbitmask = (lowbitpos < 8 * sizeof(uintb)) ? (1UL << lowbitpos) : 0;
|
||||
uintb midbitmask = 1UL << (lowbitpos - 1);
|
||||
uintb lowbitmask = (lowbitpos < 8 * sizeof(uintb)) ? ((uintb)1 << lowbitpos) : 0;
|
||||
uintb midbitmask = (uintb)1 << (lowbitpos - 1);
|
||||
uintb epsmask = midbitmask - 1;
|
||||
bool odd = (signif & lowbitmask) != 0;
|
||||
if ((signif & midbitmask) != 0 && ((signif & epsmask) != 0 || odd)) {
|
||||
|
@ -301,7 +301,7 @@ uintb FloatFormat::getEncoding(double host) const
|
|||
if (roundToNearestEven(signif, 8 * sizeof(uintb) - frac_size - exp)) {
|
||||
// TODO handle round to normal case
|
||||
if ((signif >> (8 * sizeof(uintb) - 1)) == 0) {
|
||||
signif = 1UL << (8 * sizeof(uintb) - 1);
|
||||
signif = (uintb)1 << (8 * sizeof(uintb) - 1);
|
||||
exp += 1;
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ uintb FloatFormat::getEncoding(double host) const
|
|||
// if high bit is clear, then the add overflowed. Increase exp and set
|
||||
// signif to 1.
|
||||
if ((signif >> (8 * sizeof(uintb) - 1)) == 0) {
|
||||
signif = 1UL << (8 * sizeof(uintb) - 1);
|
||||
signif = (uintb)1 << (8 * sizeof(uintb) - 1);
|
||||
exp += 1;
|
||||
}
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ uintb FloatFormat::convertEncoding(uintb encoding,
|
|||
else { // incoming is normal
|
||||
exp -= formin->bias;
|
||||
if (jbitimplied)
|
||||
signif = (1UL << (8 * sizeof(uintb) - 1)) | (signif >> 1);
|
||||
signif = ((uintb)1 << (8 * sizeof(uintb) - 1)) | (signif >> 1);
|
||||
}
|
||||
|
||||
exp += bias;
|
||||
|
@ -374,7 +374,7 @@ uintb FloatFormat::convertEncoding(uintb encoding,
|
|||
if (roundToNearestEven(signif, 8 * sizeof(uintb) - frac_size - exp)) {
|
||||
// TODO handle carry to normal case
|
||||
if ((signif >> (8 * sizeof(uintb) - 1)) == 0) {
|
||||
signif = 1UL << (8 * sizeof(uintb) - 1);
|
||||
signif = (uintb)1 << (8 * sizeof(uintb) - 1);
|
||||
exp += 1;
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +386,7 @@ uintb FloatFormat::convertEncoding(uintb encoding,
|
|||
// if high bit is clear, then the add overflowed. Increase exp and set
|
||||
// signif to 1.
|
||||
if ((signif >> (8 * sizeof(uintb) - 1)) == 0) {
|
||||
signif = 1UL << (8 * sizeof(uintb) - 1);
|
||||
signif = (uintb)1 << (8 * sizeof(uintb) - 1);
|
||||
exp += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4174,7 +4174,7 @@ void FuncProto::restoreXml(const Element *el,Architecture *glb)
|
|||
bool outputlock = false;
|
||||
|
||||
if (subel->getName() == "returnsym") {
|
||||
int4 num = subel->getNumAttributes();
|
||||
num = subel->getNumAttributes();
|
||||
for(int4 i=0;i<num;++i) {
|
||||
const string &attrname( subel->getAttributeName(i) );
|
||||
if (attrname == "typelock")
|
||||
|
@ -4891,9 +4891,9 @@ void FuncCallSpecs::forceSet(Funcdata &data,const FuncProto &fp)
|
|||
void FuncCallSpecs::insertPcode(Funcdata &data)
|
||||
|
||||
{
|
||||
int4 injectid = getInjectUponReturn();
|
||||
if (injectid < 0) return; // Nothing to inject
|
||||
InjectPayload *payload = data.getArch()->pcodeinjectlib->getPayload(injectid);
|
||||
int4 id = getInjectUponReturn();
|
||||
if (id < 0) return; // Nothing to inject
|
||||
InjectPayload *payload = data.getArch()->pcodeinjectlib->getPayload(id);
|
||||
|
||||
// do the insertion right after the callpoint
|
||||
list<PcodeOp *>::iterator iter = op->getBasicIter();
|
||||
|
@ -4964,13 +4964,13 @@ void FuncCallSpecs::checkInputTrialUse(Funcdata &data,AliasChecker &aliascheck)
|
|||
|
||||
int4 maxancestor = data.getArch()->trim_recurse_max;
|
||||
bool callee_pop = false;
|
||||
int4 extrapop = 0;
|
||||
int4 expop = 0;
|
||||
if (hasModel()) {
|
||||
callee_pop = (getModelExtraPop() == ProtoModel::extrapop_unknown);
|
||||
if (callee_pop) {
|
||||
extrapop = getExtraPop();
|
||||
expop = getExtraPop();
|
||||
// Tried to use getEffectiveExtraPop at one point, but it is too unreliable
|
||||
if ((extrapop==ProtoModel::extrapop_unknown)||(extrapop <=4))
|
||||
if ((expop==ProtoModel::extrapop_unknown)||(expop <=4))
|
||||
callee_pop = false;
|
||||
// If the subfunctions do their own parameter popping and
|
||||
// if the extrapop is successfully recovered this is hard evidence
|
||||
|
@ -4992,7 +4992,7 @@ void FuncCallSpecs::checkInputTrialUse(Funcdata &data,AliasChecker &aliascheck)
|
|||
else if (!data.getFuncProto().getLocalRange().inRange(vn->getAddr(),1))
|
||||
trial.markNoUse();
|
||||
else if (callee_pop) {
|
||||
if ((int4)(trial.getAddress().getOffset() + (trial.getSize()-1)) < extrapop)
|
||||
if ((int4)(trial.getAddress().getOffset() + (trial.getSize()-1)) < expop)
|
||||
trial.markActive();
|
||||
else
|
||||
trial.markNoUse();
|
||||
|
|
|
@ -93,7 +93,7 @@ class Funcdata {
|
|||
void setVarnodeProperties(Varnode *vn) const; ///< Look-up boolean properties and data-type information
|
||||
HighVariable *assignHigh(Varnode *vn); ///< Assign a new HighVariable to a Varnode
|
||||
Symbol *handleSymbolConflict(SymbolEntry *entry,Varnode *vn); ///< Handle two variables with matching storage
|
||||
bool syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4 flags,Datatype *ct);
|
||||
bool syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4 fl,Datatype *ct);
|
||||
bool descend2Undef(Varnode *vn); ///< Transform all reads of the given Varnode to a special \b undefined constant
|
||||
|
||||
void splitUses(Varnode *vn); ///< Make all reads of the given Varnode unique
|
||||
|
@ -270,7 +270,7 @@ public:
|
|||
Varnode *newUnique(int4 s,Datatype *ct=(Datatype *)0); ///< Create a new \e temporary Varnode
|
||||
Varnode *newCodeRef(const Address &m); ///< Create a code address \e annotation Varnode
|
||||
Varnode *setInputVarnode(Varnode *vn); ///< Mark a Varnode as an input to the function
|
||||
void adjustInputVarnodes(const Address &addr,int4 size);
|
||||
void adjustInputVarnodes(const Address &addr,int4 sz);
|
||||
void deleteVarnode(Varnode *vn) { vbank.destroy(vn); } ///< Delete the given varnode
|
||||
|
||||
Address findDisjointCover(Varnode *vn,int4 &sz); ///< Find range covering given Varnode and any intersecting Varnodes
|
||||
|
@ -362,14 +362,14 @@ public:
|
|||
/// \brief End of (input or free) Varnodes at a given storage address
|
||||
VarnodeDefSet::const_iterator endDef(uint4 fl,const Address &addr) const { return vbank.endDef(fl,addr); }
|
||||
|
||||
void checkForLanedRegister(int4 size,const Address &addr); ///< Check for a potential laned register
|
||||
void checkForLanedRegister(int4 sz,const Address &addr); ///< Check for a potential laned register
|
||||
map<VarnodeData,const LanedRegister *>::const_iterator beginLaneAccess(void) const { return lanedMap.begin(); } ///< Beginning iterator over laned accesses
|
||||
map<VarnodeData,const LanedRegister *>::const_iterator endLaneAccess(void) const { return lanedMap.end(); } ///< Ending iterator over laned accesses
|
||||
void clearLanedAccessMap(void) { lanedMap.clear(); } ///< Clear records from the laned access list
|
||||
|
||||
HighVariable *findHigh(const string &name) const; ///< Find a high-level variable by name
|
||||
HighVariable *findHigh(const string &nm) const; ///< Find a high-level variable by name
|
||||
void mapGlobals(void); ///< Make sure there is a Symbol entry for all global Varnodes
|
||||
bool checkCallDoubleUse(const PcodeOp *opmatch,const PcodeOp *op,const Varnode *vn,uint4 flags,const ParamTrial &trial) const;
|
||||
bool checkCallDoubleUse(const PcodeOp *opmatch,const PcodeOp *op,const Varnode *vn,uint4 fl,const ParamTrial &trial) const;
|
||||
bool onlyOpUse(const Varnode *invn,const PcodeOp *opmatch,const ParamTrial &trial,uint4 mainFlags) const;
|
||||
bool ancestorOpUse(int4 maxlevel,const Varnode *invn,const PcodeOp *op,ParamTrial &trial,uint4 mainFlags) const;
|
||||
bool syncVarnodesWithSymbols(const ScopeLocal *lm,bool typesyes);
|
||||
|
@ -412,8 +412,8 @@ public:
|
|||
PcodeOp *newOpBefore(PcodeOp *follow,OpCode opc,Varnode *in1,Varnode *in2,Varnode *in3=(Varnode *)0);
|
||||
PcodeOp *cloneOp(const PcodeOp *op,const SeqNum &seq); /// Clone a PcodeOp into \b this function
|
||||
PcodeOp *getFirstReturnOp(void) const; /// Find a representative CPUI_RETURN op for \b this function
|
||||
PcodeOp *newIndirectOp(PcodeOp *indeffect,const Address &addr,int4 size,uint4 extraFlags);
|
||||
PcodeOp *newIndirectCreation(PcodeOp *indeffect,const Address &addr,int4 size,bool possibleout);
|
||||
PcodeOp *newIndirectOp(PcodeOp *indeffect,const Address &addr,int4 sz,uint4 extraFlags);
|
||||
PcodeOp *newIndirectCreation(PcodeOp *indeffect,const Address &addr,int4 sz,bool possibleout);
|
||||
void markIndirectCreation(PcodeOp *indop,bool possibleOutput); ///< Convert CPUI_INDIRECT into an \e indirect \e creation
|
||||
PcodeOp *findOp(const SeqNum &sq) { return obank.findOp(sq); } ///< Find PcodeOp with given sequence number
|
||||
void opInsertBefore(PcodeOp *op,PcodeOp *follow); ///< Insert given PcodeOp before a specific op
|
||||
|
@ -604,7 +604,7 @@ class AncestorRealistic {
|
|||
flags = 0;
|
||||
}
|
||||
int4 getSolidSlot(void) const { return ((flags & seen_solid0)!=0) ? 0 : 1; } ///< Get slot associated with \e solid movement
|
||||
void markSolid(int4 slot) { flags |= (slot==0) ? seen_solid0 : seen_solid1; } ///< Mark slot as having \e solid movement
|
||||
void markSolid(int4 s) { flags |= (s==0) ? seen_solid0 : seen_solid1; } ///< Mark given slot as having \e solid movement
|
||||
void markKill(void) { flags |= seen_kill; } ///< Mark \e killedbycall seen
|
||||
bool seenSolid(void) const { return ((flags & (seen_solid0|seen_solid1))!=0); } ///< Has \e solid movement been seen
|
||||
bool seenKill(void) const { return ((flags & seen_kill)!=0); } ///< Has \e killedbycall been seen
|
||||
|
|
|
@ -361,7 +361,7 @@ bool Funcdata::removeUnreachableBlocks(bool issuewarning,bool checkexistence)
|
|||
if (bblocks.getBlock(i)->isEntryPoint()) break;
|
||||
bblocks.collectReachable(list,bblocks.getBlock(i),true); // Collect (un)reachable blocks
|
||||
|
||||
for(int4 i=0;i<list.size();++i) {
|
||||
for(i=0;i<list.size();++i) {
|
||||
list[i]->setDead();
|
||||
if (issuewarning) {
|
||||
ostringstream s;
|
||||
|
@ -374,12 +374,12 @@ bool Funcdata::removeUnreachableBlocks(bool issuewarning,bool checkexistence)
|
|||
warningHeader(s.str());
|
||||
}
|
||||
}
|
||||
for(int4 i=0;i<list.size();++i) {
|
||||
for(i=0;i<list.size();++i) {
|
||||
BlockBasic *bb = (BlockBasic *)list[i];
|
||||
while(bb->sizeOut() > 0)
|
||||
branchRemoveInternal(bb,0);
|
||||
}
|
||||
for(int4 i=0;i<list.size();++i) {
|
||||
for(i=0;i<list.size();++i) {
|
||||
BlockBasic *bb = (BlockBasic *)list[i];
|
||||
blockRemoveInternal(bb,true);
|
||||
}
|
||||
|
@ -770,9 +770,9 @@ PcodeOp *Funcdata::nodeSplitCloneOp(PcodeOp *op)
|
|||
}
|
||||
dup = newOp(op->numInput(),op->getAddr());
|
||||
opSetOpcode(dup,op->code());
|
||||
uint4 flags = op->flags & (PcodeOp::startbasic | PcodeOp::nocollapse |
|
||||
uint4 fl = op->flags & (PcodeOp::startbasic | PcodeOp::nocollapse |
|
||||
PcodeOp::startmark);
|
||||
dup->setFlag(flags);
|
||||
dup->setFlag(fl);
|
||||
return dup;
|
||||
}
|
||||
|
||||
|
|
|
@ -571,8 +571,8 @@ PcodeOp *Funcdata::cloneOp(const PcodeOp *op,const SeqNum &seq)
|
|||
{
|
||||
PcodeOp *newop = newOp(op->numInput(),seq);
|
||||
opSetOpcode(newop,op->code());
|
||||
uint4 flags = op->flags & (PcodeOp::startmark | PcodeOp::startbasic);
|
||||
newop->setFlag(flags);
|
||||
uint4 fl = op->flags & (PcodeOp::startmark | PcodeOp::startbasic);
|
||||
newop->setFlag(fl);
|
||||
if (op->getOut() != (Varnode *)0)
|
||||
opSetOutput(newop,cloneVarnode(op->getOut()));
|
||||
for(int4 i=0;i<op->numInput();++i)
|
||||
|
@ -610,15 +610,15 @@ PcodeOp *Funcdata::newOpBefore(PcodeOp *follow,OpCode opc,Varnode *in1,Varnode *
|
|||
|
||||
{
|
||||
PcodeOp *newop;
|
||||
int4 size;
|
||||
int4 sz;
|
||||
|
||||
size = (in3 == (Varnode *)0) ? 2 : 3;
|
||||
newop = newOp(size,follow->getAddr());
|
||||
sz = (in3 == (Varnode *)0) ? 2 : 3;
|
||||
newop = newOp(sz,follow->getAddr());
|
||||
opSetOpcode(newop,opc);
|
||||
newUniqueOut(in1->getSize(),newop);
|
||||
opSetInput(newop,in1,0);
|
||||
opSetInput(newop,in2,1);
|
||||
if (size==3)
|
||||
if (sz==3)
|
||||
opSetInput(newop,in3,2);
|
||||
opInsertBefore(newop,follow);
|
||||
return newop;
|
||||
|
@ -630,19 +630,19 @@ PcodeOp *Funcdata::newOpBefore(PcodeOp *follow,OpCode opc,Varnode *in1,Varnode *
|
|||
/// through a CALL or STORE. An output Varnode is automatically created.
|
||||
/// \param indeffect is the PcodeOp with the indirect effect
|
||||
/// \param addr is the starting address of the storage range to protect
|
||||
/// \param size is the number of bytes in the storage range
|
||||
/// \param sz is the number of bytes in the storage range
|
||||
/// \param extraFlags are extra boolean properties to put on the INDIRECT
|
||||
/// \return the new CPUI_INDIRECT op
|
||||
PcodeOp *Funcdata::newIndirectOp(PcodeOp *indeffect,const Address &addr,int4 size,uint4 extraFlags)
|
||||
PcodeOp *Funcdata::newIndirectOp(PcodeOp *indeffect,const Address &addr,int4 sz,uint4 extraFlags)
|
||||
|
||||
{
|
||||
Varnode *newin;
|
||||
PcodeOp *newop;
|
||||
|
||||
newin = newVarnode(size,addr);
|
||||
newin = newVarnode(sz,addr);
|
||||
newop = newOp(2,indeffect->getAddr());
|
||||
newop->flags |= extraFlags;
|
||||
newVarnodeOut(size,addr,newop);
|
||||
newVarnodeOut(sz,addr,newop);
|
||||
opSetOpcode(newop,CPUI_INDIRECT);
|
||||
opSetInput(newop,newin,0);
|
||||
opSetInput(newop,newVarnodeIop(indeffect),1);
|
||||
|
@ -657,19 +657,19 @@ PcodeOp *Funcdata::newIndirectOp(PcodeOp *indeffect,const Address &addr,int4 siz
|
|||
/// The new Varnode is allocated with a given storage range.
|
||||
/// \param indeffect is the p-code causing the indirect effect
|
||||
/// \param addr is the starting address of the given storage range
|
||||
/// \param size is the number of bytes in the storage range
|
||||
/// \param sz is the number of bytes in the storage range
|
||||
/// \param possibleout is \b true if the output should be treated as a \e directwrite.
|
||||
/// \return the new CPUI_INDIRECT op
|
||||
PcodeOp *Funcdata::newIndirectCreation(PcodeOp *indeffect,const Address &addr,int4 size,bool possibleout)
|
||||
PcodeOp *Funcdata::newIndirectCreation(PcodeOp *indeffect,const Address &addr,int4 sz,bool possibleout)
|
||||
|
||||
{
|
||||
Varnode *newout,*newin;
|
||||
PcodeOp *newop;
|
||||
|
||||
newin = newConstant(size,0);
|
||||
newin = newConstant(sz,0);
|
||||
newop = newOp(2,indeffect->getAddr());
|
||||
newop->flags |= PcodeOp::indirect_creation;
|
||||
newout = newVarnodeOut(size,addr,newop);
|
||||
newout = newVarnodeOut(sz,addr,newop);
|
||||
if (!possibleout)
|
||||
newin->flags |= Varnode::indirect_creation;
|
||||
newout->flags |= Varnode::indirect_creation;
|
||||
|
@ -1027,34 +1027,34 @@ bool Funcdata::distributeIntMultAdd(PcodeOp *op)
|
|||
if ((vn0->isFree())&&(!vn0->isConstant())) return false;
|
||||
if ((vn1->isFree())&&(!vn1->isConstant())) return false;
|
||||
uintb coeff = op->getIn(1)->getOffset();
|
||||
int4 size = op->getOut()->getSize();
|
||||
int4 sz = op->getOut()->getSize();
|
||||
// Do distribution
|
||||
if (vn0->isConstant()) {
|
||||
uintb val = coeff * vn0->getOffset();
|
||||
val &= calc_mask(size);
|
||||
newvn0 = newConstant(size,val);
|
||||
val &= calc_mask(sz);
|
||||
newvn0 = newConstant(sz,val);
|
||||
}
|
||||
else {
|
||||
PcodeOp *newop0 = newOp(2,op->getAddr());
|
||||
opSetOpcode(newop0,CPUI_INT_MULT);
|
||||
newvn0 = newUniqueOut(size,newop0);
|
||||
newvn0 = newUniqueOut(sz,newop0);
|
||||
opSetInput(newop0, vn0, 0); // To first input of original add
|
||||
Varnode *newcvn = newConstant(size,coeff);
|
||||
Varnode *newcvn = newConstant(sz,coeff);
|
||||
opSetInput(newop0, newcvn, 1);
|
||||
opInsertBefore(newop0, op);
|
||||
}
|
||||
|
||||
if (vn1->isConstant()) {
|
||||
uintb val = coeff * vn1->getOffset();
|
||||
val &= calc_mask(size);
|
||||
newvn1 = newConstant(size,val);
|
||||
val &= calc_mask(sz);
|
||||
newvn1 = newConstant(sz,val);
|
||||
}
|
||||
else {
|
||||
PcodeOp *newop1 = newOp(2,op->getAddr());
|
||||
opSetOpcode(newop1,CPUI_INT_MULT);
|
||||
newvn1 = newUniqueOut(size,newop1);
|
||||
newvn1 = newUniqueOut(sz,newop1);
|
||||
opSetInput(newop1, vn1, 0); // To second input of original add
|
||||
Varnode *newcvn = newConstant(size,coeff);
|
||||
Varnode *newcvn = newConstant(sz,coeff);
|
||||
opSetInput(newop1, newcvn, 1);
|
||||
opInsertBefore(newop1, op);
|
||||
}
|
||||
|
@ -1091,9 +1091,9 @@ bool Funcdata::collapseIntMultMult(Varnode *vn)
|
|||
if (!constVnSecond->isConstant()) return false;
|
||||
Varnode *invn = otherMultOp->getIn(0);
|
||||
if (invn->isFree()) return false;
|
||||
int4 size = invn->getSize();
|
||||
uintb val = (constVnFirst->getOffset() * constVnSecond->getOffset()) & calc_mask(size);
|
||||
Varnode *newvn = newConstant(size,val);
|
||||
int4 sz = invn->getSize();
|
||||
uintb val = (constVnFirst->getOffset() * constVnSecond->getOffset()) & calc_mask(sz);
|
||||
Varnode *newvn = newConstant(sz,val);
|
||||
opSetInput(op,newvn,1);
|
||||
opSetInput(op,invn,0);
|
||||
return true;
|
||||
|
|
|
@ -291,31 +291,31 @@ void Funcdata::destroyVarnode(Varnode *vn)
|
|||
|
||||
/// Check if the given storage range is a potential laned register.
|
||||
/// If so, record the storage with the matching laned register record.
|
||||
/// \param size is the size of the storage range in bytes
|
||||
/// \param sz is the size of the storage range in bytes
|
||||
/// \param addr is the starting address of the storage range
|
||||
void Funcdata::checkForLanedRegister(int4 size,const Address &addr)
|
||||
void Funcdata::checkForLanedRegister(int4 sz,const Address &addr)
|
||||
|
||||
{
|
||||
const LanedRegister *lanedRegister = glb->getLanedRegister(addr,size);
|
||||
const LanedRegister *lanedRegister = glb->getLanedRegister(addr,sz);
|
||||
if (lanedRegister == (const LanedRegister *)0)
|
||||
return;
|
||||
VarnodeData storage;
|
||||
storage.space = addr.getSpace();
|
||||
storage.offset = addr.getOffset();
|
||||
storage.size = size;
|
||||
storage.size = sz;
|
||||
lanedMap[storage] = lanedRegister;
|
||||
}
|
||||
|
||||
/// Look up the Symbol visible in \b this function's Scope and return the HighVariable
|
||||
/// associated with it. If the Symbol doesn't exist or there is no Varnode holding at least
|
||||
/// part of the value of the Symbol, NULL is returned.
|
||||
/// \param name is the name to search for
|
||||
/// \param nm is the name to search for
|
||||
/// \return the matching HighVariable or NULL
|
||||
HighVariable *Funcdata::findHigh(const string &name) const
|
||||
HighVariable *Funcdata::findHigh(const string &nm) const
|
||||
|
||||
{
|
||||
vector<Symbol *> symList;
|
||||
localmap->queryByName(name,symList);
|
||||
localmap->queryByName(nm,symList);
|
||||
if (symList.empty()) return (HighVariable *)0;
|
||||
Symbol *sym = symList[0];
|
||||
Varnode *vn = findLinkedVarnode(sym->getFirstWholeMap());
|
||||
|
@ -377,11 +377,11 @@ Varnode *Funcdata::setInputVarnode(Varnode *vn)
|
|||
/// op off of the new single input. If an overlapping Varnode isn't fully contained
|
||||
/// an exception is thrown.
|
||||
/// \param addr is the starting address of the range
|
||||
/// \param size is the number of bytes in the range
|
||||
void Funcdata::adjustInputVarnodes(const Address &addr,int4 size)
|
||||
/// \param sz is the number of bytes in the range
|
||||
void Funcdata::adjustInputVarnodes(const Address &addr,int4 sz)
|
||||
|
||||
{
|
||||
Address endaddr = addr + (size-1);
|
||||
Address endaddr = addr + (sz-1);
|
||||
vector<Varnode *> inlist;
|
||||
VarnodeDefSet::const_iterator iter,enditer;
|
||||
iter = vbank.beginDef(Varnode::input,addr);
|
||||
|
@ -396,8 +396,8 @@ void Funcdata::adjustInputVarnodes(const Address &addr,int4 size)
|
|||
|
||||
for(uint4 i=0;i<inlist.size();++i) {
|
||||
Varnode *vn = inlist[i];
|
||||
int4 sa = addr.justifiedContain(size,vn->getAddr(),vn->getSize(),false);
|
||||
if ((!vn->isInput())||(sa < 0)||(size<=vn->getSize()))
|
||||
int4 sa = addr.justifiedContain(sz,vn->getAddr(),vn->getSize(),false);
|
||||
if ((!vn->isInput())||(sa < 0)||(sz<=vn->getSize()))
|
||||
throw LowlevelError("Bad adjustment to input varnode");
|
||||
PcodeOp *subop = newOp(2,getAddress());
|
||||
opSetOpcode(subop,CPUI_SUBPIECE);
|
||||
|
@ -410,7 +410,7 @@ void Funcdata::adjustInputVarnodes(const Address &addr,int4 size)
|
|||
inlist[i] = newvn;
|
||||
}
|
||||
// Now that all the intersecting inputs have been pulled out, we can create the new input
|
||||
Varnode *invn = newVarnode(size,addr);
|
||||
Varnode *invn = newVarnode(sz,addr);
|
||||
invn = setInputVarnode(invn);
|
||||
// The new input may cause new heritage and "Heritage AFTER dead removal" errors
|
||||
// So tell heritage to ignore it
|
||||
|
@ -434,22 +434,22 @@ bool Funcdata::descend2Undef(Varnode *vn)
|
|||
BlockBasic *inbl;
|
||||
Varnode *badconst;
|
||||
list<PcodeOp *>::const_iterator iter;
|
||||
int4 i,size;
|
||||
int4 i,sz;
|
||||
bool res;
|
||||
|
||||
res = false;
|
||||
size = vn->getSize();
|
||||
sz = vn->getSize();
|
||||
iter = vn->beginDescend();
|
||||
while(iter != vn->endDescend()) {
|
||||
op = *iter++; // Move to next in list before deletion
|
||||
if (op->getParent()->isDead()) continue;
|
||||
if (op->getParent()->sizeIn()!=0) res = true;
|
||||
i = op->getSlot(vn);
|
||||
badconst = newConstant(size,0xBADDEF);
|
||||
badconst = newConstant(sz,0xBADDEF);
|
||||
if (op->code()==CPUI_MULTIEQUAL) { // Cannot put constant directly into MULTIEQUAL
|
||||
inbl = (BlockBasic *) op->getParent()->getIn(i);
|
||||
copyop = newOp(1,inbl->getStart());
|
||||
Varnode *inputvn = newUniqueOut(size,copyop);
|
||||
Varnode *inputvn = newUniqueOut(sz,copyop);
|
||||
opSetOpcode(copyop,CPUI_COPY);
|
||||
opSetInput(copyop,badconst,0);
|
||||
opInsertEnd(copyop,inbl);
|
||||
|
@ -457,7 +457,7 @@ bool Funcdata::descend2Undef(Varnode *vn)
|
|||
}
|
||||
else if (op->code()==CPUI_INDIRECT) { // Cannot put constant directly into INDIRECT
|
||||
copyop = newOp(1,op->getAddr());
|
||||
Varnode *inputvn = newUniqueOut(size,copyop);
|
||||
Varnode *inputvn = newUniqueOut(sz,copyop);
|
||||
opSetOpcode(copyop,CPUI_COPY);
|
||||
opSetInput(copyop,badconst,0);
|
||||
opInsertBefore(copyop,op);
|
||||
|
@ -816,7 +816,7 @@ bool Funcdata::syncVarnodesWithSymbols(const ScopeLocal *lm,bool typesyes)
|
|||
VarnodeLocSet::const_iterator iter,enditer;
|
||||
Datatype *ct;
|
||||
SymbolEntry *entry;
|
||||
uint4 flags;
|
||||
uint4 fl;
|
||||
|
||||
iter = vbank.beginLoc(lm->getSpaceId());
|
||||
enditer = vbank.endLoc(lm->getSpaceId());
|
||||
|
@ -825,7 +825,7 @@ bool Funcdata::syncVarnodesWithSymbols(const ScopeLocal *lm,bool typesyes)
|
|||
entry = lm->findOverlap(vnexemplar->getAddr(),vnexemplar->getSize());
|
||||
ct = (Datatype *)0;
|
||||
if (entry != (SymbolEntry *)0) {
|
||||
flags = entry->getAllFlags();
|
||||
fl = entry->getAllFlags();
|
||||
if (entry->getSize() >= vnexemplar->getSize()) {
|
||||
if (typesyes) {
|
||||
uintb off = (vnexemplar->getOffset() - entry->getAddr().getOffset()) + entry->getOffset();
|
||||
|
@ -843,7 +843,7 @@ bool Funcdata::syncVarnodesWithSymbols(const ScopeLocal *lm,bool typesyes)
|
|||
// getting put in a bigger register
|
||||
// Don't try to figure out type
|
||||
// Don't keep typelock and namelock
|
||||
flags &= ~((uint4)(Varnode::typelock|Varnode::namelock));
|
||||
fl &= ~((uint4)(Varnode::typelock|Varnode::namelock));
|
||||
// we do particularly want to keep the nolocalalias
|
||||
}
|
||||
}
|
||||
|
@ -852,12 +852,12 @@ bool Funcdata::syncVarnodesWithSymbols(const ScopeLocal *lm,bool typesyes)
|
|||
vnexemplar->getUsePoint(*this))) {
|
||||
// This is technically an error, there should be some
|
||||
// kind of symbol, if we are in scope
|
||||
flags = Varnode::mapped | Varnode::addrtied;
|
||||
fl = Varnode::mapped | Varnode::addrtied;
|
||||
}
|
||||
else
|
||||
flags = 0;
|
||||
fl = 0;
|
||||
}
|
||||
if (syncVarnodesWithSymbol(iter,flags,ct))
|
||||
if (syncVarnodesWithSymbol(iter,fl,ct))
|
||||
updateoccurred = true;
|
||||
}
|
||||
return updateoccurred;
|
||||
|
@ -917,10 +917,10 @@ Symbol *Funcdata::handleSymbolConflict(SymbolEntry *entry,Varnode *vn)
|
|||
/// If the given data-type is non-null, an attempt is made to update all the Varnodes
|
||||
/// to this data-type. The \b typelock and \b namelock properties cannot be changed here.
|
||||
/// \param iter points to the first Varnode in the set
|
||||
/// \param flags holds the new set of boolean properties
|
||||
/// \param fl holds the new set of boolean properties
|
||||
/// \param ct is the given data-type to set (or NULL)
|
||||
/// \return \b true if at least one Varnode was modified
|
||||
bool Funcdata::syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4 flags,Datatype *ct)
|
||||
bool Funcdata::syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4 fl,Datatype *ct)
|
||||
|
||||
{
|
||||
VarnodeLocSet::const_iterator enditer;
|
||||
|
@ -933,13 +933,13 @@ bool Funcdata::syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4
|
|||
// as we cannot set it here if it is clear
|
||||
// We can CLEAR but not SET the addrtied flag
|
||||
// If addrtied is cleared, so should addrforce
|
||||
if ((flags&Varnode::addrtied)==0) // Is the addrtied flags cleared
|
||||
if ((fl&Varnode::addrtied)==0) // Is the addrtied flags cleared
|
||||
mask |= Varnode::addrtied | Varnode::addrforce;
|
||||
// We can set the nolocalalias flag, but not clear it
|
||||
// If nolocalalias is set, then addrforce should be cleared
|
||||
if ((flags&Varnode::nolocalalias)!=0)
|
||||
if ((fl&Varnode::nolocalalias)!=0)
|
||||
mask |= Varnode::nolocalalias | Varnode::addrforce;
|
||||
flags &= mask;
|
||||
fl &= mask;
|
||||
|
||||
vn = *iter;
|
||||
enditer = vbank.endLoc(vn->getSize(),vn->getAddr());
|
||||
|
@ -949,17 +949,17 @@ bool Funcdata::syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4
|
|||
vnflags = vn->getFlags();
|
||||
if (vn->mapentry != (SymbolEntry *)0) { // If there is already an attached SymbolEntry (dynamic)
|
||||
uint4 localMask = mask & ~Varnode::mapped; // Make sure 'mapped' bit is unchanged
|
||||
uint4 localFlags = flags & localMask;
|
||||
uint4 localFlags = fl & localMask;
|
||||
if ((vnflags & localMask) != localFlags) {
|
||||
updateoccurred = true;
|
||||
vn->setFlags(localFlags);
|
||||
vn->clearFlags((~localFlags)&localMask);
|
||||
}
|
||||
}
|
||||
else if ((vnflags & mask) != flags) { // We have a change
|
||||
else if ((vnflags & mask) != fl) { // We have a change
|
||||
updateoccurred = true;
|
||||
vn->setFlags(flags);
|
||||
vn->clearFlags((~flags)&mask);
|
||||
vn->setFlags(fl);
|
||||
vn->clearFlags((~fl)&mask);
|
||||
}
|
||||
if (ct != (Datatype *)0) {
|
||||
if (vn->updateType(ct,false,false))
|
||||
|
@ -1023,13 +1023,13 @@ Symbol *Funcdata::linkSymbol(Varnode *vn)
|
|||
{
|
||||
HighVariable *high = vn->getHigh();
|
||||
SymbolEntry *entry;
|
||||
uint4 flags = 0;
|
||||
uint4 fl = 0;
|
||||
Symbol *sym = high->getSymbol();
|
||||
if (sym != (Symbol *)0) return sym; // Symbol already assigned
|
||||
|
||||
Address usepoint = vn->getUsePoint(*this);
|
||||
// Find any entry overlapping base address
|
||||
entry = localmap->queryProperties(vn->getAddr(), 1, usepoint, flags);
|
||||
entry = localmap->queryProperties(vn->getAddr(), 1, usepoint, fl);
|
||||
if (entry != (SymbolEntry *) 0) {
|
||||
sym = handleSymbolConflict(entry, vn);
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ void Funcdata::mapGlobals(void)
|
|||
VarnodeLocSet::const_iterator iter,enditer;
|
||||
Varnode *vn,*maxvn;
|
||||
Datatype *ct;
|
||||
uint4 flags;
|
||||
uint4 fl;
|
||||
vector<Varnode *> uncoveredVarnodes;
|
||||
bool inconsistentuse = false;
|
||||
|
||||
|
@ -1452,11 +1452,11 @@ void Funcdata::mapGlobals(void)
|
|||
else
|
||||
ct = glb->types->getBase(endaddr.getOffset()-addr.getOffset(),TYPE_UNKNOWN);
|
||||
|
||||
flags = 0;
|
||||
fl = 0;
|
||||
// Assume existing symbol is addrtied, so use empty usepoint
|
||||
Address usepoint;
|
||||
// Find any entry overlapping base address
|
||||
entry = localmap->queryProperties(addr,1,usepoint,flags);
|
||||
entry = localmap->queryProperties(addr,1,usepoint,fl);
|
||||
if (entry==(SymbolEntry *)0) {
|
||||
Scope *discover = localmap->discoverScope(addr,ct->getSize(),usepoint);
|
||||
if (discover == (Scope *)0)
|
||||
|
@ -1508,10 +1508,10 @@ bool Funcdata::isAlternatePathValid(const Varnode *vn,uint4 flags)
|
|||
/// \param opmatch is the first CALL linked to the trial
|
||||
/// \param op is the second CALL
|
||||
/// \param vn is the Varnode parameter for the second CALL
|
||||
/// \param flags indicates what p-code ops were crossed to reach \e vn
|
||||
/// \param fl indicates what p-code ops were crossed to reach \e vn
|
||||
/// \param trial is the given parameter trial
|
||||
/// \return \b true for a legitimate double use
|
||||
bool Funcdata::checkCallDoubleUse(const PcodeOp *opmatch,const PcodeOp *op,const Varnode *vn,uint4 flags,const ParamTrial &trial) const
|
||||
bool Funcdata::checkCallDoubleUse(const PcodeOp *opmatch,const PcodeOp *op,const Varnode *vn,uint4 fl,const ParamTrial &trial) const
|
||||
|
||||
{
|
||||
int4 j = op->getSlot(vn);
|
||||
|
@ -1544,7 +1544,7 @@ bool Funcdata::checkCallDoubleUse(const PcodeOp *opmatch,const PcodeOp *op,const
|
|||
if (curtrial.isActive())
|
||||
return false;
|
||||
}
|
||||
else if (isAlternatePathValid(vn,flags))
|
||||
else if (isAlternatePathValid(vn,fl))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1091,7 +1091,7 @@ void Heritage::guard(const Address &addr,int4 size,vector<Varnode *> &read,vecto
|
|||
vector<Varnode *> &inputvars)
|
||||
|
||||
{
|
||||
uint4 flags;
|
||||
uint4 fl;
|
||||
Varnode *vn;
|
||||
vector<Varnode *>::iterator iter;
|
||||
bool guardneeded = true;
|
||||
|
@ -1130,14 +1130,14 @@ void Heritage::guard(const Address &addr,int4 size,vector<Varnode *> &read,vecto
|
|||
// for the same address confuses the renaming algorithm
|
||||
// SO we don't guard if we think we've guarded before
|
||||
if (guardneeded) {
|
||||
flags = 0;
|
||||
fl = 0;
|
||||
// Query for generic properties of address (use empty usepoint)
|
||||
fd->getScopeLocal()->queryProperties(addr,size,Address(),flags);
|
||||
guardCalls(flags,addr,size,write);
|
||||
guardReturns(flags,addr,size,write);
|
||||
fd->getScopeLocal()->queryProperties(addr,size,Address(),fl);
|
||||
guardCalls(fl,addr,size,write);
|
||||
guardReturns(fl,addr,size,write);
|
||||
if (fd->getArch()->highPtrPossible(addr,size)) {
|
||||
guardStores(addr,size,write);
|
||||
guardLoads(flags,addr,size,write);
|
||||
guardLoads(fl,addr,size,write);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1184,18 +1184,18 @@ void Heritage::guardCallOverlappingInput(FuncCallSpecs *fc,const Address &addr,c
|
|||
/// across each call site in the function. If an effect is unknown, an
|
||||
/// INDIRECT op is added, prepopulating data-flow through the call.
|
||||
/// Any new INDIRECT causes a new Varnode to be added to the \b write list.
|
||||
/// \param flags are any boolean properties associated with the address range
|
||||
/// \param fl are any boolean properties associated with the address range
|
||||
/// \param addr is the first address of given range
|
||||
/// \param size is the number of bytes in the range
|
||||
/// \param write is the list of written Varnodes in the range (may be updated)
|
||||
void Heritage::guardCalls(uint4 flags,const Address &addr,int4 size,vector<Varnode *> &write)
|
||||
void Heritage::guardCalls(uint4 fl,const Address &addr,int4 size,vector<Varnode *> &write)
|
||||
|
||||
{
|
||||
FuncCallSpecs *fc;
|
||||
PcodeOp *indop;
|
||||
uint4 effecttype;
|
||||
|
||||
bool holdind = ((flags&Varnode::addrtied)!=0);
|
||||
bool holdind = ((fl&Varnode::addrtied)!=0);
|
||||
for(int4 i=0;i<fd->numCalls();++i) {
|
||||
fc = fd->getCallSpecs(i);
|
||||
if (fc->getOp()->isAssignment()) {
|
||||
|
@ -1297,17 +1297,17 @@ void Heritage::guardStores(const Address &addr,int4 size,vector<Varnode *> &writ
|
|||
/// The op must be in the loadGuard list, which means it may pull values from an indexed
|
||||
/// range on the stack. A COPY guard is placed for the given range on any LOAD op whose
|
||||
/// indexed range it intersects.
|
||||
/// \param flags is boolean properties associated with the address
|
||||
/// \param fl is boolean properties associated with the address
|
||||
/// \param addr is the first address of the given range
|
||||
/// \param size is the number of bytes in the given range
|
||||
/// \param write is the list of written Varnodes in the range (may be updated)
|
||||
void Heritage::guardLoads(uint4 flags,const Address &addr,int4 size,vector<Varnode *> &write)
|
||||
void Heritage::guardLoads(uint4 fl,const Address &addr,int4 size,vector<Varnode *> &write)
|
||||
|
||||
{
|
||||
PcodeOp *copyop;
|
||||
list<LoadGuard>::iterator iter;
|
||||
|
||||
if ((flags & Varnode::addrtied)==0) return; // If not address tied, don't consider for index alias
|
||||
if ((fl & Varnode::addrtied)==0) return; // If not address tied, don't consider for index alias
|
||||
iter = loadGuard.begin();
|
||||
while(iter!=loadGuard.end()) {
|
||||
LoadGuard &guardRec(*iter);
|
||||
|
@ -1342,11 +1342,11 @@ void Heritage::guardLoads(uint4 flags,const Address &addr,int4 size,vector<Varno
|
|||
/// is added as input to the RETURN (for possible return values), or a COPY
|
||||
/// is inserted right before the RETURN with its output marked as
|
||||
/// \b address \b forced.
|
||||
/// \param flags are any boolean properties associated with the address range
|
||||
/// \param fl are any boolean properties associated with the address range
|
||||
/// \param addr is the first address of the given range
|
||||
/// \param size is the number of bytes in the range
|
||||
/// \param write is the list of written Varnodes in the range (unused)
|
||||
void Heritage::guardReturns(uint4 flags,const Address &addr,int4 size,vector<Varnode *> &write)
|
||||
void Heritage::guardReturns(uint4 fl,const Address &addr,int4 size,vector<Varnode *> &write)
|
||||
|
||||
{
|
||||
list<PcodeOp *>::const_iterator iter,iterend;
|
||||
|
@ -1367,7 +1367,7 @@ void Heritage::guardReturns(uint4 flags,const Address &addr,int4 size,vector<Var
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((flags&Varnode::persist)==0) return;
|
||||
if ((fl&Varnode::persist)==0) return;
|
||||
iterend = fd->endOp(CPUI_RETURN);
|
||||
for(iter=fd->beginOp(CPUI_RETURN);iter!=iterend;++iter) {
|
||||
op = *iter;
|
||||
|
@ -1609,7 +1609,7 @@ bool Heritage::refinement(const Address &addr,int4 size,const vector<Varnode *>
|
|||
|
||||
// Alter the disjoint cover (both locally and globally) to reflect our refinement
|
||||
LocationMap::iterator iter = disjoint.find(addr);
|
||||
int4 pass = (*iter).second.pass;
|
||||
int4 addrPass = (*iter).second.pass;
|
||||
disjoint.erase(iter);
|
||||
iter = globaldisjoint.find(addr);
|
||||
globaldisjoint.erase(iter);
|
||||
|
@ -1618,8 +1618,8 @@ bool Heritage::refinement(const Address &addr,int4 size,const vector<Varnode *>
|
|||
int4 intersect;
|
||||
while(cut < size) {
|
||||
int4 sz = refine[cut];
|
||||
disjoint.add(curaddr,sz,pass,intersect);
|
||||
globaldisjoint.add(curaddr,sz,pass,intersect);
|
||||
disjoint.add(curaddr,sz,addrPass,intersect);
|
||||
globaldisjoint.add(curaddr,sz,addrPass,intersect);
|
||||
cut += sz;
|
||||
curaddr = curaddr + sz;
|
||||
}
|
||||
|
@ -1681,8 +1681,8 @@ void Heritage::guardInput(const Address &addr,int4 size,vector<Varnode *> &input
|
|||
// Now we need to make sure that all the inputs get linked
|
||||
// together into a single input
|
||||
if (newinput.size()==1) return; // Will get linked in automatically
|
||||
for(uint4 i=0;i<newinput.size();++i)
|
||||
newinput[i]->setWriteMask();
|
||||
for(uint4 j=0;j<newinput.size();++j)
|
||||
newinput[j]->setWriteMask();
|
||||
// if (!seenunspliced) {
|
||||
// // Check to see if a concatenation of inputs already exists
|
||||
// // If it existed already it would be defined at fd->getAddress()
|
||||
|
|
|
@ -249,10 +249,10 @@ class Heritage {
|
|||
void guard(const Address &addr,int4 size,vector<Varnode *> &read,vector<Varnode *> &write,vector<Varnode *> &inputvars);
|
||||
void guardInput(const Address &addr,int4 size,vector<Varnode *> &input);
|
||||
void guardCallOverlappingInput(FuncCallSpecs *fc,const Address &addr,const Address &transAddr,int4 size);
|
||||
void guardCalls(uint4 flags,const Address &addr,int4 size,vector<Varnode *> &write);
|
||||
void guardCalls(uint4 fl,const Address &addr,int4 size,vector<Varnode *> &write);
|
||||
void guardStores(const Address &addr,int4 size,vector<Varnode *> &write);
|
||||
void guardLoads(uint4 flags,const Address &addr,int4 size,vector<Varnode *> &write);
|
||||
void guardReturns(uint4 flags,const Address &addr,int4 size,vector<Varnode *> &write);
|
||||
void guardLoads(uint4 fl,const Address &addr,int4 size,vector<Varnode *> &write);
|
||||
void guardReturns(uint4 fl,const Address &addr,int4 size,vector<Varnode *> &write);
|
||||
static void buildRefinement(vector<int4> &refine,const Address &addr,int4 size,const vector<Varnode *> &vnlist);
|
||||
void splitByRefinement(Varnode *vn,const Address &addr,const vector<int4> &refine,vector<Varnode *> &split);
|
||||
void refineRead(Varnode *vn,const Address &addr,const vector<int4> &refine,vector<Varnode *> &newvn);
|
||||
|
|
|
@ -1518,16 +1518,16 @@ bool JumpBasic2::foldInOneGuard(Funcdata *fd,GuardRecord &guard,JumpTable *jump)
|
|||
return true;
|
||||
}
|
||||
|
||||
void JumpBasic2::initializeStart(const PathMeld &pathMeld)
|
||||
void JumpBasic2::initializeStart(const PathMeld &pMeld)
|
||||
|
||||
{
|
||||
if (pathMeld.empty()) {
|
||||
if (pMeld.empty()) {
|
||||
extravn = (Varnode *)0;
|
||||
return;
|
||||
}
|
||||
// Initialize at point where the JumpBasic model failed
|
||||
extravn = pathMeld.getVarnode(pathMeld.numCommonVarnode()-1);
|
||||
origPathMeld.set(pathMeld);
|
||||
extravn = pMeld.getVarnode(pMeld.numCommonVarnode()-1);
|
||||
origPathMeld.set(pMeld);
|
||||
}
|
||||
|
||||
bool JumpBasic2::recoverModel(Funcdata *fd,PcodeOp *indop,uint4 matchsize,uint4 maxtablesize)
|
||||
|
|
|
@ -409,7 +409,7 @@ class JumpBasic2 : public JumpBasic {
|
|||
virtual bool foldInOneGuard(Funcdata *fd,GuardRecord &guard,JumpTable *jump);
|
||||
public:
|
||||
JumpBasic2(JumpTable *jt) : JumpBasic(jt) {} ///< Constructor
|
||||
void initializeStart(const PathMeld &pathMeld); ///< Pass in the prior PathMeld calculation
|
||||
void initializeStart(const PathMeld &pMeld); ///< Pass in the prior PathMeld calculation
|
||||
virtual bool recoverModel(Funcdata *fd,PcodeOp *indop,uint4 matchsize,uint4 maxtablesize);
|
||||
virtual void findUnnormalized(uint4 maxaddsub,uint4 maxleftright,uint4 maxext);
|
||||
virtual JumpModel *clone(JumpTable *jt) const;
|
||||
|
|
|
@ -116,7 +116,6 @@ void ExecutablePcode::build(void)
|
|||
InjectContext &icontext(glb->pcodeinjectlib->getCachedContext());
|
||||
icontext.clear();
|
||||
uintb uniqReserve = 0x10; // Temporary register space reserved for inputs and output
|
||||
Architecture *glb = emulator.getArch();
|
||||
AddrSpace *codeSpace = glb->getDefaultCodeSpace();
|
||||
AddrSpace *uniqSpace = glb->getUniqueSpace();
|
||||
icontext.baseaddr = Address(codeSpace,0x1000); // Fake address
|
||||
|
|
|
@ -251,9 +251,9 @@ void PrintC::pushTypeStart(const Datatype *ct,bool noident)
|
|||
|
||||
if (ct->getName().size()==0) { // Check for anonymous type
|
||||
// We could support a struct or enum declaration here
|
||||
string name = genericTypeName(ct);
|
||||
string nm = genericTypeName(ct);
|
||||
pushOp(tok,(const PcodeOp *)0);
|
||||
pushAtom(Atom(name,typetoken,EmitXml::type_color,ct));
|
||||
pushAtom(Atom(nm,typetoken,EmitXml::type_color,ct));
|
||||
}
|
||||
else {
|
||||
pushOp(tok,(const PcodeOp *)0);
|
||||
|
@ -514,8 +514,8 @@ void PrintC::opCall(const PcodeOp *op)
|
|||
if (callpoint->getSpace()->getType()==IPTR_FSPEC) {
|
||||
fc = FuncCallSpecs::getFspecFromConst(callpoint->getAddr());
|
||||
if (fc->getName().size()==0) {
|
||||
string name = genericFunctionName(fc->getEntryAddress());
|
||||
pushAtom(Atom(name,functoken,EmitXml::funcname_color,op,(const Funcdata *)0));
|
||||
string nm = genericFunctionName(fc->getEntryAddress());
|
||||
pushAtom(Atom(nm,functoken,EmitXml::funcname_color,op,(const Funcdata *)0));
|
||||
}
|
||||
else {
|
||||
Funcdata *fd = fc->getFuncdata();
|
||||
|
@ -621,9 +621,9 @@ void PrintC::opConstructor(const PcodeOp *op,bool withNew)
|
|||
if (dt->getMetatype() == TYPE_PTR) {
|
||||
dt = ((TypePointer *)dt)->getPtrTo();
|
||||
}
|
||||
string name = dt->getName();
|
||||
string nm = dt->getName();
|
||||
pushOp(&function_call,op);
|
||||
pushAtom(Atom(name,optoken,EmitXml::funcname_color,op));
|
||||
pushAtom(Atom(nm,optoken,EmitXml::funcname_color,op));
|
||||
// implied vn's pushed on in reverse order for efficiency
|
||||
// see PrintLanguage::pushVnImplied
|
||||
if (op->numInput()>3) { // Multiple (non-this) parameters
|
||||
|
@ -1035,19 +1035,19 @@ void PrintC::opNewOp(const PcodeOp *op)
|
|||
// Array allocation form
|
||||
pushOp(&new_op,op);
|
||||
pushAtom(Atom("new",optoken,EmitXml::keyword_color,op,outvn));
|
||||
string name;
|
||||
string nm;
|
||||
if (outvn == (const Varnode *)0) { // Its technically possible, for new result to be unused
|
||||
name = "<unused>";
|
||||
nm = "<unused>";
|
||||
}
|
||||
else {
|
||||
Datatype *dt = outvn->getType();
|
||||
while (dt->getMetatype() == TYPE_PTR) {
|
||||
dt = ((TypePointer *)dt)->getPtrTo();
|
||||
}
|
||||
name = dt->getName();
|
||||
nm = dt->getName();
|
||||
}
|
||||
pushOp(&subscript,op);
|
||||
pushAtom(Atom(name,optoken,EmitXml::type_color,op));
|
||||
pushAtom(Atom(nm,optoken,EmitXml::type_color,op));
|
||||
pushVnImplied(vn1,op,mods);
|
||||
return;
|
||||
}
|
||||
|
@ -1642,7 +1642,7 @@ bool PrintC::pushEquate(uintb val,int4 sz,const EquateSymbol *sym,const Varnode
|
|||
void PrintC::pushAnnotation(const Varnode *vn,const PcodeOp *op)
|
||||
|
||||
{
|
||||
const Scope *scope = op->getParent()->getFuncdata()->getScopeLocal();
|
||||
const Scope *symScope = op->getParent()->getFuncdata()->getScopeLocal();
|
||||
int4 size = 0;
|
||||
if (op->code() == CPUI_CALLOTHER) {
|
||||
// This construction is for volatile CALLOTHERs where the input annotation is the original address
|
||||
|
@ -1663,9 +1663,9 @@ void PrintC::pushAnnotation(const Varnode *vn,const PcodeOp *op)
|
|||
}
|
||||
SymbolEntry *entry;
|
||||
if (size != 0)
|
||||
entry = scope->queryContainer(vn->getAddr(),size,op->getAddr());
|
||||
entry = symScope->queryContainer(vn->getAddr(),size,op->getAddr());
|
||||
else {
|
||||
entry = scope->queryContainer(vn->getAddr(),1,op->getAddr());
|
||||
entry = symScope->queryContainer(vn->getAddr(),1,op->getAddr());
|
||||
if (entry != (SymbolEntry *)0)
|
||||
size = entry->getSize();
|
||||
else
|
||||
|
@ -1829,8 +1829,8 @@ void PrintC::pushMismatchSymbol(const Symbol *sym,int4 off,int4 sz,
|
|||
|
||||
// We prepend an underscore to indicate a close
|
||||
// but not quite match
|
||||
string name = '_'+sym->getName();
|
||||
pushAtom(Atom(name,vartoken,EmitXml::var_color,op,vn));
|
||||
string nm = '_'+sym->getName();
|
||||
pushAtom(Atom(nm,vartoken,EmitXml::var_color,op,vn));
|
||||
}
|
||||
else
|
||||
pushUnnamedLocation(vn->getAddr(),vn,op);
|
||||
|
@ -2235,15 +2235,15 @@ void PrintC::emitVarDeclStatement(const Symbol *sym)
|
|||
emit->print(";");
|
||||
}
|
||||
|
||||
bool PrintC::emitScopeVarDecls(const Scope *scope,int4 cat)
|
||||
bool PrintC::emitScopeVarDecls(const Scope *symScope,int4 cat)
|
||||
|
||||
{
|
||||
bool notempty = false;
|
||||
|
||||
if (cat >= 0) { // If a category is specified
|
||||
int4 sz = scope->getCategorySize(cat);
|
||||
int4 sz = symScope->getCategorySize(cat);
|
||||
for(int4 i=0;i<sz;++i) {
|
||||
Symbol *sym = scope->getCategorySymbol(cat,i);
|
||||
Symbol *sym = symScope->getCategorySymbol(cat,i);
|
||||
// Slightly different handling for categorized symbols (cat=1 is dynamic symbols)
|
||||
if (sym->getName().size() == 0) continue;
|
||||
if (sym->isNameUndefined()) continue;
|
||||
|
@ -2252,8 +2252,8 @@ bool PrintC::emitScopeVarDecls(const Scope *scope,int4 cat)
|
|||
}
|
||||
return notempty;
|
||||
}
|
||||
MapIterator iter = scope->begin();
|
||||
MapIterator enditer = scope->end();
|
||||
MapIterator iter = symScope->begin();
|
||||
MapIterator enditer = symScope->end();
|
||||
for(;iter!=enditer;++iter) {
|
||||
const SymbolEntry *entry = *iter;
|
||||
if (entry->isPiece()) continue; // Don't do a partial entry
|
||||
|
@ -2271,8 +2271,8 @@ bool PrintC::emitScopeVarDecls(const Scope *scope,int4 cat)
|
|||
notempty = true;
|
||||
emitVarDeclStatement(sym);
|
||||
}
|
||||
list<SymbolEntry>::const_iterator iter_d = scope->beginDynamic();
|
||||
list<SymbolEntry>::const_iterator enditer_d = scope->endDynamic();
|
||||
list<SymbolEntry>::const_iterator iter_d = symScope->beginDynamic();
|
||||
list<SymbolEntry>::const_iterator enditer_d = symScope->endDynamic();
|
||||
for(;iter_d!=enditer_d;++iter_d) {
|
||||
const SymbolEntry *entry = &(*iter_d);
|
||||
if (entry->isPiece()) continue; // Don't do a partial entry
|
||||
|
@ -2326,15 +2326,15 @@ void PrintC::emitFunctionDeclaration(const Funcdata *fd)
|
|||
|
||||
/// For the given scope and all of its children that are not \e function scopes,
|
||||
/// emit a variable declaration for each symbol.
|
||||
/// \param scope is the given scope
|
||||
void PrintC::emitGlobalVarDeclsRecursive(Scope *scope)
|
||||
/// \param symScope is the given scope
|
||||
void PrintC::emitGlobalVarDeclsRecursive(Scope *symScope)
|
||||
|
||||
{
|
||||
if (!scope->isGlobal()) return;
|
||||
emitScopeVarDecls(scope,-1);
|
||||
if (!symScope->isGlobal()) return;
|
||||
emitScopeVarDecls(symScope,-1);
|
||||
ScopeMap::const_iterator iter,enditer;
|
||||
iter = scope->childrenBegin();
|
||||
enditer = scope->childrenEnd();
|
||||
iter = symScope->childrenBegin();
|
||||
enditer = symScope->childrenEnd();
|
||||
for(;iter!=enditer;++iter) {
|
||||
emitGlobalVarDeclsRecursive((*iter).second);
|
||||
}
|
||||
|
@ -2665,12 +2665,12 @@ void PrintC::emitBlockIf(const BlockIf *bl)
|
|||
emit->endBlock(id2);
|
||||
}
|
||||
else {
|
||||
int4 id = emit->startIndent();
|
||||
int4 id2 = emit->startIndent();
|
||||
emit->print("{");
|
||||
int4 id2 = emit->beginBlock(elseBlock);
|
||||
int4 id3 = emit->beginBlock(elseBlock);
|
||||
elseBlock->emit(this);
|
||||
emit->endBlock(id2);
|
||||
emit->stopIndent(id);
|
||||
emit->endBlock(id3);
|
||||
emit->stopIndent(id2);
|
||||
emit->tagLine();
|
||||
emit->print("}");
|
||||
}
|
||||
|
@ -2923,8 +2923,8 @@ void PrintC::emitLabel(const FlowBlock *bl)
|
|||
uintb off = addr.getOffset();
|
||||
if (!bb->hasSpecialLabel()) {
|
||||
if (bb->getType() == FlowBlock::t_basic) {
|
||||
const Scope *scope = ((const BlockBasic *)bb)->getFuncdata()->getScopeLocal();
|
||||
Symbol *sym = scope->queryCodeLabel(addr);
|
||||
const Scope *symScope = ((const BlockBasic *)bb)->getFuncdata()->getScopeLocal();
|
||||
Symbol *sym = symScope->queryCodeLabel(addr);
|
||||
if (sym != (Symbol *)0) {
|
||||
emit->tagLabel(sym->getName().c_str(),EmitXml::no_color,spc,off);
|
||||
return;
|
||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
|||
void emitEnumDefinition(const TypeEnum *ct); ///< Emit the definition of an \e enumeration data-type
|
||||
void emitPrototypeOutput(const FuncProto *proto,const Funcdata *fd); ///< Emit the output data-type of a function prototype
|
||||
void emitPrototypeInputs(const FuncProto *proto); ///< Emit the input data-types of a function prototype
|
||||
void emitGlobalVarDeclsRecursive(Scope *scope); ///< Emit variable declarations for all global symbols under given scope
|
||||
void emitGlobalVarDeclsRecursive(Scope *symScope); ///< Emit variable declarations for all global symbols under given scope
|
||||
void emitLocalVarDecls(const Funcdata *fd); ///< Emit variable declarations for a function
|
||||
void emitStatement(const PcodeOp *inst); ///< Emit a statement in the body of a function
|
||||
bool emitInplaceOp(const PcodeOp *op); ///< Attempt to emit an expression rooted at an \e in-place operator
|
||||
|
@ -192,7 +192,7 @@ protected:
|
|||
virtual void emitExpression(const PcodeOp *op);
|
||||
virtual void emitVarDecl(const Symbol *sym);
|
||||
virtual void emitVarDeclStatement(const Symbol *sym);
|
||||
virtual bool emitScopeVarDecls(const Scope *scope,int4 cat);
|
||||
virtual bool emitScopeVarDecls(const Scope *symScope,int4 cat);
|
||||
virtual void emitFunctionDeclaration(const Funcdata *fd);
|
||||
virtual void emitTypeDefinition(const Datatype *ct);
|
||||
virtual bool checkPrintNegation(const Varnode *vn);
|
||||
|
|
|
@ -101,8 +101,8 @@ void PrintJava::pushTypeStart(const Datatype *ct,bool noident)
|
|||
|
||||
if (ct->getName().size()==0) { // Check for anonymous type
|
||||
// We could support a struct or enum declaration here
|
||||
string name = genericTypeName(ct);
|
||||
pushAtom(Atom(name,typetoken,EmitXml::type_color,ct));
|
||||
string nm = genericTypeName(ct);
|
||||
pushAtom(Atom(nm,typetoken,EmitXml::type_color,ct));
|
||||
}
|
||||
else {
|
||||
pushAtom(Atom(ct->getName(),typetoken,EmitXml::type_color,ct));
|
||||
|
|
|
@ -382,9 +382,9 @@ protected:
|
|||
///
|
||||
/// A subset of all variables can be declared by specifying a category,
|
||||
/// 0 for parameters, -1 for everything.
|
||||
/// \param scope is the given Scope
|
||||
/// \param symScope is the given Scope
|
||||
/// \param cat is the category of variable to declare
|
||||
virtual bool emitScopeVarDecls(const Scope *scope,int4 cat)=0;
|
||||
virtual bool emitScopeVarDecls(const Scope *symScope,int4 cat)=0;
|
||||
|
||||
/// \brief Emit a full expression
|
||||
///
|
||||
|
|
|
@ -3922,9 +3922,9 @@ int4 RuleLoadVarnode::applyOp(PcodeOp *op,Funcdata &data)
|
|||
Varnode *refvn = op->getOut();
|
||||
if (refvn->isSpacebasePlaceholder()) {
|
||||
refvn->clearSpacebasePlaceholder(); // Clear the trigger
|
||||
PcodeOp *op = refvn->loneDescend();
|
||||
if (op != (PcodeOp *)0) {
|
||||
FuncCallSpecs *fc = data.getCallSpecs(op);
|
||||
PcodeOp *placeOp = refvn->loneDescend();
|
||||
if (placeOp != (PcodeOp *)0) {
|
||||
FuncCallSpecs *fc = data.getCallSpecs(placeOp);
|
||||
if (fc != (FuncCallSpecs *)0)
|
||||
fc->resolveSpacebaseRelative(data,refvn);
|
||||
}
|
||||
|
@ -4622,10 +4622,10 @@ int4 RuleSubZext::applyOp(PcodeOp *op,Funcdata &data)
|
|||
if (subvn->loneDescend() != op) return 0; // and there is no other use of the truncated value
|
||||
Varnode *newvn = data.newUnique(basevn->getSize(),(Datatype *)0);
|
||||
constvn = subop->getIn(1);
|
||||
uintb val = constvn->getOffset() * 8;
|
||||
uintb rightVal = constvn->getOffset() * 8;
|
||||
data.opSetInput(op,newvn,0);
|
||||
data.opSetOpcode(subop,CPUI_INT_RIGHT); // Convert the truncation to a shift
|
||||
data.opSetInput(subop,data.newConstant(constvn->getSize(),val),1);
|
||||
data.opSetInput(subop,data.newConstant(constvn->getSize(),rightVal),1);
|
||||
data.opSetOutput(subop,newvn);
|
||||
}
|
||||
else
|
||||
|
@ -8146,15 +8146,13 @@ int4 RuleSubfloatConvert::applyOp(PcodeOp *op,Funcdata &data)
|
|||
SubfloatFlow subflow(&data,outvn,insize);
|
||||
if (!subflow.doTrace()) return 0;
|
||||
subflow.apply();
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
SubfloatFlow subflow(&data,invn,outsize);
|
||||
if (!subflow.doTrace()) return 0;
|
||||
subflow.apply();
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/// \class RuleNegateNegate
|
||||
|
@ -9072,7 +9070,6 @@ Varnode *RulePopcountBoolXor::getBooleanResult(Varnode *vn,int4 bitPos,int4 &con
|
|||
return (Varnode *)0;
|
||||
}
|
||||
}
|
||||
return (Varnode *)0; // Never reach here
|
||||
}
|
||||
|
||||
/// \brief Return \b true if concatenating with a SUBPIECE of the given Varnode is unusual
|
||||
|
|
|
@ -552,8 +552,8 @@ uintb JoinSpace::restoreXmlAttributes(const Element *el,uint4 &size) const
|
|||
string attrVal = el->getAttributeValue(i);
|
||||
string::size_type offpos = attrVal.find(':');
|
||||
if (offpos == string::npos) {
|
||||
const Translate *trans = getTrans();
|
||||
const VarnodeData &point(trans->getRegister(attrVal));
|
||||
const Translate *tr = getTrans();
|
||||
const VarnodeData &point(tr->getRegister(attrVal));
|
||||
vdat = point;
|
||||
}
|
||||
else {
|
||||
|
@ -615,8 +615,8 @@ uintb JoinSpace::read(const string &s,int4 &size) const
|
|||
pieces.back() = getTrans()->getRegister(token);
|
||||
}
|
||||
catch(LowlevelError &err) { // Name doesn't exist
|
||||
char shortcut = token[0];
|
||||
AddrSpace *spc = getManager()->getSpaceByShortcut(shortcut);
|
||||
char tryShortcut = token[0];
|
||||
AddrSpace *spc = getManager()->getSpaceByShortcut(tryShortcut);
|
||||
if (spc == (AddrSpace *)0)
|
||||
throw LowlevelError("Could not parse join string");
|
||||
|
||||
|
|
|
@ -357,11 +357,11 @@ bool Datatype::isPtrsubMatching(uintb offset) const
|
|||
return false;
|
||||
}
|
||||
else {
|
||||
int4 size = offset;
|
||||
int4 sz = offset;
|
||||
int4 typesize = basetype->getSize();
|
||||
if ((basetype->metatype != TYPE_ARRAY)&&(basetype->metatype != TYPE_STRUCT))
|
||||
return false; // Not a pointer to a structured type
|
||||
else if ((typesize <= AddrSpace::addressToByteInt(size,wordsize))&&(typesize!=0))
|
||||
else if ((typesize <= AddrSpace::addressToByteInt(sz,wordsize))&&(typesize!=0))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -374,10 +374,10 @@ void Datatype::restoreXmlBasic(const Element *el)
|
|||
|
||||
{
|
||||
name = el->getAttributeValue("name");
|
||||
istringstream i(el->getAttributeValue("size"));
|
||||
i.unsetf(ios::dec | ios::hex | ios::oct);
|
||||
istringstream s(el->getAttributeValue("size"));
|
||||
s.unsetf(ios::dec | ios::hex | ios::oct);
|
||||
size = -1;
|
||||
i >> size;
|
||||
s >> size;
|
||||
if (size < 0)
|
||||
throw LowlevelError("Bad size for type "+name);
|
||||
metatype = string2metatype( el->getAttributeValue("metatype") );
|
||||
|
@ -389,9 +389,9 @@ void Datatype::restoreXmlBasic(const Element *el)
|
|||
flags |= coretype;
|
||||
}
|
||||
else if (attribName == "id") {
|
||||
istringstream i1(el->getAttributeValue(i));
|
||||
i1.unsetf(ios::dec | ios::hex | ios::oct);
|
||||
i1 >> id;
|
||||
istringstream s1(el->getAttributeValue(i));
|
||||
s1.unsetf(ios::dec | ios::hex | ios::oct);
|
||||
s1 >> id;
|
||||
}
|
||||
else if (attribName == "varlength") {
|
||||
if (xml_readbool(el->getAttributeValue(i)))
|
||||
|
@ -1293,10 +1293,10 @@ int4 TypeCode::compareBasic(const TypeCode *op) const
|
|||
int4 opnump = op->proto->numParams();
|
||||
if (nump != opnump)
|
||||
return (opnump < nump) ? -1 : 1;
|
||||
uint4 flags = proto->getComparableFlags();
|
||||
uint4 myflags = proto->getComparableFlags();
|
||||
uint4 opflags = op->proto->getComparableFlags();
|
||||
if (flags != opflags)
|
||||
return (flags < opflags) ? -1 : 1;
|
||||
if (myflags != opflags)
|
||||
return (myflags < opflags) ? -1 : 1;
|
||||
|
||||
return 2; // Carry on with comparison of parameters
|
||||
}
|
||||
|
@ -1467,8 +1467,8 @@ Datatype *TypeSpacebase::nearestArrayedComponentForward(uintb off,uintb *newoff,
|
|||
return symbolType;
|
||||
}
|
||||
}
|
||||
int4 size = AddrSpace::byteToAddressInt(smallest->getSize(), spaceid->getWordSize());
|
||||
nextAddr = smallest->getAddr() + size;
|
||||
int4 sz = AddrSpace::byteToAddressInt(smallest->getSize(), spaceid->getWordSize());
|
||||
nextAddr = smallest->getAddr() + sz;
|
||||
}
|
||||
if (nextAddr < addr)
|
||||
return (Datatype *)0; // Don't let the address wrap
|
||||
|
|
|
@ -523,23 +523,23 @@ int4 HighVariable::markExpression(Varnode *vn,vector<HighVariable *> &highList)
|
|||
path.pop_back();
|
||||
continue;
|
||||
}
|
||||
Varnode *vn = node.op->getIn(node.slot);
|
||||
Varnode *curVn = node.op->getIn(node.slot);
|
||||
node.slot += 1;
|
||||
if (vn->isAnnotation()) continue;
|
||||
if (vn->isExplicit()) {
|
||||
high = vn->getHigh();
|
||||
if (curVn->isAnnotation()) continue;
|
||||
if (curVn->isExplicit()) {
|
||||
high = curVn->getHigh();
|
||||
if (high->isMark()) continue; // Already in the list
|
||||
high->setMark();
|
||||
highList.push_back(high);
|
||||
continue; // Truncate at explicit
|
||||
}
|
||||
if (!vn->isWritten()) continue;
|
||||
op = vn->getDef();
|
||||
if (!curVn->isWritten()) continue;
|
||||
op = curVn->getDef();
|
||||
if (op->isCall())
|
||||
retVal |= 1;
|
||||
if (op->code() == CPUI_LOAD)
|
||||
retVal |= 2;
|
||||
path.push_back(PcodeOpNode(vn->getDef(),0));
|
||||
path.push_back(PcodeOpNode(curVn->getDef(),0));
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
|
|
@ -722,12 +722,12 @@ MapState::MapState(AddrSpace *spc,const RangeList &rn,
|
|||
{
|
||||
spaceid = spc;
|
||||
defaultType = dt;
|
||||
set<Range>::const_iterator iter;
|
||||
for(iter=pm.begin();iter!=pm.end();++iter) {
|
||||
AddrSpace *spc = (*iter).getSpace();
|
||||
uintb first = (*iter).getFirst();
|
||||
uintb last = (*iter).getLast();
|
||||
range.removeRange(spc,first,last); // Clear possible input symbols
|
||||
set<Range>::const_iterator pmiter;
|
||||
for(pmiter=pm.begin();pmiter!=pm.end();++pmiter) {
|
||||
AddrSpace *pmSpc = (*pmiter).getSpace();
|
||||
uintb first = (*pmiter).getFirst();
|
||||
uintb last = (*pmiter).getLast();
|
||||
range.removeRange(pmSpc,first,last); // Clear possible input symbols
|
||||
}
|
||||
#ifdef OPACTION_DEBUG
|
||||
debugon = false;
|
||||
|
@ -737,9 +737,9 @@ MapState::MapState(AddrSpace *spc,const RangeList &rn,
|
|||
MapState::~MapState(void)
|
||||
|
||||
{
|
||||
vector<RangeHint *>::iterator iter;
|
||||
for(iter=maplist.begin();iter!=maplist.end();++iter)
|
||||
delete *iter;
|
||||
vector<RangeHint *>::iterator riter;
|
||||
for(riter=maplist.begin();riter!=maplist.end();++riter)
|
||||
delete *riter;
|
||||
}
|
||||
|
||||
/// A specific range of bytes is described for the hint, given a starting offset and other information.
|
||||
|
@ -760,8 +760,8 @@ void MapState::addRange(uintb st,Datatype *ct,uint4 fl,RangeHint::RangeType rt,i
|
|||
intb sst = (intb)AddrSpace::byteToAddress(st,spaceid->getWordSize());
|
||||
sign_extend(sst,spaceid->getAddrSize()*8-1);
|
||||
sst = (intb)AddrSpace::addressToByte(sst,spaceid->getWordSize());
|
||||
RangeHint *range = new RangeHint(st,sz,sst,ct,fl,rt,hi);
|
||||
maplist.push_back(range);
|
||||
RangeHint *newRange = new RangeHint(st,sz,sst,ct,fl,rt,hi);
|
||||
maplist.push_back(newRange);
|
||||
#ifdef OPACTION_DEBUG
|
||||
if (debugon) {
|
||||
ostringstream s;
|
||||
|
@ -863,14 +863,14 @@ void MapState::addGuard(const LoadGuard &guard,OpCode opc,TypeFactory *typeFacto
|
|||
void MapState::gatherSymbols(const EntryMap *rangemap)
|
||||
|
||||
{
|
||||
list<SymbolEntry>::const_iterator iter;
|
||||
list<SymbolEntry>::const_iterator riter;
|
||||
Symbol *sym;
|
||||
if (rangemap == (EntryMap *)0) return;
|
||||
for(iter=rangemap->begin_list();iter!=rangemap->end_list();++iter) {
|
||||
sym = (*iter).getSymbol();
|
||||
for(riter=rangemap->begin_list();riter!=rangemap->end_list();++riter) {
|
||||
sym = (*riter).getSymbol();
|
||||
if (sym == (Symbol *)0) continue;
|
||||
// if ((*iter).isPiece()) continue; // This should probably never happen
|
||||
uintb start = (*iter).getAddr().getOffset();
|
||||
uintb start = (*riter).getAddr().getOffset();
|
||||
Datatype *ct = sym->getType();
|
||||
addRange(start,ct,sym->getFlags(),RangeHint::fixed,-1);
|
||||
}
|
||||
|
@ -890,8 +890,8 @@ bool MapState::initialize(void)
|
|||
sign_extend(sst,spaceid->getAddrSize()*8-1);
|
||||
sst = (intb)AddrSpace::addressToByte(sst,spaceid->getWordSize());
|
||||
// Add extra range to bound any final open entry
|
||||
RangeHint *range = new RangeHint(high,1,sst,defaultType,0,RangeHint::endpoint,-2);
|
||||
maplist.push_back(range);
|
||||
RangeHint *termRange = new RangeHint(high,1,sst,defaultType,0,RangeHint::endpoint,-2);
|
||||
maplist.push_back(termRange);
|
||||
|
||||
stable_sort(maplist.begin(),maplist.end(),RangeHint::compareRanges);
|
||||
reconcileDatatypes();
|
||||
|
@ -906,12 +906,12 @@ bool MapState::initialize(void)
|
|||
void MapState::gatherVarnodes(const Funcdata &fd)
|
||||
|
||||
{
|
||||
VarnodeLocSet::const_iterator iter,iterend;
|
||||
VarnodeLocSet::const_iterator riter,iterend;
|
||||
Varnode *vn;
|
||||
iter = fd.beginLoc(spaceid);
|
||||
riter = fd.beginLoc(spaceid);
|
||||
iterend = fd.endLoc(spaceid);
|
||||
while(iter != iterend) {
|
||||
vn = *iter++;
|
||||
while(riter != iterend) {
|
||||
vn = *riter++;
|
||||
if (vn->isFree()) continue;
|
||||
uintb start = vn->getOffset();
|
||||
Datatype *ct = vn->getType();
|
||||
|
@ -929,13 +929,13 @@ void MapState::gatherHighs(const Funcdata &fd)
|
|||
|
||||
{
|
||||
vector<HighVariable *> varvec;
|
||||
VarnodeLocSet::const_iterator iter,iterend;
|
||||
VarnodeLocSet::const_iterator riter,iterend;
|
||||
Varnode *vn;
|
||||
HighVariable *high;
|
||||
iter = fd.beginLoc(spaceid);
|
||||
riter = fd.beginLoc(spaceid);
|
||||
iterend = fd.endLoc(spaceid);
|
||||
while(iter != iterend) {
|
||||
vn = *iter++;
|
||||
while(riter != iterend) {
|
||||
vn = *riter++;
|
||||
high = vn->getHigh();
|
||||
if (high == (HighVariable *)0) continue;
|
||||
if (high->isMark()) continue;
|
||||
|
@ -986,12 +986,12 @@ void MapState::gatherOpen(const Funcdata &fd)
|
|||
|
||||
TypeFactory *typeFactory = fd.getArch()->types;
|
||||
const list<LoadGuard> &loadGuard( fd.getLoadGuards() );
|
||||
for(list<LoadGuard>::const_iterator iter=loadGuard.begin();iter!=loadGuard.end();++iter)
|
||||
addGuard(*iter,CPUI_LOAD,typeFactory);
|
||||
for(list<LoadGuard>::const_iterator giter=loadGuard.begin();giter!=loadGuard.end();++giter)
|
||||
addGuard(*giter,CPUI_LOAD,typeFactory);
|
||||
|
||||
const list<LoadGuard> &storeGuard( fd.getStoreGuards() );
|
||||
for(list<LoadGuard>::const_iterator iter=storeGuard.begin();iter!=storeGuard.end();++iter)
|
||||
addGuard(*iter,CPUI_STORE,typeFactory);
|
||||
for(list<LoadGuard>::const_iterator siter=storeGuard.begin();siter!=storeGuard.end();++siter)
|
||||
addGuard(*siter,CPUI_STORE,typeFactory);
|
||||
}
|
||||
|
||||
/// Define stack Symbols based on Varnodes.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue