Skip to content

Conversation

@bdash
Copy link
Contributor

@bdash bdash commented Sep 14, 2025

This does the following:

  • Adds support for relative direct selectors in older shared cache versions.

    Prior to macOS 13 / iOS 16, the base offset to use for relative direct selector references within Objective-C message lists was stored within the __TEXT,__objc_opt_ro section of /usr/lib/libobjc.A.dylib.

  • Reworks 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, and SharedCacheMachOProcessor now directly accesses the local symbols cache entry rather than needing to search for it, and uses the separate VM object for reading data from it.

Fixes #7393.

{
m_localSymbolsEntry = std::move(entry);
// Map the entire file into its own virtual memory space.
// This is necessary due to code that processes symbols being written in terms of a `VirtualMemory`
Copy link
Member

@emesare emesare Sep 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the fileAccessor in place of the m_localSymbolsVM, since it is just that file mapped at zero and it does not exist inside the regular virtual memory.

Just a suggestion, nothing blocking

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the comment mentions, this uses a VirtualMemory as SharedCacheMachOHeader::ReadSymbolTable requires one. Since it is also used to process symbol tables inside images, such as in macOS shared caches, it cannot be updated to work with a FileAccessor. Some additional refactoring would be required to remove that use of VirtualMemory.

Prior to macOS 13 / iOS 16, the base offset to use for relative direct
selector references within Objective-C message lists was stored within
the `__TEXT,__objc_opt_ro` section of /usr/lib/libobjc.A.dylib.
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.
These files are present alongside iOS 26 shared caches. Explicitly
ignoring them avoids an error being logged to the console.
@bdash bdash merged commit e422737 into dev Sep 18, 2025
4 of 5 checks passed
@bdash bdash deleted the dsc-ios-15 branch September 18, 2025 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DSC] Problems when loading an iOS 15 shared cache

3 participants