Skip to content

Commit 8ade516

Browse files
committed
temp shit
1 parent c662526 commit 8ade516

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

plugins/rtti/itanium.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ void ItaniumRTTIProcessor::ProcessRTTI()
477477

478478
void ItaniumRTTIProcessor::ProcessVFT()
479479
{
480-
std::map<uint64_t, uint64_t> vftMap = {};
480+
// TODO: vftMap needs to be an array i guess?
481+
// TODO: What ddoes msvc do?
482+
std::map<uint64_t, std::set<uint64_t>> vftMap = {};
481483
std::map<uint64_t, std::optional<VirtualFunctionTableInfo>> vftFinishedMap = {};
482484
auto start_time = std::chrono::high_resolution_clock::now();
483485
for (auto &[coLocatorAddr, classInfo]: m_classInfo)
@@ -490,7 +492,9 @@ void ItaniumRTTIProcessor::ProcessVFT()
490492
continue;
491493
// TODO: This is not pointing at where it should, remember that the vtable will be inside another structure.
492494
auto vftAddr = ref + m_view->GetAddressSize();
493-
vftMap[coLocatorAddr] = vftAddr;
495+
// Found a vtable reference to colocator
496+
// TODO: Access check here.
497+
vftMap[coLocatorAddr].insert(vftAddr);
494498
}
495499
}
496500

@@ -541,16 +545,22 @@ void ItaniumRTTIProcessor::ProcessVFT()
541545
return vftInfo;
542546
};
543547

544-
for (const auto &[coLocatorAddr, vftAddr]: vftMap)
545-
{
548+
auto populateVftMap = [&](uint64_t coLocatorAddr, uint64_t vftAddr) {
546549
auto classInfo = m_classInfo.find(coLocatorAddr)->second;
547550
if (classInfo.baseClassName.has_value())
548551
{
549552
// Process base vtable and add it to the class info.
550-
for (auto [baseCoLocAddr, baseClassInfo] : m_classInfo)
553+
for (auto& [baseCoLocAddr, baseClassInfo] : m_classInfo)
551554
{
552555
if (baseClassInfo.className == classInfo.baseClassName.value())
553556
{
557+
// TODO: This is so fucked up
558+
// TODO: Itanium does not have this structure that msvc has
559+
// TODO: The multi inheritence is flatteed at the colocator level
560+
// TODO: To have this work we need to either 1: do a single pass on the
561+
// TODO: virtual table
562+
// TODO: Or 2: have some way of locating the correct vft from the colocator
563+
// TODO: Which WILL have multiple xrefs, how do we find the correct one?
554564
uint64_t baseVftAddr = vftMap[baseCoLocAddr];
555565
if (auto baseVftInfo = GetCachedVFTInfo(baseVftAddr, baseClassInfo))
556566
{
@@ -565,6 +575,14 @@ void ItaniumRTTIProcessor::ProcessVFT()
565575
classInfo.vft = vftInfo.value();
566576

567577
m_classInfo[coLocatorAddr] = classInfo;
578+
};
579+
580+
for (const auto &[coLocatorAddr, vftAddrs]: vftMap)
581+
{
582+
for (const auto& vftAddr: vftAddrs)
583+
{
584+
populateVftMap(coLocatorAddr, vftAddr);
585+
}
568586
}
569587

570588
auto end_time = std::chrono::high_resolution_clock::now();

0 commit comments

Comments
 (0)