Difference between revisions of "DOL (File Format)"
m |
(Give this format the usual treatment.) |
||
Line 1: | Line 1: | ||
+ | The '''DOL''' format is the name given to a section of [[Wii]] and [[GameCube]] disc partitions. This section represents an object file. It contains [[Assembly Code|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]]. | ||
− | A C-definition of the DOL header: | + | = 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 (File Format)|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 (<code>bss</code>) 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 <code>0x80004000</code> to <code>0x81200000</code>. Addresses outside this range are reserved for the operating system and the loader. | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |+ 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 (<code>bss</code>) range. | ||
+ | |- | ||
+ | | 0x0dc | ||
+ | | 4 | ||
+ | | '''bss length''' indicates the size in bytes of the zero initialised (<code>bss</code>) range. | ||
+ | |- | ||
+ | | 0x0e0 | ||
+ | | 4 | ||
+ | | '''Entry point''' indicates the virtual memory address of a function to run after the the DOL has been loaded in order to start the program. This function should not return. | ||
+ | |- | ||
+ | | 0x0e4 | ||
+ | | 0x1c | ||
+ | | {{unknown|Padding.}} | ||
+ | |- | ||
+ | | 0x100 | ||
+ | | colspan=3 {{unknown|'''End of header'''. Start of section data.}} | ||
+ | |- | ||
+ | |} | ||
+ | |||
+ | A GNU C-definition of the DOL header: | ||
<pre> | <pre> | ||
− | |||
#define DOL_N_TEXT_SECTIONS 7 | #define DOL_N_TEXT_SECTIONS 7 | ||
#define DOL_N_DATA_SECTIONS 11 | #define DOL_N_DATA_SECTIONS 11 | ||
Line 11: | Line 58: | ||
typedef struct dol_header_t | typedef struct dol_header_t | ||
{ | { | ||
− | /* 0x00 */ | + | /* 0x00 */ uint32_t sect_off [DOL_N_SECTIONS]; // file offset |
− | /* 0x48 */ | + | /* 0x48 */ uint32_t sect_addr[DOL_N_SECTIONS]; // virtual address |
− | /* 0x90 */ | + | /* 0x90 */ uint32_t sect_size[DOL_N_SECTIONS]; // section size |
− | /* 0xd8 */ | + | /* 0xd8 */ uint32_t bss_addr; // BSS address |
− | /* 0xdc */ | + | /* 0xdc */ uint32_t bss_size; // BSS size |
− | /* 0xe0 */ | + | /* 0xe0 */ uint32_t entry_addr; // entry point |
− | /* 0xe4 */ | + | /* 0xe4 */ uint8_t padding[DOL_HEADER_SIZE-0xe4]; |
} | } | ||
__attribute__ ((packed)) dol_header_t; | __attribute__ ((packed)) dol_header_t; |
Revision as of 09:22, 9 October 2017
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.
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 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. |
A GNU C-definition of the DOL header:
#define DOL_N_TEXT_SECTIONS 7 #define DOL_N_DATA_SECTIONS 11 #define DOL_N_SECTIONS 18 #define DOL_HEADER_SIZE 0x100 typedef struct dol_header_t { /* 0x00 */ uint32_t sect_off [DOL_N_SECTIONS]; // file offset /* 0x48 */ uint32_t sect_addr[DOL_N_SECTIONS]; // virtual address /* 0x90 */ uint32_t sect_size[DOL_N_SECTIONS]; // section size /* 0xd8 */ uint32_t bss_addr; // BSS address /* 0xdc */ uint32_t bss_size; // BSS size /* 0xe0 */ uint32_t entry_addr; // entry point /* 0xe4 */ uint8_t padding[DOL_HEADER_SIZE-0xe4]; } __attribute__ ((packed)) dol_header_t;