Skip to content

Commit 7794bcf

Browse files
committed
Handle relocated itanium ABI base vtables
1 parent 9ff2b8d commit 7794bcf

File tree

1 file changed

+8
-21
lines changed

1 file changed

+8
-21
lines changed

plugins/rtti/itanium.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,17 @@ std::optional<TypeInfoVariant> ReadTypeInfoVariant(BinaryView *view, uint64_t ob
208208
// If there is a symbol at objectAddr pointing to a symbol starting with "vtable for __cxxabiv1"
209209
auto baseSym = view->GetSymbolByAddress(typeInfo.base);
210210
if (baseSym == nullptr)
211-
return std::nullopt;
211+
{
212+
// Check relocation at objectAddr for symbol
213+
for (const auto& r : view->GetRelocationsAt(objectAddr))
214+
if (auto relocSym = r->GetSymbol())
215+
baseSym = relocSym;
216+
if (baseSym == nullptr)
217+
return std::nullopt;
218+
}
212219
if (baseSym->GetType() != ExternalSymbol)
213220
return std::nullopt;
214221
auto baseSymName = baseSym->GetShortName();
215-
216-
// TODO: __vmi_class_type_info seems to point to operator delete(void*)
217-
// TODO: For now we just bruteforce it with the type_name check...
218-
219222
if (baseSymName.find("__cxxabiv1") != std::string::npos)
220223
{
221224
// symbol takes the form of `abi::base_name`
@@ -230,22 +233,6 @@ std::optional<TypeInfoVariant> ReadTypeInfoVariant(BinaryView *view, uint64_t ob
230233
if (baseSymName == "__vmi_class_type_info")
231234
return TIVVMIClass;
232235
}
233-
else if (typeInfo.type_name.length() > 2)
234-
{
235-
// TODO: This is so ugly
236-
switch (typeInfo.type_name.at(0))
237-
{
238-
case '7':
239-
return TIVClass;
240-
case '9':
241-
return TIVSIClass;
242-
case '1':
243-
if (typeInfo.type_name.at(1) == '4')
244-
return TIVVMIClass;
245-
default:
246-
return std::nullopt;
247-
}
248-
}
249236

250237
return std::nullopt;
251238
}

0 commit comments

Comments
 (0)