Format:.NET ReadyToRun
| Developer | Microsoft (.NET Foundation) |
|---|---|
| Versions | header major version 26-32 in current dotnet/runtime main |
| Magic | 52 54 52 00 ("RTR") at the ManagedNativeHeader RVA |
| Extensions | .dll, .exe (also composite .r2r.dll or platform-native envelopes) |
| Endianness | little |
| License | MIT |
| On this wiki | Facts · Code · Notes · Topics |
ReadyToRun (R2R) is .NET's ahead-of-time image format: an ordinary managed PE (full IL and ECMA-335 metadata kept) plus precompiled native code located through a READYTORUN_HEADER (signature 'RTR\0') that the CLR header's ManagedNativeHeader points to. Composite images compile several assemblies into one native file.
What it is
The compiler (crossgen2) takes IL assemblies and writes a copy of the assembly (IL and metadata unchanged, per the spec 'a full copy of the input IL and MSIL metadata') with native method bodies added. The runtime uses the native code when the version rules allow and falls back to the JIT otherwise. So IL decompilers still work; native disassembly is for performance work or when IL was stripped. Basic structures are also described on Format:.NET metadata (ECMA-335)#ReadyToRun.
Identification
- CLI header Flags has
COMIMAGE_FLAGS_IL_LIBRARY(0x4) andManagedNativeHeaderpoints to the READYTORUN_HEADER; the image is always platform-specific. READYTORUN_HEADER: u32 Signature 0x00525452, u16 MajorVersion, u16 MinorVersion, thenREADYTORUN_CORE_HEADER{ u32 Flags, u32 NumberOfSections } followed by 12-byte section entries {Type, RVA, Size} sorted by Type (Fact:.NET metadata (ECMA-335)/struct/READYTORUN HEADER).- Composite images (several assemblies in one native file) are reached through the exported symbol
RTR_HEADER(name settable by crossgen2 option--rtr-header-symbol-name) and have the COMPOSITE flag; the CLI header in them only exists for PDB generation. The component assemblies then become IL-only stubs with a header whose only section is OwnerCompositeExecutable (a UTF-8 file name).
Flags (READYTORUN_CORE_HEADER.Flags)
Fact:.NET ReadyToRun/enum/ReadyToRun header flags: 0x1 PLATFORM_NEUTRAL_SOURCE, 0x2 SKIP_TYPE_VALIDATION, 0x4 PARTIAL, 0x8 NONSHARED_PINVOKE_STUBS, 0x10 EMBEDDED_MSIL, 0x20 COMPONENT, 0x40 MULTIMODULE_VERSION_BUBBLE, 0x80 UNRELATED_R2R_CODE, 0x100 PLATFORM_NATIVE_IMAGE, 0x200 STRIPPED_IL_BODIES, 0x400 STRIPPED_INLINING_INFO, 0x800 STRIPPED_DEBUG_INFO, 0x1000 VERIFY_GC_MODE_TRANSITIONS (WebAssembly), 0x2000 SINGLE_THREADED.
Sections
IDs 100-127 (Fact:.NET metadata (ECMA-335)/enum/ReadyToRun section types). Most useful for reversing:
- RuntimeFunctions (102): array of RUNTIME_FUNCTION (8 bytes on x86/ARM/ARM64, 12 on AMD64) = begin/end/unwind of every compiled method, like a PE
.pdata. - MethodDefEntryPoints (103): a native-format sparse array indexed by MethodDef RID; each element is
(RuntimeFunctions index << 1) | hasFixups, followed by a nibble-encoded list of import-section slots that must be resolved before the method runs. - ImportSections (101): array of {Section range, Flags (Eager 0x1, PCode 0x4), Type (Unknown 0, StubDispatch 2, StringHandle 3, ILBodyFixups 7), EntrySize, Signatures RVA, AuxiliaryData}. Calls from R2R code go through indirection cells in these sections, initially pointing to lazy-binding thunks; the Signatures give the target method/type/field as encoded signatures, so call targets are named in the image, a big help when annotating disassembly.
- InstanceMethodEntryPoints (109), AvailableTypes (108) (hashtables of generic instantiations and types), ManifestMetadata (112) (extra assembly references for cross-module use), ComponentAssemblies (115) and OwnerCompositeExecutable (116) for composite builds, DebugInfo (105) (variable and sequence-point maps), CompilerIdentifier (100) (e.g.
CoreCLR 4.6.22727.0 PROJECTK, nowCrossgen2 <version>).
Structures use the 'native format' (integer encoding, sparse array, hashtable) described in the spec's 'Native Format' chapter.
Versions
The header comment in readytorun.h is a changelog: 2.1 InliningInfo, 3.0 calling-convention change (not backward compatible), 6.0 managed layout change, 9.x frozen-segment helpers and GCInfo v3, 13 funclet ABI changes, 16 new debug-boundary compression, 17 fat debug info, 18.5 the STRIPPED_* flags. dotnet/runtime main has MAJOR_VERSION 32 and MINIMUM 26 (main is the in-development release after .NET 10). Shipped releases, from readytorun.h on each release branch: .NET 6 5.4, .NET 7 8.0, .NET 8 9.1, .NET 9 10.1, .NET 10 16.0 (Fact:.NET metadata (ECMA-335)/identification/ReadyToRun version and compiler). Unverified: the numbers of servicing updates after the branch heads read (dotnet/runtime release/10.0 at 591ede8).
Related
- Technique:Identifying .NET NativeAOT executables reuses the same 'RTR' signature in a different, simpler header.
- Format:.NET single-file bundle, Format:Xamarin and .NET for Android assembly store can contain R2R assemblies.
- Unverified: the platform-native (ELF/Mach-O) composite envelope is only planned in the spec text read; behaviour in shipping SDKs was not checked.
Code & repositories
- https://github.com/dotnet/runtime @
ec0059c08c077e839c6eb8827c846530a891d7e2· license: MIT
dotnet/runtime: docs/design/coreclr/botr/readytorun-format.md and src/coreclr/inc/readytorun.h (ReadyToRun), src/coreclr/nativeaot (ModuleHeaders.h) and tools/aot ILCompiler sources (NativeAOT sections), src/mono/mono/mini/aot-runtime.[ch] (Mono AOT).
Tested on: source read, not run: Read at this commit (October 2026); not built. · checked 2026-10-18; last activity 2026-10-18