From 31ef836d222aaa8786d4ac2c36e09e4fd9e02929 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Tue, 3 Dec 2024 17:49:11 -0500 Subject: Replace bad auto symbol for Itanium RTTI --- plugins/rtti/rtti.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'plugins/rtti/rtti.cpp') diff --git a/plugins/rtti/rtti.cpp b/plugins/rtti/rtti.cpp index d99983ee..623c523b 100644 --- a/plugins/rtti/rtti.cpp +++ b/plugins/rtti/rtti.cpp @@ -14,13 +14,26 @@ std::optional RTTI::DemangleNameMS(BinaryView* view, bool allowMang } -std::optional RTTI::DemangleNameGNU3(BinaryView* view, bool allowMangled, const std::string &mangledName) +std::string RemoveItaniumPrefix(const std::string& name) { + // Remove class prefixes. + // 7 is class_type + // 9 is si_class_type + // 14 is vmi_class_type + if (name.rfind('7', 0) == 0) + return name.substr(1); + if (name.rfind('9', 0) == 0) + return name.substr(1); + if (name.rfind("14", 0) == 0) + return name.substr(2); + return name; +} + + +std::optional RTTI::DemangleNameItanium(BinaryView* view, bool allowMangled, const std::string &mangledName) { - QualifiedName demangledName = {}; - Ref outType = {}; - if (!DemangleGNU3(view->GetDefaultArchitecture(), mangledName, outType, demangledName, true)) - return DemangleNameLLVM(allowMangled, mangledName); - return demangledName.GetString(); + if (auto demangledName = DemangleNameLLVM(allowMangled, mangledName)) + return RemoveItaniumPrefix(demangledName.value()); + return std::nullopt; } -- cgit v1.3.1