You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+2-43Lines changed: 2 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,9 +10,7 @@ used in a Multiboot2-kernel.
10
10
11
11
It follows the Multiboot 2.0 specification at https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html and the ELF 64 specification at http://www.uclibc.org/docs/elf-64-gen.pdf.
12
12
13
-
Below is the draft for a blog post about this. I don't plan to finish it but maybe it's helpful as documentation.
14
-
15
-
## The Multiboot 2 Information Structure
13
+
## Background: The Multiboot 2 Information Structure
16
14
The Multiboot information structure looks like this:
17
15
18
16
Field | Type
@@ -30,46 +28,7 @@ type | u32
30
28
size | u32
31
29
other fields | variable
32
30
33
-
All tags are 8-byte aligned. The last tag must be the _end tag_, which is a tag of type `0` and size `8`.
34
-
35
-
## Tags
36
-
37
-
We are interested in two tags, the _Elf-symbols_ tag and the _memory map_ tag. For a full list of possible tags see section 3.4 in the Multiboot 2 specification ([PDF][Multiboot 2]).
The Elf-symbols tag contains a list of all sections of the loaded [ELF] kernel. It has the following format:
43
-
44
-
[ELF]: http://www.uclibc.org/docs/elf-64-gen.pdf
45
-
46
-
Field | Type
47
-
--------------------------- | -----------------
48
-
type = 9 | u32
49
-
size | u32
50
-
number of entries | u32
51
-
entry size | u32
52
-
string table | u32
53
-
section headers | variable
54
-
55
-
Note that this format differs from the description in the Multiboot specification because it seems to be wrong for ELF 64 kernels: The `number of entries`, `entry size`, and `string table` fields seem to be `u32` instead of `u16`. The `multiboot2.h` file in the example section of the specification also specifies these fields as being `u32`, which suggests that the `u16` fields are an editing error. The GRUB2 bootloader [uses u32 fields](https://github.com/josefbacik/grub2/blob/96695ad84ce9c93f057ba53ae77d04d8561586e9/include/multiboot2.h#L298-L300), too.
56
-
57
-
The section headers are just copied from the ELF file, so we need to look at the ELF specification to find the corresponding structure definition. Our kernel is a 64-bit ELF file, so we need to look at the ELF-64 specification ([PDF][ELF specification]). According to section 4 and figure 3, a section header has the following format:
0 commit comments