summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCache.cpp
diff options
context:
space:
mode:
authorWeiN76LQh <WeiN76LQh@github.com>2024-11-26 16:06:30 +0000
committerkat <kat@vector35.com>2025-02-10 10:33:20 -0500
commite90a08f5a6237472a3d0caf77e11dfcc987f1169 (patch)
tree3525a0359b60e7a15f356f2bc2475521596eb8dc /view/sharedcache/core/SharedCache.cpp
parent8953660bbbd0fc8f15be004f3302886f34f620df (diff)
[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.
Diffstat (limited to 'view/sharedcache/core/SharedCache.cpp')
-rw-r--r--view/sharedcache/core/SharedCache.cpp13
1 files changed, 10 insertions, 3 deletions
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<Ref<Symbol>> SharedCache::ParseExportTrie(std::shared_ptr<MMappedFil
}
-std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> SharedCache::GetExportListForHeader(SharedCacheMachOHeader header, std::function<std::shared_ptr<MMappedFileAccessor>()> provideLinkeditFile)
+std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> SharedCache::GetExportListForHeader(SharedCacheMachOHeader header, std::function<std::shared_ptr<MMappedFileAccessor>()> 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<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> SharedCac
// TODO does this have to be a functor? can't we just pass the accessor? if not, why?
std::shared_ptr<MMappedFileAccessor> linkeditFile = provideLinkeditFile();
if (!linkeditFile)
+ {
+ if (didModifyExportList)
+ *didModifyExportList = false;
return std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>>();
+ }
auto exportList = SharedCache::ParseExportTrie(linkeditFile, header);
std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> exportMapping(exportList.size());
@@ -2828,6 +2834,8 @@ std::vector<std::pair<uint64_t, std::pair<BNSymbolType, std::string>>> 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<std::pair<std::string, Ref<Symbol>>> 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<std::pair<std::string, Ref<Symbol>>> 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<MMappedFileAccessor>(nullptr);
}
- });
+ }, &doSave);
for (const auto& sym : exportList)
{
symbols.push_back({img.installName, new Symbol(sym.second.first, sym.second.second, sym.first)});