Page 1 of 1

GNU LD max-page-size for Multiboot2 header on elf64

Posted: Mon Aug 02, 2021 8:53 am
by RedDocMD
I am using the following bit of assembly to insert a Multiboot2 header to my kernel:

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:
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:

Code: Select all

grub-file --is-x86-multiboot2 build/simple-os.bin || echo "Not multiboot 2"
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?

Re: GNU LD max-page-size for Multiboot2 header on elf64

Posted: Thu Aug 05, 2021 8:08 pm
by Octocontrabass
Set it to the smallest page size: 0x1000.