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
An experimental Multiboot 2 crate for ELF-64 kernels. It's still incomplete, so please open an issue if you're missing some functionality. Contributions welcome!
6
+
Library that helps you to parse the multiboot information structure (mbi) from
7
+
Multiboot2-compliant bootloaders, like GRUB. It supports all tags from the specification
8
+
including full support for the sections of ELF-64. This library is `no_std` and can be
9
+
used in a Multiboot2-kernel.
7
10
8
-
It uses 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.
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.
9
12
10
-
Below is the draft for a blog post about this. I don't plan to finish it but maybe it's helpful as documentation.
11
-
12
-
## The Multiboot 2 Information Structure
13
+
## Background: The Multiboot 2 Information Structure
13
14
The Multiboot information structure looks like this:
14
15
15
16
Field | Type
@@ -27,46 +28,7 @@ type | u32
27
28
size | u32
28
29
other fields | variable
29
30
30
-
All tags are 8-byte aligned. The last tag must be the _end tag_, which is a tag of type `0` and size `8`.
31
-
32
-
## Tags
33
-
34
-
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:
40
-
41
-
[ELF]: http://www.uclibc.org/docs/elf-64-gen.pdf
42
-
43
-
Field | Type
44
-
--------------------------- | -----------------
45
-
type = 9 | u32
46
-
size | u32
47
-
number of entries | u32
48
-
entry size | u32
49
-
string table | u32
50
-
section headers | variable
51
-
52
-
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.
53
-
54
-
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