Skip to content

Consider storing R2R images in a separate file #10802

@jonathanpeppers

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:

PR Title Author Date
#120584 Add initial doc for R2R platform-native image (Mach-O, composite only) elinor-fung Oct 2025
#120777 Extract out minimal concerns from PEImageLayout for R2R images jkoritzinsky Nov 2025
#121186 Add support for emitting Mach-O R2R images jkoritzinsky Nov 2025
#121363 Add support for host callback to get information for platform-native composite R2R images elinor-fung Nov 2025
#122511 Reduce the number of sections in R2R PE files jkoritzinsky Jan 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions