Skip to content

Commit 997b4a1

Browse files
committed
Fix Itanium RTTI skipping type info with stripped root type info object
1 parent 71af685 commit 997b4a1

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

plugins/rtti/itanium.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,18 @@ std::optional<TypeInfoVariant> ReadTypeInfoVariant(BinaryView *view, uint64_t ob
321321
uint64_t typeInfoAddr = reader.ReadPointer();
322322
if (!view->IsValidOffset(typeInfoAddr))
323323
return std::nullopt;
324-
auto vftSym = view->GetSymbolByAddress(typeInfoAddr);
325-
if (vftSym == nullptr)
326-
return std::nullopt;
327-
baseSym = vftSym;
324+
auto typeInfoSym = view->GetSymbolByAddress(typeInfoAddr);
325+
if (typeInfoSym == nullptr)
326+
{
327+
// For stripped binaries there will be no symbol, contruct a type info object and check.
328+
auto rootTypeInfo = GetTypeInfo(view, typeInfoAddr);
329+
if (!rootTypeInfo.has_value())
330+
return std::nullopt;
331+
if (rootTypeInfo->type_name.find("__cxxabiv1") == std::string::npos)
332+
return std::nullopt;
333+
typeInfoSym = new Symbol(DataSymbol, fmt::format("_typeinfo_for_{}", rootTypeInfo->type_name), typeInfoAddr);
334+
}
335+
baseSym = typeInfoSym;
328336
}
329337

330338
auto baseSymName = baseSym->GetShortName();

plugins/rtti/rtti.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ std::string RemoveItaniumPrefix(std::string &name)
3939
{
4040
// Remove numerical prefixes.
4141
// TODO: We might want to use the numbers for figuring out the class info.
42+
// TODO: NSt6locale5facetE is not demangled. N and St seem to be prefixes.
4243
while (!name.empty() && std::isdigit(name[0]))
4344
name = name.substr(1);
4445
return name;

0 commit comments

Comments
 (0)