Introduction
A loader reads the header, and for each of the 18 slots whose size is not zero copies that many bytes from the file offset to the load address; then it clears the BSS and jumps to the entry point. Slot 0 to 6 are called text and slots 7 to 17 data; the names say what a toolchain puts in them, but the header has no flag: a loader copies both kinds the same way.
The slots
| Slot | Name | Usually holds |
|---|---|---|
| 0 to 6 | Text0 to Text6 | Code. A program built by the usual toolchain has one or two (the start-up code is sometimes alone in Text0, at a fixed early address, and the rest of the code in Text1). |
| 7 to 17 | Data0 to Data10 | Read-only data, initialised data and the small data areas (what a compiler names .rodata, .data, .sdata, .sdata2). |
| BSS | — | Zero-filled memory with no bytes in the file: one address and one size in the header. |
These “usually” rows are the viewer’s description of what tools do, not a rule of the format.
Alignment
WiiBrew states that each section should be 32-byte aligned and have a size that is a multiple of 32, or the GameCube’s IPL and the Wii’s IOS reject it. The viewer requires the file offset to be a multiple of 32 to call the file a DOL, and shows a size that is not as an issue.
Small data areas
Code built for the GameCube reaches small global variables through two registers that the start-up code points into the data: r13 (the small data area)
and r2 (the second one, for read-only small data), so a load such as lwz r0, -0x7ff0(r13) reads a variable without building an address.
A DOL has no symbol table and the header holds no register value, so the viewer does not know the bases. They are options (r13 small data base and
r2 small data base, default unknown); when given, a load or store through that register is noted as the base plus the displacement. The register roles
are the PowerPC embedded convention; the particular values are a program’s own.
Not described
Known, not yet covered
- Reference: which section a given toolchain fills with what (only the usual roles above), the effect of the gaps between sections, and the loaders of the disc and of the Homebrew Channel.
- Viewer: data sections are shown as bytes, not decoded; text sections are decoded entirely as instructions.
Links
Reference
- WiiBrew: DOL – the section slots and the alignment rule