Merge remote-tracking branch 'origin/GT-3580_DecompilerVariableNames'

This commit is contained in:
ghidorahrex 2020-03-06 08:53:18 -05:00
commit 6266b18e42
2 changed files with 9 additions and 15 deletions

View File

@ -2357,8 +2357,8 @@ void ActionNameVars::makeRec(ProtoParameter *param,Varnode *vn,map<HighVariable
}
}
HighVariable *high = vn->getHigh();
if (!high->isMark()) return; // Not one of the variables needing a name
if (high->isAddrTied()) return; // Don't propagate parameter name to address tied variable
if (param->getName().compare(0,6,"param_")==0) return;
map<HighVariable *,OpRecommend>::iterator iter = recmap.find(high);
if (iter != recmap.end()) { // We have seen this varnode before
@ -2391,18 +2391,6 @@ void ActionNameVars::lookForFuncParamNames(Funcdata &data,const vector<Varnode *
int4 numfunc = data.numCalls();
if (numfunc == 0) return;
int4 markcount = 0;
for(uint4 i=0;i<varlist.size();++i) { // Mark all the varnodes that can accept a name from a parameter
Varnode *vn = varlist[i];
if (vn->isFree()) continue;
if (vn->isInput()) continue; // Don't override unaffected or input naming strategy
Symbol *sym = vn->getHigh()->getSymbol();
if (sym == (Symbol *)0) continue;
if (!sym->isNameUndefined()) continue;
markcount += 1;
vn->getHigh()->setMark();
}
if (markcount == 0) return;
map<HighVariable *,OpRecommend> recmap;
ScopeLocal *localmap = data.getScopeLocal();
@ -2419,13 +2407,18 @@ void ActionNameVars::lookForFuncParamNames(Funcdata &data,const vector<Varnode *
makeRec(param,vn,recmap);
}
}
if (recmap.empty()) return;
map<HighVariable *,OpRecommend>::iterator iter;
for(uint4 i=0;i<varlist.size();++i) { // Do the actual naming in the original (address based) order
Varnode *vn = varlist[i];
if (vn->isFree()) continue;
if (vn->isInput()) continue; // Don't override unaffected or input naming strategy
HighVariable *high = vn->getHigh();
if (!high->isMark()) continue;
high->clearMark();
if (high->getNumMergeClasses() > 1) continue; // Don't inherit a name if speculatively merged
Symbol *sym = high->getSymbol();
if (sym == (Symbol *)0) continue;
if (!sym->isNameUndefined()) continue;
iter = recmap.find(high);
if (iter != recmap.end()) {
Symbol *sym = high->getSymbol();

View File

@ -104,6 +104,7 @@ public:
Varnode *getInputVarnode(void) const; ///< Find (the) input member Varnode
Varnode *getTypeRepresentative(void) const; ///< Get a member Varnode with the strongest data-type
Varnode *getNameRepresentative(void) const; ///< Get a member Varnode that dictates the naming of \b this HighVariable
int4 getNumMergeClasses(void) const { return numMergeClasses; } ///< Get the number of speculative merges for \b this
bool isMapped(void) const { updateFlags(); return ((flags&Varnode::mapped)!=0); } ///< Return \b true if \b this is mapped
bool isPersist(void) const { updateFlags(); return ((flags&Varnode::persist)!=0); } ///< Return \b true if \b this is a global variable
bool isAddrTied(void) const { updateFlags(); return ((flags&Varnode::addrtied)!=0); } ///< Return \b true if \b this is \e address \e ties