Uh oh!
There was an error while loading. Please reload this page.
Add R2RDump support for Mach-O composite R2R images - #121566
Conversation
TODO: - Move shared code out of HostModel, separate into shared/HostModel/R2RDump parts - Print Mach-O header info when dumping image - Handle diff for Mach-O sections
9a4abc4 to
3e51420CompareThere was a problem hiding this comment.
Pull Request Overview
This PR adds support for Mach-O composite ReadyToRun (R2R) images to the R2RDump tool and ILCompiler.Reflection.ReadyToRun library. The implementation introduces an abstraction layer for binary image reading to handle both PE and Mach-O formats uniformly.
Key Changes:
- Introduced
IBinaryImageReaderinterface to abstract binary image reading across PE and Mach-O formats - Implemented
PEImageReaderandMachOImageReaderas format-specific readers - Moved common Mach-O types from
Microsoft.NET.HostModelto shared locationsrc/coreclr/tools/Common/MachOwith conditional compilation for namespace selection
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
IBinaryImageReader.cs | New interface abstracting binary image operations across formats |
PEImageReader.cs | PE-specific implementation wrapping PEReader |
MachOImageReader.cs | New Mach-O image reader with symbol table parsing and segment resolution |
ReadyToRunReader.cs | Refactored to use IBinaryImageReader interface instead of directly using PEReader |
ManifestAssemblyMetadata.cs | Added parameterless constructor for Mach-O support where PEReader is unavailable |
ReadyToRunMethod.cs | Added debug assertion for PE-specific operations |
R2RDiff.cs | Updated to use abstracted GetSections method |
NList64.cs | New Mach-O symbol table entry structure |
NameBuffer.cs | Added GetString method for reading segment/section names |
Segment64LoadCommand.cs | Added GetVMAddress accessor |
Section64LoadCommand.cs | Added SectionName, GetVMAddress, and GetSize accessors |
MachHeader.cs | Added CpuType accessor |
MachObjectFile.cs | Moved IsMachOImage method to shared location with conditional namespaces |
| Common MachO enums/types | Added conditional compilation for dual namespace support |
| Project files | Updated to include shared MachO sources |
Comments suppressed due to low confidence (1)
src/coreclr/tools/Common/MachO/BinaryFormat/NameBuffer.cs:57
- The
GetString()method may not respect byte order. When the struct is created,_nameLowerand_nameUppermay be swapped based on endianness (lines 29-38), butGetString()always reads bytes starting from_nameLower. On big-endian systems, the bytes should be read starting from_nameUpperinstead. Consider adjusting the implementation to account for endianness similar to how the constructor does.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
davidwrighton
commented
Nov 13, 2025
@adamperlin You should be aware of this effort. |
Uh oh!
There was an error while loading. Please reload this page.
Update
R2RDump/ILCompiler.Reflection.ReadyToRunto handle Mach-O composite R2R imagesReadyToRunReadystop operating onPEReaderdirectlyIBinaryImageReaderinterface to handle reading of different R2R image types - implementations for PE and MachOMicrosoft.NET.HostModelto shared locationsrc/coreclr/tools/Common