Repository navigation
Refactor MachObjectFile signature blobs - #116566
Merged
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @vitek-karas, @agocke |
- Use classes instead of structs for blobs - Create IBlob interface for blob writing - Remove MachObjectFile.CodeSignature - Create IMachFileAccess to abstract reading and writing to disk
jtschuster
force-pushed
the
MachOSignatureRefactor
branch
from
June 12, 2025 16:08
095fc30 to
df505ca
Compare
jtschuster
marked this pull request as ready for review
June 12, 2025 18:12
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the handling of Mach-O signature blobs by replacing structs with classes and introducing a common IBlob interface, while also consolidating and removing redundant code files. Key changes include:
- Converting blob representations to classes with read/write methods.
- Introducing the IBlob interface and reorganizing blob types.
- Abstracting file access via the new IMachOFileAccess interface.
Reviewed Changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| FileUtils/EndianConversionExtensions.cs | Adds ulong conversion method for consistency. |
| Enums/HashType.cs | Adds HashTypeExtensions for creating hash algorithms and obtaining hash sizes. |
| Enums/CodeDirectorySpecialSlot.cs | Updates comment with a reference link. |
| Enums/BlobMagic.cs | Adjusts ordering of enum members without altering underlying values. |
| BinaryFormat/SymbolTableLoadCommand.cs | Renames the struct for clarity and adjusts default check accordingly. |
| BinaryFormat/LinkEditLoadCommand.cs | Renames the struct and updates the constructor and default check. |
| BinaryFormat/Blobs/SuperBlob.cs | Introduces SuperBlob for managing composite blobs and validates blob offsets. |
| BinaryFormat/Blobs/SimpleBlob.cs | Implements a simple blob type for binary read/write operations. |
| BinaryFormat/Blobs/RequirementsBlob.cs | Wraps a SuperBlob to represent an empty Requirements blob. |
| BinaryFormat/Blobs/EmbeddedSignatureBlob.cs | Implements an EmbeddedSignature blob that aggregates sub-blobs. |
| BinaryFormat/Blobs/CodeDirectoryBlob.cs | Implements a CodeDirectoryBlob with header parsing and blob writing logic. |
| BinaryFormat/Blobs/CmsWrapperBlob.cs | Implements a CmsWrapperBlob using a SimpleBlob as inner storage. |
| BinaryFormat/Blobs/BlobParser.cs | Provides logic to parse a blob based on its magic number. |
| BinaryFormat/Blobs/BlobIndex.cs | Adds a constant for blob index size. |
| AppHost/HostWriter.cs | Updates Mach-O file access to use the new IMachOFileAccess interface. |
…ate identical objects
Member
Author
|
I'm going to go ahead and merge. @elinor-fung I'll apply any review feedback to the follow up PR. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Decided to split up #115800 into a refactor PR with no behavioral changes and a separate PR with the behavior changes. Unfortunately this still ended up being pretty large, but much of the diff is moving code or forwarding method calls in a wrapper.
This PR makes the following changes