Use located cache for Objective-C header info lookup - #31
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Objective-C header-info lookup to reuse the dyld-cache helper that already resolves Mach-O images by image index, and updates cache-backed header optimization table lookups to read header-info entries from the same located cache (avoiding redundant hierarchy traversal).
Changes:
- Simplifies
ObjCProtocolRelativeListList32loaded-image resolution by reusingDyldCacheLoaded.machO(at:). - Updates
DyldCache._machO(at:)to readheaderInfosfrom the cache that actually contained the located header optimization RO table (both 64-bit and 32-bit paths).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Sources/MachOObjCSection/Model/Protocol/ObjCProtocolRelativeListList.swift | Switches 32-bit protocol relative-list resolution to use the shared dyld-cache Mach-O lookup helper. |
| Sources/MachOObjCSection/Extension/DyldCache+.swift | Ensures header-info arrays are read from the located cache containing the RO table, reducing redundant hierarchy traversal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DyldCacheLoaded.machO(at:)for 32-bit protocol relative-list resolutionRationale
objc4 defines
header_infoentries as the trailing array ofobjc_headeropt_ro_t, while dyld resolves the table start fromheaderInfoROCacheOffset. Once the cache containing the RO table is known, its entries should be read from that same cache instead of searching the hierarchy again.The loaded-image protocol path also duplicated the same RO-to-Mach-O lookup and hard-coded the 64-bit RO table. Reusing the existing helper keeps the 32-bit and 64-bit paths consistent.
Validation
swift testswift test --filter MachOObjCSectionTests/testImageInfoInImagegit diff --check