From e90a08f5a6237472a3d0caf77e11dfcc987f1169 Mon Sep 17 00:00:00 2001 From: WeiN76LQh Date: Tue, 26 Nov 2024 16:06:30 +0000 Subject: [SharedCache] Add parameter to `SharedCache::InitializeHeader` to check if `m_exportInfos` was modified This probably makes more sense than the current solution of using execution of the callback parameter to determine if `m_exportInfos` was modified. --- view/sharedcache/core/SharedCache.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'view/sharedcache/core/SharedCache.cpp') diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp index d5933039..64afeee7 100644 --- a/view/sharedcache/core/SharedCache.cpp +++ b/view/sharedcache/core/SharedCache.cpp @@ -2808,10 +2808,12 @@ std::vector> SharedCache::ParseExportTrie(std::shared_ptr>> SharedCache::GetExportListForHeader(SharedCacheMachOHeader header, std::function()> provideLinkeditFile) +std::vector>> SharedCache::GetExportListForHeader(SharedCacheMachOHeader header, std::function()> provideLinkeditFile, bool* didModifyExportList) { if (auto it = m_state->exportInfos.find(header.textBase); it != m_state->exportInfos.end()) { + if (didModifyExportList) + *didModifyExportList = false; return it->second; } else @@ -2819,7 +2821,11 @@ std::vector>> SharedCac // TODO does this have to be a functor? can't we just pass the accessor? if not, why? std::shared_ptr linkeditFile = provideLinkeditFile(); if (!linkeditFile) + { + if (didModifyExportList) + *didModifyExportList = false; return std::vector>>(); + } auto exportList = SharedCache::ParseExportTrie(linkeditFile, header); std::vector>> exportMapping(exportList.size()); @@ -2828,6 +2834,8 @@ std::vector>> SharedCac exportMapping.push_back({sym->GetAddress(), {sym->GetType(), sym->GetRawName()}}); } m_state->exportInfos[header.textBase] = exportMapping; + if (didModifyExportList) + *didModifyExportList = true; return exportMapping; } } @@ -2858,7 +2866,6 @@ std::vector>> SharedCache::LoadAllSymbolsAndW auto exportList = GetExportListForHeader(*header, [&]() { try { auto mapping = MMappedFileAccessor::Open(m_dscView, m_dscView->GetFile()->GetSessionId(), header->exportTriePath)->lock(); - doSave = true; return mapping; } catch (...) @@ -2866,7 +2873,7 @@ std::vector>> SharedCache::LoadAllSymbolsAndW m_logger->LogWarn("Serious Error: Failed to open export trie %s for %s", header->exportTriePath.c_str(), header->installName.c_str()); return std::shared_ptr(nullptr); } - }); + }, &doSave); for (const auto& sym : exportList) { symbols.push_back({img.installName, new Symbol(sym.second.first, sym.second.second, sym.first)}); -- cgit v1.3.1