From b1445a8de262dfce57784d14547497f6b3ce0463 Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Wed, 2 Apr 2025 05:36:15 -0400 Subject: [SharedCache] Fix not adding type libraries in the macho processor --- view/sharedcache/core/MachOProcessor.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'view/sharedcache/core/MachOProcessor.cpp') 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 view, std:: void SharedCacheMachOProcessor::ApplyHeader(SharedCacheMachOHeader& header) { + auto typeLibraryFromName = [&](const std::string& name) -> Ref { + // 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? -- cgit v1.3.1