diff options
| author | Mason Reed <mason@vector35.com> | 2024-12-03 17:49:11 -0500 |
|---|---|---|
| committer | Mason Reed <mason@vector35.com> | 2025-03-19 21:17:34 -0400 |
| commit | 31ef836d222aaa8786d4ac2c36e09e4fd9e02929 (patch) | |
| tree | a114bebf46837d110dbc9e7c560ca52d7348202b /plugins/rtti/rtti.cpp | |
| parent | 7794bcfa9f8c51442a87f10a3475612dfc4435d8 (diff) | |
Replace bad auto symbol for Itanium RTTI
Diffstat (limited to 'plugins/rtti/rtti.cpp')
| -rw-r--r-- | plugins/rtti/rtti.cpp | 25 |
1 files changed, 19 insertions, 6 deletions
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<std::string> RTTI::DemangleNameMS(BinaryView* view, bool allowMang } -std::optional<std::string> 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<std::string> RTTI::DemangleNameItanium(BinaryView* view, bool allowMangled, const std::string &mangledName) { - QualifiedName demangledName = {}; - Ref<Type> 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; } |
