Hello,
I’m trying to compile and link a multiboot kernel using Haiku, but when I boot into my kernel on another machine I get a ‘No Multiboot Header found’
I started out defining a .multiboot section in my kernel code, and when that didn’t work I tried doing it in the linker script, but either way when I link using:
ld -o kernel.bin -T linker.ld --oformat binary obj/kernel.o obj/print.o -m elf_i386_haiku -e _start
it shoves everything in the .data section, and I suspect this is why the bootloader is not finding the header.
Linker Script
ENTRY(_start)
SECTIONS
{
. = 0x10000;
.multiboot : {
KEEP(*(.multiboot))
}
.text : {
*(.text)
}
.rodata : {
*(.rodata*)
}
.data : {
*(.data)
}
.bss : {
*(.bss)
}
}
And my original Multiboot definition in the source:
...
#define MULTIBOOT_MAGIC 0x1BADB002
#define MULTIBOOT_FLAGS 0x00000003
extern "C" void print(const char* str);
struct MultibootHeader {
uint32_t magic;
uint32_t flags;
uint32_t checksum;
};
// Align the Multiboot header to 8 bytes
__attribute__((section(".multiboot"),aligned(8)))
static MultibootHeader header = {
.magic = MULTIBOOT_MAGIC,
.flags = MULTIBOOT_FLAGS,
.checksum = static_cast<uint32_t>(-(MULTIBOOT_MAGIC + MULTIBOOT_FLAGS))
};
...
Regardless, something ain’t right. Is there some optimization or default flag being set in Haiku’s implementation of the linker which would be causing this? Or is there something blindingly obvious I should be seeing in my script/code?
I’m fairly new to kernel code, so I’m sort of in unfamiliar territory here.
Any help would be gratefully received!
EDIT: When running objdump -f kernel.bin -b binary I get:
kernel.bin file format binary
architecture: UNKNOWN!, flags 0x00000000
start address 0x00000000