Technique:Identifying .NET NativeAOT executables
| On this wiki | Facts · Code · Notes · Topics |
|---|
A NativeAOT (ILCompiler) program is a plain native PE/ELF/Mach-O binary without IL or a CLR header: managed code sits in dedicated sections, a 'ReadyToRunHeader' with the signature RTR (0x00525452) is reached from a modules section, and type names survive only as far as reflection metadata and the runtime's needs.
Recognising one
- No CLR header and no
BSJBmetadata root: it is not a managed assembly, so IL decompilers see nothing. Contrast Format:.NET ReadyToRun, which keeps IL. - The compiler (
src/coreclr/tools/aot/ILCompiler.Compiler) puts compiled managed code in an own section:.managedcode(Windows;.managedcode$Icontent) or__managedcode(Unix/Mach-O); unboxing stubs in.unbox/__unbox; the module table in.modules/__modules(a writable pointer to the module header); and, when the compiler 'dehydrates' data (the default for size), an uninitialised section namedhydratedthat startup code fills from a compressed__dehydrated_datastream. See Fact:Identifying .NET NativeAOT executables/identification/Section names. - The modules section contains a pointer to a
ReadyToRunHeader(Fact:Identifying .NET NativeAOT executables/struct/NativeAOT ReadyToRunHeader): u32 Signature 0x00525452 'RTR', u16 MajorVersion, u16 MinorVersion, u32 Flags, u16 NumberOfSections, u8 EntrySize, u8 EntryType, then entries (id + pointer-sized data/end pair; entry size = 8 + pointer size). Current version indotnet/runtimemain is 32.0, kept in sync with the ReadyToRun major version. - NativeAOT section ids (Fact:Identifying .NET NativeAOT executables/enum/NativeAOT section types): 200 StringTable, 201 GCStaticRegion, 202 ThreadStaticRegion, 204 TypeManagerIndirection, 205 EagerCctor, 206 FrozenObjectRegion, 208 ThreadStaticOffsetRegion, 212 ImportAddressTables, 300-399 reserved read-only blob regions. These differ from ReadyToRun ids (100-127) although the header signature is the same.
- The managed entry point is a symbol
__managed__Main(constantManagedEntryPointMethodNamein MainMethodRootProvider.cs) called from a small native startup; symbol names are mangled with the compilation unit prefix. In stripped release builds these symbols are gone. - Unverified: runtime strings such as exception messages and
System.Private.CoreLibtype names are present in a typical binary; a quick filter is to grep for 'System.Private.CoreLib' (not tested here).
What survives
The compiler only keeps reflection metadata for what is reachable and rooted (analysis, rd.xml descriptors, default for serializers etc.). Type names often remain as strings for Type.ToString(), EEType records (MethodTable-like structures) and generated metadata; method names generally do not unless metadata for them is kept. Useful switches that document the layout of a build you control: IlcGenerateMapFile (object layout map *.map.xml), IlcGenerateMetadataLog (CSV of metadata handles, kinds and names), IlcGenerateMstatFile (size info for types/methods), IlcGenerateDgmlFile (troubleshooting doc). Generated code uses the runtime-internal calling conventions and a GC info encoding shared with ReadyToRun.
Practical workflow
- Confirm a native binary, find the modules section, follow the pointer to the RTR header and list sections.
- Use the .NET type-system knowledge (Format:.NET metadata (ECMA-335) concepts such as MethodTable layout) to recover EEType structures from the frozen-object and data regions.
- Look for hints of the .NET version in the RTR header version and in runtime strings. Unverified: public tooling that automates recovery (leads only; search GitHub for NativeAOT symbol-recovery scripts for Ghidra/IDA).
See also: Technique:Cross-platform app frameworks, Technique:Recognizing code obfuscation.
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