Skip to content

Add support for host callback to get information for platform-native composite R2R images - #121363

Merged
elinor-fung merged 12 commits into
dotnet:mainfrom
elinor-fung:r2r-host-runtime-callback
Nov 11, 2025
Merged

Add support for host callback to get information for platform-native composite R2R images#121363
elinor-fung merged 12 commits into
dotnet:mainfrom
elinor-fung:r2r-host-runtime-callback

Conversation

@elinor-fung

Copy link
Copy Markdown
Member

Depends on #120777. (First commit is a merge from that PR)

Add the basic runtime flow for calling into the host to get information about a platform-native R2R - see ReadyToRun Platform Native Envelope.

  • Add get_native_code_data callback to host_runtime_contract
  • If a component R2R assembly has READYTORUN_FLAG_PLATFORM_NATIVE_IMAGE, invoke the callback to get the R2R header, image size, and image base address
  • Currently only implemented and tested on Windows (with local changes to include the flag)
  • Mach-O support will need Add support for emitting Mach-O R2R images #121186

Contributes to #120065.

Comment threadsrc/coreclr/vm/nativeimage.cpp
@jkoritzinsky

Copy link
Copy Markdown
Member

cc: @adamperlin

@elinor-fung
elinor-fung marked this pull request as ready for review November 6, 2025 21:32
CopilotAI review requested due to automatic review settings November 6, 2025 21:32
@elinor-fung

Copy link
Copy Markdown
MemberAuthor

This should be ready for review now.

CopilotAI 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 adds support for platform-native R2R (ReadyToRun) composite image loading, enabling the runtime to load composite R2R images in native platform formats (e.g., Mach-O on macOS, PE on Windows) through a new host contract callback mechanism.

Key changes:

  • New host contract callback get_native_code_data to retrieve platform-native composite images from the host
  • New READYTORUN_FLAG_PLATFORM_NATIVE_IMAGE flag to mark component assemblies
  • Test infrastructure to validate platform-native R2R composite image loading

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
src/native/corehost/host_runtime_contract.hAdds new structs and callback interface for native code data retrieval
src/installer/tests/Assets/Projects/HostApiInvokerApp/HostRuntimeContract.csUpdates managed representation of host contract with new callback
src/coreclr/inc/readytorun.hDefines new READYTORUN_FLAG_PLATFORM_NATIVE_IMAGE flag
src/coreclr/inc/hostinformation.hDeclares GetNativeCodeData helper method
src/coreclr/vm/hostinformation.cppImplements GetNativeCodeData to call host callback
src/coreclr/vm/readytoruninfo.cppPasses platform-native flag when loading composite images
src/coreclr/vm/assemblybinder.hAdds isPlatformNative parameter to LoadNativeImage
src/coreclr/vm/assemblybinder.cppSimplifies LoadNativeImage and passes isPlatformNative flag
src/coreclr/vm/nativeimage.hUpdates Open signature with componentModulePath and isPlatformNative
src/coreclr/vm/nativeimage.cppRefactors to support both host callback and PE-based loading paths
src/coreclr/hosts/corerun/corerun.hppAdds platform-specific helpers for UTF-8 conversion and image introspection
src/coreclr/hosts/corerun/corerun.cppImplements get_native_code_data callback for testing
src/tests/Loader/PlatformNativeR2R/PlatformNativeR2R.csprojTest project configuration
src/tests/Loader/PlatformNativeR2R/PlatformNativeR2R.csTest implementation using R2RDump validation

Comment threadsrc/tests/Loader/PlatformNativeR2R/PlatformNativeR2R.csproj
Comment threadsrc/tests/Loader/PlatformNativeR2R/PlatformNativeR2R.cs Outdated
Comment threadsrc/native/corehost/host_runtime_contract.h Outdated
Comment threadsrc/coreclr/vm/nativeimage.cpp Outdated
Comment threadsrc/coreclr/hosts/corerun/corerun.hpp Outdated
elinor-fungand others added 2 commits November 6, 2025 22:08
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment threadsrc/coreclr/hosts/corerun/corerun.hpp Outdated
Comment threadsrc/coreclr/hosts/corerun/corerun.hpp Outdated
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
@elinor-fung

Copy link
Copy Markdown
MemberAuthor

/ba-g Android timeouts

@elinor-fung
elinor-fung merged commit ad65508 into dotnet:mainNov 11, 2025
140 of 164 checks passed
@elinor-fung
elinor-fung deleted the r2r-host-runtime-callback branch November 11, 2025 18:46
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Dec 12, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@elinor-fung@jkoritzinsky@am11