mirror of
https://github.com/NationalSecurityAgency/ghidra
synced 2024-08-27 13:03:12 +00:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
70489f8f1c
|
@ -408,7 +408,6 @@ public:
|
|||
void clearDeadVarnodes(void); ///< Delete any dead Varnodes
|
||||
void calcNZMask(void); ///< Calculate \e non-zero masks for all Varnodes
|
||||
void clearDeadOps(void) { obank.destroyDead(); } ///< Delete any dead PcodeOps
|
||||
void clearSymbolLinks(HighVariable *high); ///< Clear Symbols attached to Varnodes in the given HighVariable
|
||||
void remapVarnode(Varnode *vn,Symbol *sym,const Address &usepoint);
|
||||
void remapDynamicVarnode(Varnode *vn,Symbol *sym,const Address &usepoint,uint8 hash);
|
||||
Symbol *linkSymbol(Varnode *vn); ///< Find or create Symbol associated with given Varnode
|
||||
|
|
|
@ -1002,18 +1002,6 @@ bool Funcdata::syncVarnodesWithSymbol(VarnodeLocSet::const_iterator &iter,uint4
|
|||
return updateoccurred;
|
||||
}
|
||||
|
||||
/// For each instance Varnode, remove any SymbolEntry reference and associated properties.
|
||||
/// \param high is the given HighVariable to clear
|
||||
void Funcdata::clearSymbolLinks(HighVariable *high)
|
||||
|
||||
{
|
||||
for(int4 i=0;i<high->numInstances();++i) {
|
||||
Varnode *vn = high->getInstance(i);
|
||||
vn->mapentry = (SymbolEntry *)0;
|
||||
vn->clearFlags(Varnode::namelock | Varnode::typelock | Varnode::mapped);
|
||||
}
|
||||
}
|
||||
|
||||
/// \brief Remap a Symbol to a given Varnode using a static mapping
|
||||
///
|
||||
/// Any previous links between the Symbol, the Varnode, and the associate HighVariable are
|
||||
|
@ -1024,7 +1012,7 @@ void Funcdata::clearSymbolLinks(HighVariable *high)
|
|||
void Funcdata::remapVarnode(Varnode *vn,Symbol *sym,const Address &usepoint)
|
||||
|
||||
{
|
||||
clearSymbolLinks(vn->getHigh());
|
||||
vn->clearSymbolLinks();
|
||||
SymbolEntry *entry = localmap->remapSymbol(sym, vn->getAddr(), usepoint);
|
||||
vn->setSymbolEntry(entry);
|
||||
}
|
||||
|
@ -1040,7 +1028,7 @@ void Funcdata::remapVarnode(Varnode *vn,Symbol *sym,const Address &usepoint)
|
|||
void Funcdata::remapDynamicVarnode(Varnode *vn,Symbol *sym,const Address &usepoint,uint8 hash)
|
||||
|
||||
{
|
||||
clearSymbolLinks(vn->getHigh());
|
||||
vn->clearSymbolLinks();
|
||||
SymbolEntry *entry = localmap->remapSymbolDynamic(sym, hash, usepoint);
|
||||
vn->setSymbolEntry(entry);
|
||||
}
|
||||
|
|
|
@ -175,15 +175,14 @@ void HighVariable::updateSymbol(void) const
|
|||
highflags &= ~((uint4)symboldirty);
|
||||
vector<Varnode *>::const_iterator iter;
|
||||
symbol = (Symbol *)0;
|
||||
Varnode *vn = (Varnode *)0;
|
||||
|
||||
for(iter=inst.begin();iter!=inst.end();++iter) {
|
||||
Varnode *tmpvn = *iter;
|
||||
if (tmpvn->getSymbolEntry() != (SymbolEntry *)0)
|
||||
vn = tmpvn;
|
||||
Varnode *vn = *iter;
|
||||
if (vn->getSymbolEntry() != (SymbolEntry *)0) {
|
||||
setSymbol(vn);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (vn != (Varnode *)0)
|
||||
setSymbol(vn);
|
||||
}
|
||||
|
||||
/// Compare two Varnode objects based just on their storage address
|
||||
|
|
|
@ -88,6 +88,7 @@ private:
|
|||
void flagsDirty(void) const { highflags |= flagsdirty | namerepdirty; } ///< Mark the boolean properties as \e dirty
|
||||
void coverDirty(void) const { highflags |= coverdirty; } ///< Mark the cover as \e dirty
|
||||
void typeDirty(void) const { highflags |= typedirty; } ///< Mark the data-type as \e dirty
|
||||
void symbolDirty(void) const { highflags |= symboldirty; } ///< Mark the symbol as \e dirty
|
||||
void setUnmerged(void) const { highflags |= unmerged; } ///< Mark \b this as having merge problems
|
||||
public:
|
||||
HighVariable(Varnode *vn); ///< Construct a HighVariable with a single member Varnode
|
||||
|
|
|
@ -352,6 +352,22 @@ void Varnode::clearFlags(uint4 fl) const
|
|||
}
|
||||
}
|
||||
|
||||
/// For \b this Varnode and any others attached to the same HighVariable,
|
||||
/// remove any SymbolEntry reference and associated properties.
|
||||
void Varnode::clearSymbolLinks(void)
|
||||
|
||||
{
|
||||
bool foundEntry = false;
|
||||
for(int4 i=0;i<high->numInstances();++i) {
|
||||
Varnode *vn = high->getInstance(i);
|
||||
foundEntry = foundEntry || (vn->mapentry != (SymbolEntry *)0);
|
||||
vn->mapentry = (SymbolEntry *)0;
|
||||
vn->clearFlags(Varnode::namelock | Varnode::typelock | Varnode::mapped);
|
||||
}
|
||||
if (foundEntry)
|
||||
high->symbolDirty();
|
||||
}
|
||||
|
||||
/// Directly change the defining PcodeOp and set appropriate dirty bits
|
||||
/// \param op is the pointer to the new PcodeOp, which can be \b null
|
||||
void Varnode::setDef(PcodeOp *op)
|
||||
|
|
|
@ -159,6 +159,7 @@ private:
|
|||
void clearCover(void) const; ///< Turn off any coverage information
|
||||
void setFlags(uint4 fl) const; ///< Internal method for setting boolean attributes
|
||||
void clearFlags(uint4 fl) const; ///< Internal method for clearing boolean attributes
|
||||
void clearSymbolLinks(void); ///< Clear any Symbol attached to \b this Varnode
|
||||
void setUnaffected(void) { setFlags(Varnode::unaffected); } ///< Mark Varnode as \e unaffected
|
||||
// These functions should be only private things used by VarnodeBank
|
||||
void setInput(void) { setFlags(Varnode::input|Varnode::coverdirty); } ///< Mark Varnode as \e input
|
||||
|
|
|
@ -19,30 +19,38 @@ package ghidra.program.model.correlate;
|
|||
* This encodes the main hash value for an n-gram, and the number of Instructions hashed
|
||||
*
|
||||
*/
|
||||
public class Hash implements Comparable<Hash> {
|
||||
public class Hash implements Comparable<Hash> {
|
||||
// Initial accumulator values for the hash functions. Should be non-zero for the CRC, but value doesn't matter otherwise
|
||||
public static final int SEED = 22222;
|
||||
public static final int ALTERNATE_SEED = 11111; // Must be different from SEED
|
||||
|
||||
protected int value; // Actual hash value
|
||||
protected int size; // Number of instructions involved in hash
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(Hash o) {
|
||||
return Long.compare(value, o.value);
|
||||
int cmp = Integer.compare(value, o.value);
|
||||
if (cmp == 0) {
|
||||
return Integer.compare(size, o.size);
|
||||
}
|
||||
return cmp;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return value == ((Hash)obj).value;
|
||||
Hash o = (Hash) obj;
|
||||
if (value != o.value) {
|
||||
return false;
|
||||
}
|
||||
return (size == o.size);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public Hash(int val,int sz) {
|
||||
|
||||
public Hash(int val, int sz) {
|
||||
value = val;
|
||||
size = sz;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue