Skip to content

Consider storing R2R images in a separate file #10802

Description

@jonathanpeppers

Android framework version

net11.0-android (Preview)

Affected platform version

.NET 11

Description

Context:

When we added ReadyToRun support for Android (CoreCLR), R2R images remain inside .dll files. There was a step where this data was copied to memory and loaded, which may not be optimal.

For CoreCLR (R2R) support on iOS, there was "Platform-Native R2R Envelope" related work — tracked by issue dotnet/runtime#120065. On iOS, PE-based R2R can't work due to page protection restrictions (no JIT entitlement), so R2R native code is emitted into a separate Mach-O (.dylib) file that the OS can load natively.

Key PRs:

PRTitleAuthorDate
#120584Add initial doc for R2R platform-native image (Mach-O, composite only)elinor-fungOct 2025
#120777Extract out minimal concerns from PEImageLayout for R2R imagesjkoritzinskyNov 2025
#121186Add support for emitting Mach-O R2R imagesjkoritzinskyNov 2025
#121363Add support for host callback to get information for platform-native composite R2R imageselinor-fungNov 2025
#122511Reduce the number of sections in R2R PE filesjkoritzinskyJan 2026

The integration on the macios side was dotnet/macios#24327, which got a MAUI iOS app running with R2R.

The design doc (readytorun-platform-native-envelope.md) lays out the approach: crossgen2 emits the composite R2R image as a native Mach-O .dylib, and a new get_native_code_data host callback tells the runtime where to find it. This lets the OS dlopen the native code directly rather than needing to copy/map PE data.

Question

Is there anything we can use from this work to improve Android?

Steps to Reproduce

  1. dotnet new android
  2. dotnet build -c Release uses ReadyToRun by default

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions