summaryrefslogtreecommitdiff
path: root/view/sharedcache
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-02 05:36:15 -0400
committerMason Reed <mason@vector35.com>2025-04-02 05:36:54 -0400
commitb1445a8de262dfce57784d14547497f6b3ce0463 (patch)
treed2239de494a97105ad44dc12116df28335a490c9 /view/sharedcache
parent888579fcac2d8bc809dc9600ccc916b25a065eab (diff)
[SharedCache] Fix not adding type libraries in the macho processor
Diffstat (limited to 'view/sharedcache')
-rw-r--r--view/sharedcache/core/MachOProcessor.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/view/sharedcache/core/MachOProcessor.cpp b/view/sharedcache/core/MachOProcessor.cpp
index 5ef14abd..565e6d06 100644
--- a/view/sharedcache/core/MachOProcessor.cpp
+++ b/view/sharedcache/core/MachOProcessor.cpp
@@ -19,6 +19,17 @@ SharedCacheMachOProcessor::SharedCacheMachOProcessor(Ref<BinaryView> view, std::
void SharedCacheMachOProcessor::ApplyHeader(SharedCacheMachOHeader& header)
{
+ auto typeLibraryFromName = [&](const std::string& name) -> Ref<TypeLibrary> {
+ // Check to see if we have already loaded the type library.
+ if (auto typeLib = m_view->GetTypeLibrary(name))
+ return typeLib;
+
+ auto typeLibs = m_view->GetDefaultPlatform()->GetTypeLibrariesByName(name);
+ if (!typeLibs.empty())
+ return typeLibs.front();
+ return nullptr;
+ };
+
// Add a section for the header itself.
std::string headerSection = fmt::format("{}::__macho_header", header.identifierPrefix);
// TODO: Support mach_header (non 64bit)
@@ -38,7 +49,8 @@ void SharedCacheMachOProcessor::ApplyHeader(SharedCacheMachOHeader& header)
m_view->AddFunctionForAnalysis(targetPlatform, func, false);
}
- auto typeLib = m_view->GetTypeLibrary(header.installName);
+ // Pull the available type library for the image we are loading, so we can apply known types.
+ auto typeLib = typeLibraryFromName(header.installName);
m_view->BeginBulkModifySymbols();
// TODO: Why does this need to only happen in linkeditSegment?