Skip to content

Use located cache for Objective-C header info lookup - #31

Merged
p-x9 merged 2 commits into
mainfrom
feature/objc-header-info-cache
Jul 17, 2026
Merged

Use located cache for Objective-C header info lookup#31
p-x9 merged 2 commits into
mainfrom
feature/objc-header-info-cache

Conversation

@p-x9

@p-x9 p-x9 commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • read Objective-C header info entries from the cache containing the header optimization table
  • avoid a second cache hierarchy traversal after locating that table
  • reuse DyldCacheLoaded.machO(at:) for 32-bit protocol relative-list resolution

Rationale

objc4 defines header_info entries as the trailing array of objc_headeropt_ro_t, while dyld resolves the table start from headerInfoROCacheOffset. 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 test
  • swift test --filter MachOObjCSectionTests/testImageInfoInImage
  • git diff --check

@p-x9
p-x9 marked this pull request as ready for review July 17, 2026 17:15
@p-x9
p-x9 requested a review from Copilot July 17, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 ObjCProtocolRelativeListList32 loaded-image resolution by reusing DyldCacheLoaded.machO(at:).
  • Updates DyldCache._machO(at:) to read headerInfos from 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.

@p-x9
p-x9 merged commit 020800b into main Jul 17, 2026
3 checks passed
@p-x9
p-x9 deleted the feature/objc-header-info-cache branch July 17, 2026 17:20
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.

2 participants