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