Multiboot header not found (x86_64)

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
TheLittleWho
Member
Member
Posts: 51
Joined: Sun Mar 01, 2015 7:58 am

Multiboot header not found (x86_64)

Post by TheLittleWho »

Hi, I am trying to get into 64 bit mode, but I can't get OS to boot. At the moment, I don't want efectively to enable 64 bit mode, I just want to boot the OS when it is compiled with x86_64 compiles. Using similar link script and boot file, on 32-bit compiler, it works, but when I compile with 64 bit compiler I get "multiboot header not found" error. I decompiled the elf file and the multiboot header seems to be the same as in 32-bit elf, but it doesn't work. How could I get it working?

This is the linker script:

Code: Select all

KERNEL_VMA = 0x100000;
KERNEL_LMA = 0x100000;
ALIGN_VAL = 0x1000;

OUTPUT_FORMAT("elf32-x86-64")
ENTRY(_start64)
SECTIONS
{
    . = KERNEL_LMA;

    linker_kernelStart = .;

    _boot = .;
    .boot :
    {
        CMakeFiles/phios.elf.dir/kernel/src/arch/x86/boot64.s.o (.text)
    }
    _eboot = .;

    _text = .;
    .text :
    {
        *(EXCLUDE_FILE(CMakeFiles/phios.elf.dir/kernel/src/arch/x86/boot64.s.o) .text)
    }
    _etext = .;

    _data = .;
    .data :
    {
        *(.data)
    }
    _edata = .;

    _eh_frame = .;
    .eh_frame :
    {
        *(.eh_frame)
    }
    _eeh_frame = .;

    _bss = .;
    .bss :
    {
        *(.bss)
        *(COMMON)
    }
    _ebss = .;

    linker_kernelEnd = .;

    .comment :
    {
        *(.comment)
    }
}

And this is the boot64.s file:

Code: Select all

.section .text
.code32

multiboot_header_begin:
    .align 4
    .long 0xe85250d6
    .long 0
    .long multiboot_header_end - multiboot_header_begin
    .long -(0xe85250d6 + (multiboot_header_end - multiboot_header_begin))
    .short 0
    .short 0
    .long 8
multiboot_header_end:

.global _start64
.type _start64, @function
_start64:
    # 64-bit initialization should go here
    # and jump...
1:
    hlt
    jmp 1b

.size _start64, . - _start64

.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
stack_top:

Thanks!
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Multiboot header not found (x86_64)

Post by bzt »

You haven't set up entry point in multiboot header. Also, you should check if the header's magic is properly aligned in your elf file. Your checksum doesn't seem to be correct either. Read again the spec carefully.
Post Reply