NRO: Difference between revisions

Based on the NSO page.
 
No edit summary
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
[[Category:File formats]]
NRO is the executable format for non-[[ExeFS]] binaries.
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):
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".


= NRO Start =
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 12: Line 13:
|-
|-
| 0x0
| 0x0
| 0x10
| [[#RocrtHeader|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|ModuleId]]
|-
| 0x60
| 0x4
| DsoHandleOffset
|-
| 0x64
| 0x4
| Reserved
|-
| 0x68
| 0x4
| EmbeddedOffset
|-
| 0x6C
| 0x4
| 0x4
| Unused
| EmbeddedSize
|-
|-
| 0x70
| 0x4
| 0x4
| DynStrOffset
|-
| 0x74
| 0x4
| DynStrSize
|-
| 0x78
| 0x4
| 0x4
| [[NSO|MOD0]] offset
| DynSymOffset
|-
|-
| 0x8
| 0x7C
| 0x8
| 0x4
| Padding
| DynSymSize
|}
|}


= NRO Header =
== RocrtHeader ==
This is "nn::ro::detail::RocrtHeader".
 
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 32: Line 111:
|-
|-
| 0x0
| 0x0
| 4
| [17.0.0+] 0xC ([1.0.0-16.1.0] 0x8)
| Magic "NRO0"
| [[MOD#ModuleHeaderLocation|ModuleHeaderLocation]]
|-
|-
| 0xC
| 0x4
| 0x4
| 4
| 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 [https://github.com/switchbrew/switch-tools switch-tools] for implementation.
 
The below offsets are relative to the beginning of the assets section (AssetHeader).
 
=== AssetHeader ===
{| class="wikitable" border="1"
|-
|-
| 0x8
! Offset
| 4
! Size
| Total NRO filesize
! Description
|-
|-
| 0xC
| 0x0
| 4
| 0x4
| ?
| Magic "ASET"
|-
| 0x10
| 0x8 * 3
| SegmentHeader[3]
|-
|-
| 0x28
| 0x4
| 0x4
| bssSize
|-
| 0x2C
| 0x4
| 0x4
| ?
| Format version, currently 0.
|-
|-
| 0x30
| 0x8
| 0x20
| 0x10
| Value of "build id" from ELF's GNU .note section. Contains variable sized digest, up to 32bytes.
| AssetSection icon. Used by the Homebrew Launcher. Like official icons, this is a 256x256 JPEG.
|-
|-
| 0x50
| 0x18
| 0x10
| 0x10
| Padding
| AssetSection [[NACP_Format|NACP]]. Used by the Homebrew Launcher.
|-
|-
| 0x60
| 0x28
| 0x10
| 0x10
| ?
| AssetSection romfs. Can be used by the application.
|}
|}


== SegmentHeader ==
=== AssetSection ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
Line 80: Line 166:
|-
|-
| 0x0
| 0x0
| 4
| 0x8
| FileOffset
| Offset
|-
|-
| 0x4
| 0x8
| 4
| 0x8
| Size
| Size, 0 indicates this section is empty.
|}
|}