NRO

From Nintendo Switch Brew
Revision as of 21:32, 25 September 2024 by Hexkyz (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

NRO is the executable format for non-ExeFS binaries.

It starts with the NRO-start structure then the "NRO" header and mainly describes .text, .rodata, and .data segments (like a short-form of ELF program headers).

NroHeader

This is "nn::ro::detail::NroHeader".

Offset Size Description
0x0 0x10 Rocrt
0x10 0x4 Signature ("NRO0")
0x14 0x4 Version
0x18 0x4 Size (total NRO file size)
0x1C 0x4 Flags
0x20 0x4 TextMemoryOffset
0x24 0x4 TextSize
0x28 0x4 RoMemoryOffset
0x2C 0x4 RoSize
0x30 0x4 DataMemoryOffset
0x34 0x4 DataSize
0x38 0x4 BssSize
0x3C 0x4 Reserved
0x40 0x20 ModuleId
0x60 0x4 DsoHandleOffset
0x64 0x4 Reserved
0x68 0x4 EmbeddedOffset
0x6C 0x4 EmbeddedSize
0x70 0x4 DynStrOffset
0x74 0x4 DynStrSize
0x78 0x4 DynSymOffset
0x7C 0x4 DynSymSize

RocrtHeader

This is "nn::ro::detail::RocrtHeader".

Offset Size Description
0x0 [17.0.0+] 0xC ([1.0.0-16.1.0] 0x8) ModuleHeaderLocation
0xC 0x4 Reserved

ModuleId

This is "nn::ro::detail::ModuleId".

Value of "build id" from ELF's GNU .note section. Contains variable sized digest, up to 32bytes.

Homebrew

Assets

This is an optional custom assets section for homebrew, this is located at file offset {NroHeader.size}. See also switch-tools for implementation.

The below offsets are relative to the beginning of the assets section (AssetHeader).

AssetHeader

Offset Size Description
0x0 0x4 Magic "ASET"
0x4 0x4 Format version, currently 0.
0x8 0x10 AssetSection icon. Used by the Homebrew Launcher. Like official icons, this is a 256x256 JPEG.
0x18 0x10 AssetSection NACP. Used by the Homebrew Launcher.
0x28 0x10 AssetSection romfs. Can be used by the application.

AssetSection

Offset Size Description
0x0 0x8 Offset
0x8 0x8 Size, 0 indicates this section is empty.