From 07d2c34b3fe413f17629e2f563af38d82956d8b0 Mon Sep 17 00:00:00 2001 From: ghidra007 Date: Wed, 21 Aug 2024 16:57:21 +0000 Subject: [PATCH] GP-4862 fixed gcc dupe namespace creation mechanism. --- .../classrecovery/RTTIGccClassRecoverer.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java index 092f8a32a1..3f5b6ce71f 100644 --- a/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java +++ b/Ghidra/Features/Decompiler/ghidra_scripts/classrecovery/RTTIGccClassRecoverer.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -2820,20 +2820,24 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer { // get the newly created symbol to get the namespace Symbol typeinfoNameSymbol = symbolTable.getPrimarySymbol(typeinfoNameAddress); + Namespace typeinfoNamespace = typeinfoNameSymbol.getParentNamespace(); + // need to account for rare case where there are more than one typeinfos with // exact same class and name so make two classes in this case - name second one // dupe# List symbols = symbolTable.getSymbols(typeinfoNameSymbol.getName(), - typeinfoNameSymbol.getParentNamespace()); + typeinfoNamespace); if (symbols.size() > 1) { + Namespace parentNamespace = typeinfoNamespace.getParentNamespace(); Msg.debug(this, "Duplicate typeinfo namespace: " + - typeinfoNameSymbol.getParentNamespace().toString()); + typeinfoNamespace.toString()); for (Symbol symbol : symbols) { Msg.debug(this, symbol.getAddress()); } - Namespace newNamespace = symbolTable.getOrCreateNameSpace(globalNamespace, - typeinfoNameSymbol.getParentNamespace().getName(true) + "DUPE", + + Namespace newNamespace = symbolTable.getOrCreateNameSpace(parentNamespace, + typeinfoNamespace.getName() + "DUPE", SourceType.ANALYSIS); try { typeinfoNameSymbol.setNamespace(newNamespace); @@ -2868,7 +2872,6 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer { return newSymbol; } - private Symbol createTypeinfoSymbolFromNonMangledString(Address typeinfoAddress) throws DuplicateNameException, InvalidInputException, CancelledException { @@ -3753,7 +3756,6 @@ public class RTTIGccClassRecoverer extends RTTIClassRecoverer { return null; } - /* * Method to find special vtable using special typeinfo references. This * assumption that vtable is defaultPtrSize above ref to single specialTypeinfo