Skip to content

Commit 10083ac

Browse files
committed
[SharedCache] Fix not adding type libraries in the macho processor
1 parent 306aa9a commit 10083ac

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

view/sharedcache/core/MachOProcessor.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ SharedCacheMachOProcessor::SharedCacheMachOProcessor(Ref<BinaryView> view, std::
1919

2020
void SharedCacheMachOProcessor::ApplyHeader(SharedCacheMachOHeader& header)
2121
{
22+
auto typeLibraryFromName = [&](const std::string& name) -> Ref<TypeLibrary> {
23+
// Check to see if we have already loaded the type library.
24+
if (auto typeLib = m_view->GetTypeLibrary(name))
25+
return typeLib;
26+
27+
auto typeLibs = m_view->GetDefaultPlatform()->GetTypeLibrariesByName(name);
28+
if (!typeLibs.empty())
29+
return typeLibs.front();
30+
return nullptr;
31+
};
32+
2233
// Add a section for the header itself.
2334
std::string headerSection = fmt::format("{}::__macho_header", header.identifierPrefix);
2435
// TODO: Support mach_header (non 64bit)
@@ -38,7 +49,8 @@ void SharedCacheMachOProcessor::ApplyHeader(SharedCacheMachOHeader& header)
3849
m_view->AddFunctionForAnalysis(targetPlatform, func, false);
3950
}
4051

41-
auto typeLib = m_view->GetTypeLibrary(header.installName);
52+
// Pull the available type library for the image we are loading, so we can apply known types.
53+
auto typeLib = typeLibraryFromName(header.installName);
4254
m_view->BeginBulkModifySymbols();
4355

4456
// TODO: Why does this need to only happen in linkeditSegment?

0 commit comments

Comments
 (0)