Skip to content

Conversation

@p-x9
Copy link
Owner

@p-x9 p-x9 commented Jun 7, 2025

When a super class, category class, or compliant protocol is read from a mach-o in the Dyld cache,
it may refer to something defined in a different mach-O file than the mach-o that contains itself.

@p-x9 p-x9 requested a review from Copilot June 7, 2025 08:48
Copy link
Contributor

Copilot AI left a comment

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 updates multiple ObjC runtime parsing components to return not just class or protocol information but also the Mach‐O file (or image) that defines them, ensuring that references to super, meta, or category classes use the correct Mach‐O context. Key changes include:

  • Modifying protocol and class lookup methods to return tuples that pair the found entity with its defining Mach‐O.
  • Updating filtering and offset logic to use the appropriate Mach‐O pointers.
  • Adjusting dependency versions and adding helper extensions for Mach‐O determination.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Sources/MachOObjCSection/Support/ObjCDump.swift Updates protocol mapping closures and filtering logic to use the Mach‐O pointer for identity checks.
Sources/MachOObjCSection/Protocol/Protocol/ObjCProtocolListProtocol.swift Changes return types of protocols functions to return tuples with their Mach‐O context and adjusts helper logic accordingly.
Sources/MachOObjCSection/Protocol/Class/ObjCClassProtocol.swift Revises metaClass and superClass functions to return Mach‐O paired results and deprecates older implementations.
Sources/MachOObjCSection/Protocol/Category/ObjCCategoryProtocol.swift Updates class and stubClass lookup methods to include Mach‐O context in the returned tuple.
Sources/MachOObjCSection/Model/Protocol/ObjCProtocolList64.swift & ObjCProtocolList32.swift Adjusts protocol lookup methods to return tuples with Mach‐O context and update file offset handling.
Sources/MachOObjCSection/Extension/DyldCacheLoaded+.swift & DyldCache+.swift Adds helper methods to locate the correct Mach‐O from raw pointers or unslid addresses.
Package.swift Upgrades MachOKit dependency from version 0.30.0 to 0.34.0.
Comments suppressed due to low confidence (3)

Sources/MachOObjCSection/Protocol/Protocol/ObjCProtocolListProtocol.swift:56

  • The variable 'sequnece' appears to be misspelled. Consider renaming it to 'sequence' for clarity.
let sequnece = MemorySequence(

Sources/MachOObjCSection/Support/ObjCDump.swift:327

  • [nitpick] Please add a brief comment explaining the rationale for using the 'ptr' for filtering instead of the machO path to improve future code maintainability.
.filter({ $0.0.ptr == machO.ptr })

Sources/MachOObjCSection/Protocol/Class/ObjCClassProtocol.swift:182

  • [nitpick] Consider adding a comment to explain why the offset is adjusted by the difference between targetMachO.ptr and machO.ptr in the deprecated metaClass(in:) method.
let diff = Int(bitPattern: targetMachO.ptr) - Int(bitPattern: machO.ptr)

@p-x9 p-x9 merged commit 8dceebf into main Jun 7, 2025
2 checks passed
@p-x9 p-x9 deleted the feature/improve-read-class-protocol branch June 7, 2025 10:27
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