Skip to content

Reuse cached full dyld cache for lookups - #33

Merged
p-x9 merged 1 commit into
mainfrom
feature/reuse-full-dyld-cache
Jul 24, 2026
Merged

Reuse cached full dyld cache for lookups#33
p-x9 merged 1 commit into
mainfrom
feature/reuse-full-dyld-cache

Conversation

@p-x9

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

Copy link
Copy Markdown
Owner

Summary

  • route DyldCache.locateValue through an already-associated FullDyldCache
  • add FullDyldCache.locateValue helpers that search the main cache and its subcaches
  • exclude the cache already checked by the caller so each cache is resolved at most once
  • reuse cached full-cache address lookup APIs from MachOFile

Why

Lookup paths previously traversed or reopened individual dyld cache files even when a complete FullDyldCache was already available. This change reuses the associated full-cache view, keeps main/subcache lookup behavior consistent, and avoids evaluating the same subcache twice during delegated resolution.

Impact

Mach-O Objective-C metadata and address resolution can reuse existing full-cache state instead of reconstructing cache access paths, while preserving fallback behavior for standalone DyldCache instances.

Validation

  • swift build
  • swift test --filter MachOObjCSectionTests.testCategories2InCacheFile
  • verified main-cache-first lookup and single-visit behavior with focused regression checks during development

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

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 optimizes dyld cache lookups by reusing an already-associated FullDyldCache when available, avoiding redundant cache traversals/reopens while keeping main-cache-first behavior consistent across main/subcaches.

Changes:

  • Routes MachOFile dyld-cache address resolution through cache._cachedFullCache when present.
  • Adds FullDyldCache.locateValue helpers to resolve values across main cache + subcaches with optional exclusion.
  • Updates DyldCache.locateValue to delegate to the cached FullDyldCache (excluding the already-checked cache) when available.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Sources/MachOObjCSection/Extension/MachOFile+.swift Reuses cached full-cache state for address→cache/fileOffset lookups and Objective-C selector base offset resolution.
Sources/MachOObjCSection/Extension/FullDyldCache+.swift Introduces hierarchy-wide locateValue helpers with exclusion support.
Sources/MachOObjCSection/Extension/DyldCache+.swift Delegates locateValue to an associated FullDyldCache to avoid re-checking caches.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Sources/MachOObjCSection/Extension/MachOFile+.swift
Comment thread Sources/MachOObjCSection/Extension/FullDyldCache+.swift
@p-x9
p-x9 merged commit 9921196 into main Jul 24, 2026
3 checks passed
@p-x9
p-x9 deleted the feature/reuse-full-dyld-cache branch July 24, 2026 14:35
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