0

I am trying to make a minimal kernel. My goal is to make this not-yet-existing kernel to be multiboot2 compliant. So I started out by creating a minimal multiboot2-header in NASM-Assembly.

I am using grub-file to test whether my binary is compliant.

The problem: When I assemble my file to an elf32, grub-file is happy. However, when i assemble my header to a raw binary using nasm, the resulting file is not compliant.

Why is that? In the multiboot2 specification no specific executable-format is specified.

multiboot2header.asm:

section .multiboot
align 8,db 0
multibootheader_start:
    dd 0xE85250D6
    dd 0
    dd (multibootheader_end - multibootheader_start)
    dd -(0xE85250D6 + multibootheader_end - multibootheader_start)
multibootheader_end:

NASM commands:

nasm -felf32 multiboot2header.asm -o multiboot2header.bin

nasm -fbin multiboot2header.asm -o multiboot2header.bin

grub-file command:

grub-file --is-x86-multiboot2 multiboot2header.bin

Alexander
  • 3
  • 1

1 Answers1

0

I suspect that the problem is caused by not having an address tag structure (see https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#Address-header-tag ).

This tag is optional for Elf format files (because the boot loader can just use Elf's headers); but is required for other cases (because the boot loader won't have a clue where to load the file otherwise).

Brendan
  • 35,656
  • 2
  • 39
  • 66
  • Thanks! After taking another look at the documentation, I found the following statement, proving your answer: Note: This information does not need to be provided if the kernel image is in ELF format, but it must be provided if the image is in a.out format or in some other format. When the address tag is present it must be used in order to load the image, regardless of whether an ELF header is also present. Compliant boot loaders must be able to load images that are either in ELF format or contain the address tag embedded in the Multiboot2 header. – Alexander Jun 29 '21 at 19:40