mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GP-3014 - Add deduping to DynamicHash gatherFirstLevelVars
This commit is contained in:
parent
f1dc157f04
commit
4b2a78b1fb
3 changed files with 46 additions and 9 deletions
|
@ -415,7 +415,7 @@ public class DynamicHash {
|
|||
hash <<= 4;
|
||||
hash |= method; // 4-bits
|
||||
hash <<= 7;
|
||||
hash |= op.getOpcode(); // 7-bits
|
||||
hash |= transtable[op.getOpcode()]; // 7-bits
|
||||
hash <<= 5;
|
||||
hash |= slot & 0x1f; // 5-bits
|
||||
|
||||
|
@ -705,6 +705,21 @@ public class DynamicHash {
|
|||
}
|
||||
}
|
||||
|
||||
private static void dedupVarnodes(ArrayList<Varnode> varlist) {
|
||||
if (varlist.size() < 2) {
|
||||
return;
|
||||
}
|
||||
ArrayList<Varnode> resList = new ArrayList<>();
|
||||
HashSet<Varnode> hashSet = new HashSet<>();
|
||||
for (Varnode vn : varlist) {
|
||||
if (hashSet.add(vn)) {
|
||||
resList.add(vn);
|
||||
}
|
||||
}
|
||||
varlist.clear();
|
||||
varlist.addAll(resList);
|
||||
}
|
||||
|
||||
public static void gatherFirstLevelVars(ArrayList<Varnode> varlist, PcodeSyntaxTree fd,
|
||||
Address addr, long h) {
|
||||
int opc = getOpCodeFromHash(h);
|
||||
|
@ -714,7 +729,7 @@ public class DynamicHash {
|
|||
|
||||
while (iter.hasNext()) {
|
||||
PcodeOp op = iter.next();
|
||||
if (op.getOpcode() != opc) {
|
||||
if (transtable[op.getOpcode()] != opc) {
|
||||
continue;
|
||||
}
|
||||
if (slot < 0) {
|
||||
|
@ -745,6 +760,7 @@ public class DynamicHash {
|
|||
varlist.add(vn);
|
||||
}
|
||||
}
|
||||
dedupVarnodes(varlist);
|
||||
}
|
||||
|
||||
public static int getSlotFromHash(long h) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue