From b776df4c7cd3ba98ecdc833a1cd604ff58f44f06 Mon Sep 17 00:00:00 2001 From: ghizard <50744617+ghizard@users.noreply.github.com> Date: Mon, 30 Sep 2024 21:42:44 +0000 Subject: [PATCH] GP-4975 - PDB - allow VxTable mangled symbol to be primary for Demangler --- .../pdbapplicator/DefaultPdbApplicator.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/DefaultPdbApplicator.java b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/DefaultPdbApplicator.java index 93772aeb30..990dc5c7ec 100644 --- a/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/DefaultPdbApplicator.java +++ b/Ghidra/Features/PDB/src/main/java/ghidra/app/util/pdb/pdbapplicator/DefaultPdbApplicator.java @@ -2335,8 +2335,10 @@ public class DefaultPdbApplicator implements PdbApplicator { } if (!existingSymbol.getParentNamespace().equals(program.getGlobalNamespace())) { - // existing symbol has a non-global namespace - return doCreateSymbol(address, symbolPath, false, plateAddition); + // Existing symbol has a non-global namespace + if (!preferNewSymbolOverExistingNamespacedSymbol(symbolPath)) { + return doCreateSymbol(address, symbolPath, false, plateAddition); + } } if (symbolPath.getParent() != null) { @@ -2353,6 +2355,22 @@ public class DefaultPdbApplicator implements PdbApplicator { return doCreateSymbol(address, symbolPath, false, plateAddition); } + // We've found that a mangled version of vxtables can present more detailed information + // than a non-mangled vxtable symbol that has a namespace (the information is not + // as descriptive regarding vxtables owned by the child for a parent). So do not + // accept these existing symbol with namespace to maintain their primary status. + // + // Kludge... this mechanism might go away later if/when instead we evaluate all symbols at + // an address to do the right thing or if/when we process the tables in some place other + // than or besides the Demangler. + private boolean preferNewSymbolOverExistingNamespacedSymbol(SymbolPath symbolPath) { + String name = symbolPath.getName(); + if (name.startsWith("??_7") || name.startsWith("??_8")) { + return true; + } + return false; + } + private Symbol doCreateSymbol(Address address, SymbolPath symbolPath, boolean makePrimary, String plateAddition) { Symbol symbol = null;