From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Library:Libdragon" |
|---|
| claim | "In ROMs built with libdragon's preview branch the table of contents is a 16-byte header 'TOC0', u32 cookie (CRC32 of the written files), u32 toc_size (1024), u16 entry_size (64), u16 num_entries, followed by 64-byte entries {u32 rom_offset; u32 size; char name[56]}." |
|---|
| scope | | level | "library" |
|---|
| applies_to | "Library:libdragon" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "libdragon_toc_preview" |
|---|
| size | "0x10" |
|---|
| fields | | offset | "0x0" |
|---|
| size | 4 |
|---|
| type | "char[4]" |
|---|
| name | "magic" |
|---|
| notes | "'TOC0'" |
|---|
|
| offset | "0x4" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "cookie" |
|---|
|
| offset | "0x8" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "toc_size" |
|---|
| notes | "1024" |
|---|
|
| offset | "0xC" |
|---|
| size | 2 |
|---|
| type | "uint16_t" |
|---|
| name | "entry_size" |
|---|
| notes | "64; entries: u32 offset, u32 size, char name[56]" |
|---|
|
| offset | "0xE" |
|---|
| size | 2 |
|---|
| type | "uint16_t" |
|---|
| name | "num_entries" |
|---|
|
|
|---|
| endianness | "big" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "header_t {magic, cookie, toc_size, uint16 entry_size, uint16 num_entries}; entry_t {offset, size, name[]}" |
|---|
| repo | "https://github.com/DragonMinded/libdragon" |
|---|
| commit | "39d0d6096130836a65710da6730290701d060272" |
|---|
| path | "src/rompak.c" |
|---|
| lines | "16-35" |
|---|
|
| type | "source" |
|---|
| detail | "struct toc_s with cookie computed by crc32_update over the written data" |
|---|
| repo | "https://github.com/DragonMinded/libdragon" |
|---|
| commit | "39d0d6096130836a65710da6730290701d060272" |
|---|
| path | "tools/n64tool.c" |
|---|
| lines | "99-125" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "N64FlashcartMenu V0.3.4: 'TOC0' at 0x1930, cookie 0xC5BAEA85, toc_size 1024, entry_size 64, 4 entries (.elf.stripped at 0x1E00 size 536288, .elf.sym at 0x84CE0, .dfs at 0x9D1C0, libdragon.version at 0x233D20)." |
|---|
|
| type | "source" |
|---|
| detail | "SWAPLONG on toc_size, file offset/size, cookie and SWAPSHORT on num_entries/entry_size before writing the TOC" |
|---|
| repo | "https://github.com/DragonMinded/libdragon" |
|---|
| commit | "39d0d6096130836a65710da6730290701d060272" |
|---|
| path | "tools/n64tool.c" |
|---|
| lines | "88-92, 804-821" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Rompak TOC header (preview)" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T04:49:51.462Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T17:25:27.065Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read src/rompak.c at the cited commit: header_t {u32 magic, u32 cookie, u32 toc_size, u16 entry_size, u16 num_entries} = 16 bytes, entry_t {u32 offset, u32 size, char name[]}; TOC_MAGIC 0x544F4330. Big-endian follows from the big-endian MIPS target reading these structs natively (writer byte swaps, per the fact's n64tool evidence, not re-read)." |
|---|
|
|
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T12:14:54.298Z" |
|---|
| summary | "Byte order missing: tools/n64tool.c at 39d0d60 stores cookie, toc_size, entry_size, num_entries and each entry's offset/size through SWAPLONG/SWAPSHORT, so the TOC in the ROM is big endian. Layout…" |
|---|
| changed | |
|---|
|
|
|---|