From e937b89628f3b3ce039d641fe849796cc295c41a Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Sat, 13 Sep 2025 16:17:43 -0700 Subject: [DSC] Rework handling of .symbols files to be compatible with iOS 15 In some iOS 15 caches, the .symbols file's mapping has an address of 0. This would cause it to be returned by `SharedCache::GetEntryContaining` and loaded into the view. The .symbols file contains the local symbol tables for images in the shared cache. It is not intended to be mapped into the same address space as the rest of the shared cache. `SharedCache` now tracks the symbols cache entry separately from other entries. A dedicated `VirtualMemory` region is used when accessing the data it contains. This could be a `FileAccessor`, but that would require additional changes within `SharedCacheMachOHeader`. `SharedCacheMachOProcessor` now directly accesses the local symbols cache entry rather than needing to search for it. --- view/sharedcache/core/SharedCache.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'view/sharedcache/core/SharedCache.h') diff --git a/view/sharedcache/core/SharedCache.h b/view/sharedcache/core/SharedCache.h index efef394c..58f1f38c 100644 --- a/view/sharedcache/core/SharedCache.h +++ b/view/sharedcache/core/SharedCache.h @@ -188,6 +188,11 @@ class SharedCache // NOTE: Wrapped in unique_ptr to keep SharedCache movable. std::unique_ptr m_namedSymMutex; + // Local symbols entry and its mapping, used to read symbol tables from the .symbols file. + // These are handled separately as they are not mapped into the main virtual memory of the cache. + std::optional m_localSymbolsEntry; + std::shared_ptr m_localSymbolsVM; + bool ProcessEntryImage(const std::string& path, const dyld_cache_image_info& info); // Add a region known not to overlap with another, otherwise use AddRegion. @@ -211,6 +216,9 @@ public: const std::unordered_map& GetImages() const { return m_images; } const std::unordered_map& GetSymbols() const { return m_symbols; } + const std::optional& GetLocalSymbolsEntry() const { return m_localSymbolsEntry; } + std::shared_ptr GetLocalSymbolsVM() const { return m_localSymbolsVM; } + void AddImage(CacheImage&& image); // Add a region that may overlap with another. -- cgit v1.3.1