diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.cc index 86492e63ce..c71858f759 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.cc @@ -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()) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.hh b/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.hh index 2607b603c4..83c7fe1fc8 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.hh +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/dynamic.hh @@ -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 }; diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java index 7d75b64ded..ac7dfa84c2 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/pcode/DynamicHash.java @@ -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 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