DOL (File Format)

From Custom Mario Kart
(Redirected from DOL)
Jump to: navigation, search

The DOL format is the name given to a section of Wii and GameCube disc partitions. This section represents an object file. It contains code for the game or program on the disc as well as the data needed by that code. The discs do not explicitly contain a file with the DOL format in the file system, but by convention most disc viewers/editors list a file called main.dol which contains the DOL section of the disc. Mario Kart Wii's disc contains three DOL sections for each of its three disc partitions. This article documents the generic DOL format, information about Mario Kart Wii's main DOL can be found at main.dol.

File Format

Like many object formats, DOLs are divided into sections, grouped by like access. For example, executable code may be placed in one section, read only data in another, etc. The file begins with a header and then is directly followed by the section data. The format does not support relocation or symbol information and so DOLs are much simpler and much less flexible than most common object formats such as ELF or PE (.exe). The REL format is used by some games including Mario Kart Wii when a more complex object format is required.

Header

The file begins with a header of 0x100 bytes. The header allows for a maximum of 18 sections with contents. The first 7 sections can contain executable code and the remaining 11 sections can only contain data. The header also allows for a zero initialised (bss) range. This range can overlap the 18 sections, with the sections taking priority. DOL files on Wii and GameCube should only affect address in the range 0x80004000 to 0x81200000. Addresses outside this range are reserved for the operating system and the loader.

DOL file header
Offset Size Description
0x000 4 × 18 Section offsets indicate where each section's data begins relative to the start of this header. 0 for unused sections.
0x048 4 × 18 Section address indicates where each section should be copied to by the loader as a virtual memory address. 0 for unused sections.
0x090 4 × 18 Section lengths indicate the size in bytes of each section. 0 for unused sections.
0x0d8 4 bss address indicates the start of the zero initialised (bss) range.
0x0dc 4 bss length indicates the size in bytes of the zero initialised (bss) range.
0x0e0 4 Entry point indicates the virtual memory address of a function to run after the DOL has been loaded in order to start the program. This function should not return.
0x0e4 0x1c Padding.
0x100 End of header. Start of section data.