GNU LD max-page-size for Multiboot2 header on elf64
Posted: Mon Aug 02, 2021 8:53 am
I am using the following bit of assembly to insert a Multiboot2 header to my kernel:
I am using binutils 2.37 to assemble and link the kernel (cross-compiled to the x86_64-elf target).
The kernel thus formed fails the multiboot2 test:
The Wiki mentions an issue here: https://wiki.osdev.org/Multiboot#Multiboot_2.
The fix suggested is to set the max-page-size while linking.
What would be the correct size to set?
Code: Select all
.set LENGTH, (header_end - header_start)
.set ARCH, 0
.set MAGIC, 0xE85250D6
.set CHECKSUM, -(MAGIC + ARCH + LENGTH)
.section .multiboot
header_start:
.int MAGIC /* Magic number */
.int ARCH /* x86 protected mode */
.int LENGTH /* Header length */
.int CHECKSUM /* Multiboot2 checksum */
/* Set the end flag */
.word 0 /* Type */
.word 0 /* Flag */
.int 8 /* Size */
header_end:
The kernel thus formed fails the multiboot2 test:
Code: Select all
grub-file --is-x86-multiboot2 build/simple-os.bin || echo "Not multiboot 2"
The fix suggested is to set the max-page-size while linking.
What would be the correct size to set?