summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-25 12:50:57 -0400
committerMason Reed <mason@vector35.com>2025-04-25 12:50:57 -0400
commit997b4a14beafa2b92a75791f27dcb184c2c70706 (patch)
tree6f1463b9d683347e4f92d6eff65358fc79053747
parent71af6853ae407d70dc0783d5682b80563d045a90 (diff)
Fix Itanium RTTI skipping type info with stripped root type info object
-rw-r--r--plugins/rtti/itanium.cpp16
-rw-r--r--plugins/rtti/rtti.cpp1
2 files changed, 13 insertions, 4 deletions
diff --git a/plugins/rtti/itanium.cpp b/plugins/rtti/itanium.cpp
index cc632045..f2b773b0 100644
--- a/plugins/rtti/itanium.cpp
+++ b/plugins/rtti/itanium.cpp
@@ -321,10 +321,18 @@ std::optional<TypeInfoVariant> ReadTypeInfoVariant(BinaryView *view, uint64_t ob
uint64_t typeInfoAddr = reader.ReadPointer();
if (!view->IsValidOffset(typeInfoAddr))
return std::nullopt;
- auto vftSym = view->GetSymbolByAddress(typeInfoAddr);
- if (vftSym == nullptr)
- return std::nullopt;
- baseSym = vftSym;
+ auto typeInfoSym = view->GetSymbolByAddress(typeInfoAddr);
+ if (typeInfoSym == nullptr)
+ {
+ // For stripped binaries there will be no symbol, contruct a type info object and check.
+ auto rootTypeInfo = GetTypeInfo(view, typeInfoAddr);
+ if (!rootTypeInfo.has_value())
+ return std::nullopt;
+ if (rootTypeInfo->type_name.find("__cxxabiv1") == std::string::npos)
+ return std::nullopt;
+ typeInfoSym = new Symbol(DataSymbol, fmt::format("_typeinfo_for_{}", rootTypeInfo->type_name), typeInfoAddr);
+ }
+ baseSym = typeInfoSym;
}
auto baseSymName = baseSym->GetShortName();
diff --git a/plugins/rtti/rtti.cpp b/plugins/rtti/rtti.cpp
index 57cd52cf..f0cde410 100644
--- a/plugins/rtti/rtti.cpp
+++ b/plugins/rtti/rtti.cpp
@@ -39,6 +39,7 @@ std::string RemoveItaniumPrefix(std::string &name)
{
// Remove numerical prefixes.
// TODO: We might want to use the numbers for figuring out the class info.
+ // TODO: NSt6locale5facetE is not demangled. N and St seem to be prefixes.
while (!name.empty() && std::isdigit(name[0]))
name = name.substr(1);
return name;