Luigi's Mansion:Docs/DOL (File Format)

From LM Hacking
Jump to navigation Jump to search

Summary[edit | edit source]

DOL files can be edited only through a hex editor. It can be extracted and imported.

In Luigi Mansion, the DOL is the executable of the game, containing compiled code the GameCube can use.

Format Information[edit | edit source]

The DOL format is the name given to a section of Wii and GameCube disc partitions. This section represents an object file. It contains compiled 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 some disc viewers/editors may list the file as main.dol, or start.dol, orboot.dol, or similar, which contains the DOL section of the disc. This article documents the generic DOL format, information about Luigi's Mansion's DOL can be found at DOL (Information).

File Format[edit | edit source]

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).

Header[edit | edit source]

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 initialized (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.
(Source: Custom Mario Kart Wiiki)