summaryrefslogtreecommitdiff
path: root/view/sharedcache/core/SharedCache.cpp
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-13 00:47:36 -0400
committerMason Reed <mason@vector35.com>2025-04-14 03:20:51 -0400
commitea47d4c85e78533ea7e88adc442159414feb3f7f (patch)
tree801cd657bf7872d02cb783f8ee0f25b3f5ecad1c /view/sharedcache/core/SharedCache.cpp
parent83dc0ef0eea5face59d8a58251f78f32f3e6c914 (diff)
[SharedCache] Apply .symbols file information when applying an image
This improves symbol recovery drastically on newer shared caches Related PR: https://github.com/Vector35/binaryninja-api/pull/6210
Diffstat (limited to 'view/sharedcache/core/SharedCache.cpp')
-rw-r--r--view/sharedcache/core/SharedCache.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/view/sharedcache/core/SharedCache.cpp b/view/sharedcache/core/SharedCache.cpp
index 717ec6aa..dced1660 100644
--- a/view/sharedcache/core/SharedCache.cpp
+++ b/view/sharedcache/core/SharedCache.cpp
@@ -80,10 +80,14 @@ std::optional<CacheEntry> CacheEntry::FromFile(const std::string& filePath, cons
// We found a single dyld data cache entry file. Mark it as such!
type = CacheEntryType::DyldData;
}
- else if (fileName.find(".symbols") != std::string::npos)
+ else if (fileName.find(".symbols") != std::string::npos && mappings.size() == 1)
{
// We found a single symbols cache entry file. Mark it as such!
type = CacheEntryType::Symbols;
+ // Adjust the mapping for the symbol file, they seem to be only for the header.
+ // If we do not adjust the mapping than we will not be able to read the symbol table through the virtual memory.
+ mappings[0].fileOffset = 0;
+ mappings[0].size = file->Length();
}
else if (mappings.size() == 1 && header.imagesCountOld == 0 && header.imagesCount == 0
&& header.imagesTextOffset == 0)
@@ -154,8 +158,7 @@ std::optional<uint64_t> CacheEntry::GetMappedAddress(uint64_t fileOffset) const
SharedCache::SharedCache(uint64_t addressSize)
{
- m_addressSize = addressSize;
- m_vm = std::make_shared<VirtualMemory>();
+ m_vm = std::make_shared<VirtualMemory>(addressSize);
m_namedSymMutex = std::make_unique<std::shared_mutex>();
}
@@ -321,7 +324,7 @@ void SharedCache::ProcessEntryRegions(const CacheEntry& entry)
// Collect pool addresses as non image memory regions.
for (size_t i = 0; i < entryHeader.branchPoolsCount; i++)
{
- auto branchPoolAddr = entryHeader.branchPoolsOffset + (i * m_addressSize);
+ auto branchPoolAddr = entryHeader.branchPoolsOffset + (i * m_vm->GetAddressSize());
auto header = SharedCacheMachOHeader::ParseHeaderForAddress(
m_vm, branchPoolAddr, "dyld_shared_cache_branch_islands_" + std::to_string(i));
// Stop processing branch pools if a header fails to parse.