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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
RedDocMD
Posts: 1
Joined: Mon Aug 02, 2021 8:41 am

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

Post 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?
Octocontrabass
Member
Member
Posts: 5563
Joined: Mon Mar 25, 2013 7:01 pm

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

Post by Octocontrabass »

Set it to the smallest page size: 0x1000.
Post Reply