mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-26 22:21:52 +00:00
Merge remote-tracking branch 'origin/GP-2006_DynamicHashCompare'
This commit is contained in:
commit
357ff97cb3
@ -393,7 +393,7 @@ void DynamicHash::uniqueHash(const Varnode *root,Funcdata *fd)
|
||||
Varnode *tmpvn = vnlist[i];
|
||||
clear();
|
||||
calcHash(tmpvn,method);
|
||||
if (hash == tmphash) { // Hash collision
|
||||
if (getComparable(hash) == getComparable(tmphash)) { // Hash collision
|
||||
vnlist2.push_back(tmpvn);
|
||||
if (vnlist2.size()>maxduplicates) break;
|
||||
}
|
||||
@ -449,7 +449,7 @@ void DynamicHash::uniqueHash(const PcodeOp *op,int4 slot,Funcdata *fd)
|
||||
if (slot >= tmpop->numInput()) continue;
|
||||
clear();
|
||||
calcHash(tmpop,slot,method);
|
||||
if (hash == tmphash) { // Hash collision
|
||||
if (getComparable(hash) == getComparable(tmphash)) { // Hash collision
|
||||
oplist2.push_back(tmpop);
|
||||
if (oplist2.size()>maxduplicates)
|
||||
break;
|
||||
@ -508,7 +508,7 @@ Varnode *DynamicHash::findVarnode(const Funcdata *fd,const Address &addr,uint8 h
|
||||
Varnode *tmpvn = vnlist[i];
|
||||
clear();
|
||||
calcHash(tmpvn,method);
|
||||
if (hash == h)
|
||||
if (getComparable(hash) == getComparable(h))
|
||||
vnlist2.push_back(tmpvn);
|
||||
}
|
||||
if (total != vnlist2.size()) return (Varnode *)0;
|
||||
@ -542,7 +542,7 @@ PcodeOp *DynamicHash::findOp(const Funcdata *fd,const Address &addr,uint8 h)
|
||||
if (slot >= tmpop->numInput()) continue;
|
||||
clear();
|
||||
calcHash(tmpop,slot,method);
|
||||
if (hash == h)
|
||||
if (getComparable(hash) == getComparable(h))
|
||||
oplist2.push_back(tmpop);
|
||||
}
|
||||
if (total != oplist2.size())
|
||||
|
@ -96,6 +96,7 @@ public:
|
||||
static uint4 getTotalFromHash(uint8 h); ///< Retrieve the encoded collision total from a hash
|
||||
static bool getIsNotAttached(uint8 h); ///< Retrieve the attachment boolean from a hash
|
||||
static void clearTotalPosition(uint8 &h); ///< Clear the collision total and position fields within a hash
|
||||
static uint4 getComparable(uint8 h) { return (uint4)h; } ///< Get only the formal hash for comparing
|
||||
static uint4 transtable[]; ///< Translation of op-codes to hash values
|
||||
};
|
||||
|
||||
|
@ -398,7 +398,7 @@ public class DynamicHash {
|
||||
}
|
||||
clear();
|
||||
calcHash(tmpop, slot, method);
|
||||
if (hash == tmphash) { // Hash collision
|
||||
if (getComparable(hash) == getComparable(tmphash)) { // Hash collision
|
||||
oplist2.add(tmpop);
|
||||
if (oplist2.size() > maxduplicates) {
|
||||
break;
|
||||
@ -461,7 +461,7 @@ public class DynamicHash {
|
||||
Varnode tmpvn = vnlist.get(i);
|
||||
clear();
|
||||
calcHash(tmpvn, method);
|
||||
if (hash == tmphash) { // Hash collision
|
||||
if (getComparable(hash) == getComparable(tmphash)) { // Hash collision
|
||||
vnlist2.add(tmpvn);
|
||||
if (vnlist2.size() > maxduplicates) {
|
||||
break;
|
||||
@ -600,7 +600,7 @@ public class DynamicHash {
|
||||
Varnode tmpvn = vnlist.get(i);
|
||||
dhash.clear();
|
||||
dhash.calcHash(tmpvn, method);
|
||||
if (dhash.getHash() == h) {
|
||||
if (getComparable(dhash.getHash()) == getComparable(h)) {
|
||||
vnlist2.add(tmpvn);
|
||||
}
|
||||
}
|
||||
@ -621,11 +621,12 @@ public class DynamicHash {
|
||||
ArrayList<PcodeOp> oplist2 = new ArrayList<>();
|
||||
gatherOpsAtAddress(oplist, fd, addr);
|
||||
for (PcodeOp tmpop : oplist) {
|
||||
if (slot >= tmpop.getNumInputs())
|
||||
if (slot >= tmpop.getNumInputs()) {
|
||||
continue;
|
||||
}
|
||||
dhash.clear();
|
||||
dhash.calcHash(tmpop, slot, method);
|
||||
if (dhash.getHash() == h) {
|
||||
if (getComparable(dhash.getHash()) == getComparable(h)) {
|
||||
oplist2.add(tmpop);
|
||||
}
|
||||
}
|
||||
@ -721,6 +722,10 @@ public class DynamicHash {
|
||||
return h;
|
||||
}
|
||||
|
||||
public static int getComparable(long h) {
|
||||
return (int) h;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that extendval is equal to val1, where extendval may be an extension
|
||||
* @param val1 is the value that needs to be matched
|
||||
|
Loading…
Reference in New Issue
Block a user