Skip to content

Conversation

@jkoritzinsky
Copy link
Member

Depends on #120758

Will make it much easier to implement support for a Mach-O envelope of R2R data.

Contributes to #120065

…determining if a given instruction is in an address range.
…from a R2R image without requiring the PE format
@jkoritzinsky jkoritzinsky force-pushed the r2r-native-layout-non-pe branch from 7d54255 to f654ce0 Compare October 16, 2025 16:54
@jkoritzinsky jkoritzinsky marked this pull request as ready for review October 16, 2025 16:54
Copilot AI review requested due to automatic review settings October 16, 2025 16:54
@jkoritzinsky jkoritzinsky removed the blocked Issue/PR is blocked on something - see comments label Oct 16, 2025
@jkoritzinsky jkoritzinsky requested review from a team and davidwrighton October 16, 2025 16:54
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 introduces a lightweight ReadyToRunLoadedImage abstraction to decouple ReadyToRun (R2R) processing from PEImageLayout, easing future support for non-PE (e.g. Mach-O) envelopes.

  • Replaces usages of PEImageLayout/PEDecoder for R2R access with ReadyToRunLoadedImage.
  • Adds ReadyToRunLoadedImage class with basic image base/size access and cleanup semantics.
  • Updates multiple subsystems (R2R info, native image loading, PGO, fixups, DAC) to use the new abstraction.

Reviewed Changes

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

Show a summary per file
File Description
src/coreclr/vm/readytoruninfo.h Adds ReadyToRunLoadedImage class and replaces PEImageLayout pointers with the new type.
src/coreclr/vm/readytoruninfo.cpp Constructs ReadyToRunLoadedImage during ReadyToRunInfo initialization.
src/coreclr/vm/prestub.cpp Switches fixup helpers to use ReadyToRunLoadedImage.
src/coreclr/vm/pgo.h Updates PGO interfaces to use ReadyToRunLoadedImage.
src/coreclr/vm/pgo.cpp Adapts instrumentation reader to new image type.
src/coreclr/vm/nativeimage.h Replaces PEImageLayout member with ReadyToRunLoadedImage.
src/coreclr/vm/nativeimage.cpp Wraps PEImageLayout in ReadyToRunLoadedImage with cleanup lambda.
src/coreclr/vm/frames.cpp Uses ReadyToRunLoadedImage for GC ref map lookup.
src/coreclr/vm/codeman.cpp Updates EH enumeration to use new image abstraction.
src/coreclr/vm/ceeload.inl Template fixup function now takes ReadyToRunLoadedImage.
src/coreclr/vm/ceeload.h Module accessors updated to return ReadyToRunLoadedImage.
src/coreclr/vm/ceeload.cpp Module methods updated to use ReadyToRunLoadedImage.
src/coreclr/debug/daccess/request.cpp DAC tiered version query updated to use ReadyToRunLoadedImage and GetVirtualSize.

@hoyosjs hoyosjs requested review from a team and removed request for a team October 31, 2025 03:22
@noahfalk
Copy link
Member

Is the plan to nest a complete PE image inside the MachO envelope or the PE part might go away at some point? Not that it should block this PR at all, but just wanted to give a heads up that its very likely there are lurking assumptions about the PE file format in the debugging stack. For example we have:
https://learn.microsoft.com/en-us/dotnet/core/unmanaged-api/debugging/icordebug/icordebugmodule-getbaseaddress-method
https://learn.microsoft.com/en-us/dotnet/core/unmanaged-api/debugging/icordebug/icordebugmodule4-ismappedlayout-method

If we get to the point where that base address doesn't point to PE format then debugger changes will be needed.

Copy link
Member

@noahfalk noahfalk left a comment

Choose a reason for hiding this comment

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

This seems fine to me from the diagnostics angle. In the future if we get to the point that PE headers go away or the GetBaseAddress API isn't pointing to it then we've got some debugger impact to work through.

@jkoritzinsky
Copy link
Member Author

The plan is to not have a fake PE header in the MachO format and only have the R2R data structures.

Given that GetBaseAddress returns 0 for native images, I would expect the MachO files to go down the same route for the debugger APIs.

@jkoritzinsky
Copy link
Member Author

/ba-g Android timeout

@jkoritzinsky jkoritzinsky enabled auto-merge (squash) November 5, 2025 21:30
@jkoritzinsky jkoritzinsky merged commit e1136d1 into dotnet:main Nov 5, 2025
87 of 99 checks passed
@jkoritzinsky jkoritzinsky deleted the r2r-native-layout-non-pe branch November 5, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants