OSDev.org
https://forum.osdev.org/

Wrong Placement of the Multiboot-Header
https://forum.osdev.org/viewtopic.php?f=1&t=33766
Page 1 of 1

Author:  Neatoro [ Sun Jul 14, 2019 1:03 am ]
Post subject:  Wrong Placement of the Multiboot-Header

Hey folks,

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


Attachment:
multibootheader.PNG
multibootheader.PNG [ 12.46 KiB | Viewed 672 times ]


Thanks for your help!

Author:  Neatoro [ Sun Jul 14, 2019 3:04 am ]
Post subject:  Re: Wrong Placement of the Multiboot-Header

I fixed it, was missing a dot in the assembly code

Code:
.section .multiboot

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/