From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:NRO" |
|---|
| claim | "The MOD0 header is found through the u32 at offset 4 of the first segment (offset of MOD0 relative to the start of the image); its fields are signed 32-bit offsets relative to the MOD0 header itself: .dynamic, bss start/end, eh_frame_hdr start/end, a module-object slot (zero in libnx), and libnx extensions LNY0 (GOT range), LNY1 (relro range) and, in the crt0 stub, LNY2 (version word)." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:NRO" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "Mod0Header" |
|---|
| endianness | "little" |
|---|
| fields | | offset | "0x00" |
|---|
| size | 4 |
|---|
| type | "u32" |
|---|
| name | "magic_mod0" |
|---|
| notes | "0x30444f4d, bytes 4D 4F 44 30 MOD0" |
|---|
|
| offset | "0x04" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "dyn_offset" |
|---|
| notes | "to _DYNAMIC" |
|---|
|
| offset | "0x08" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "bss_start_offset" |
|---|
|
| offset | "0x0C" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "bss_end_offset" |
|---|
|
| offset | "0x10" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "eh_frame_hdr_start_offset" |
|---|
|
| offset | "0x14" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "eh_frame_hdr_end_offset" |
|---|
|
| offset | "0x18" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "module_object_offset" |
|---|
| notes | "libnx dynamic.c calls it unused; crt0 comment: offset to runtime-generated module object, not used in homebrew, emitted as 0" |
|---|
|
| offset | "0x1C" |
|---|
| size | 4 |
|---|
| type | "u32" |
|---|
| name | "magic_lny0" |
|---|
| notes | "0x30594e4c 'LNY0' (libnx extension)" |
|---|
|
| offset | "0x20" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "got_start_offset" |
|---|
|
| offset | "0x24" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "got_end_offset" |
|---|
|
| offset | "0x28" |
|---|
| size | 4 |
|---|
| type | "u32" |
|---|
| name | "magic_lny1" |
|---|
| notes | "0x31594e4c 'LNY1'" |
|---|
|
| offset | "0x2C" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "relro_start_offset" |
|---|
|
| offset | "0x30" |
|---|
| size | 4 |
|---|
| type | "s32" |
|---|
| name | "relro_end_offset" |
|---|
| notes | "crt0 emits __data_start here" |
|---|
|
| offset | "0x34" |
|---|
| size | 4 |
|---|
| type | "u32" |
|---|
| name | "magic_lny2" |
|---|
| notes | "'LNY2' (0x32594e4c); only in crt0 blocks that emit it, not part of the Mod0Header struct of dynamic.c" |
|---|
|
| offset | "0x38" |
|---|
| size | 4 |
|---|
| type | "u32" |
|---|
| name | "lny2_version" |
|---|
| notes | "1 in the cited crt0 (version/fix field)" |
|---|
|
| offset | "0x3C" |
|---|
| size | 4 |
|---|
| type | "u32" |
|---|
| name | "lny2_reserved" |
|---|
| notes | "0" |
|---|
|
|
|---|
| size_min | "0x34" |
|---|
| size_max | "0x40" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "Mod0Header struct and magic comparisons" |
|---|
| repo | "https://github.com/switchbrew/libnx" |
|---|
| commit | "20cbcfd90567f7bf84df7725f27e345e2164fa6b" |
|---|
| path | "nx/source/runtime/dynamic.c" |
|---|
| lines | "7-21, 73-75, 124" |
|---|
|
| type | "source" |
|---|
| detail | "crt0 __nx_mod0 block: 'MOD0' + six words, 'LNY0' + two, 'LNY1' + two, then 'LNY2' + version 1 + reserved 0 (not part of the Mod0Header struct in dynamic.c, so the emitted block is 0x40 bytes); each word is symbol - __nx_mod0; _start has 'b 1f', then the word __nx_mod0 - _start at +4 and the ASCII HOMEBREW at +8, code resumes at _start+0x80" |
|---|
| repo | "switchbrew/libnx" |
|---|
| commit | "20cbcfd90567f7bf84df7725f27e345e2164fa6b" |
|---|
| path | "nx/source/runtime/switch_crt0.s" |
|---|
| lines | "5-10, 67-88" |
|---|
|
| type | "source" |
|---|
| detail | "__nx_dynamic returns early if magic is not MOD0; it clears bss, walks the dynamic section for DT_RELA/RELASZ/DT_RELR/RELRSZ, applies R_AARCH64_NONE and R_AARCH64_RELATIVE only (any other relocation type aborts) and only protects relro when both LNY0 and LNY1 magics are present" |
|---|
| repo | "switchbrew/libnx" |
|---|
| commit | "20cbcfd90567f7bf84df7725f27e345e2164fa6b" |
|---|
| path | "nx/source/runtime/dynamic.c" |
|---|
| lines | "30-50, 71-138" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "MOD0 header" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-18T07:01:26.820Z" |
|---|
| verifications | |
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T12:51:20.880Z" |
|---|
| summary | "Size was wrong (0x34 in libnx's struct, 0x40 as emitted by crt0 with LNY2); add LNY2; crt0 evidence" |
|---|
| changed | | "claim" |
| "data" |
| "evidence" |
|
|---|
|
| by | "PatientStepper99" |
|---|
| date | "2026-10-19T17:33:31.420Z" |
|---|
| summary | "The data stops at 0x34 although the claim and evidence say crt0 emits 0x40 bytes with LNY2: list LNY2 (magic 0x32594e4c at 0x34, version word 1 at 0x38, reserved 0 at 0x3C) as fields present only in…" |
|---|
| changed | |
|---|
|
|
|---|