This specification adopts a compromise solution to this problem. Multiboot-compliant OS images always contain a magic Multiboot header (see OS image format), which allows the boot loader to load the image without having to understand numerous a.out variants or other executable formats. This magic header does not need to be at the very beginning of the executable file, so kernel images can still conform to the local a.out format variant in addition to being Multiboot-compliant.
An OS image may be an ordinary 32-bit executable file in the standard format for that particular operating system, except that it may be linked at a non-default load address to avoid loading on top of the PC’s I/O region or other reserved areas, and of course it should not use shared libraries or other fancy features.
An OS image must contain an additional header called Multiboot header, besides the headers of the format used by the OS image. The Multiboot header must be contained completely within the first 8192 bytes of the OS image, and must be longword (32-bit) aligned. In general, it should come as early as possible, and may be embedded in the beginning of the text segment after the real executable header.
The layout of the Multiboot header must be as follows:
Offset | Type | Field Name | Note |
0 | u32 | magic | required |
4 | u32 | flags | required |
8 | u32 | checksum | required |
12 | u32 | header_addr | if flags[16] is set |
16 | u32 | load_addr | if flags[16] is set |
20 | u32 | load_end_addr | if flags[16] is set |
24 | u32 | bss_end_addr | if flags[16] is set |
28 | u32 | entry_addr | if flags[16] is set |
32 | u32 | mode_type | if flags[2] is set |
36 | u32 | width | if flags[2] is set |
40 | u32 | height | if flags[2] is set |
44 | u32 | depth | if flags[2] is set |
The field ‘magic’ is the magic number identifying the header, which must be the hexadecimal value 0x1BADB002
.
The field ‘flags’ specifies features that the OS image requests or requires of an boot loader.
The field ‘checksum’ is a 32-bit unsigned value which, when added to the other magic fields (i.e. ‘magic’ and ‘flags’), must have a 32-bit unsigned sum of zero.