yesterday I added some code to my kernel after I followed the Bare Bones tutorial (https://wiki.osdev.org/Bare_Bones). Afterwards I got the error that GRUB is not anymore able to find the multiboot header. I checked the .bin file and saw that for some reasons the multiboot header is placed after the actual kernel code. At least I am guessing that it is placed after the kernel code because I see "Hello World" some bytes before.
I currently have the feeling that something is off with my linker configuration, but I have no clue what. Maybe someone of you could give my some insights:
Code: Select all
ENTRY(_start)
SECTIONS {
. = 1M;
.text BLOCK(4K) : ALIGN(4K)
{
*(.multiboot)
*(.text)
}
.rodata BLOCK(4K) : ALIGN(4K)
{
*(.rodata)
}
.data BLOCK(4K) : ALIGN(4K)
{
*(.data)
}
.bss BLOCK(4K) : ALIGN(4K)
{
*(COMMON)
*(.bss)
}
}
Code: Select all
.set ALIGN, 1<<0
.set MEMINFO, 1<<1
.set FLAGS, ALIGN | MEMINFO
.set MAGIC, 0x1BADB002
.set CHECKSUM, -(MAGIC + FLAGS)
.section multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
.section .bss
.align 16
stack_bottom:
.skip 16384
stack_top:
.section .text
.global _start
.type _start, @function
_start:
mov $stack_top, %esp
call kernel_main
cli
1: hlt
jmp 1b
.size _start, . - _start