Multiboot2 header: unrecognized tag
Posted: Fri May 11, 2018 10:24 am
I am trying to load my kernel with grub. Grub tells me that it found an unrecognized tag(0x18). This is the assembly file with my header:
NASM is giving me a warning when I assemble the file that says that the checksum value is too high for dd. I don't know if that is related but I get the feeling it might be.
While looking at the produced binary file in a hex editor I've come to the conclusion that the value 0x18 is actually the size specified in the address tag.
I have annotated what the hex editor showed me, I would appreciate it if you were tell me if I made any mistakes:
My linker.ld:
I am assembling and linking like this:
I've probably made a really obvious mistake and I hope you can find it because couldn't.
Code: Select all
%include "multiboot2.inc"
BITS 32
section .multiboot
multiboot_header:
align MULTIBOOT_HEADER_ALIGN
dd MULTIBOOT2_HEADER_MAGIC ; magic
dd MULTIBOOT_ARCHITECTURE_I386 ; architecture
dd multiboot_header_end - multiboot_header
dd -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header)) ; checksum
mbi_tag_start:
dw MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST ; type
dw MULTIBOOT_HEADER_TAG_OPTIONAL ; flags
dd mbi_tag_end - mbi_tag_start
dd MULTIBOOT_TAG_TYPE_CMDLINE
dd MULTIBOOT_TAG_TYPE_MMAP
dd MULTIBOOT_TAG_TYPE_FRAMEBUFFER
mbi_tag_end:
address_tag_start:
dw MULTIBOOT_HEADER_TAG_ADDRESS ; type
dw MULTIBOOT_HEADER_TAG_OPTIONAL ; flags
dd address_tag_end - address_tag_start ; size
dd multiboot_header ; header address
dd text_start ; load address
dd text_end ; load end address
dd bss_end ; bss end address
address_tag_end:
entry_address_tag_start:
dw MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS ; type
dw MULTIBOOT_HEADER_TAG_OPTIONAL ; flags
dd entry_address_tag_end - entry_address_tag_start ; size
dd _start
entry_address_tag_end:
framebuffer_tag_start:
dw MULTIBOOT_HEADER_TAG_FRAMEBUFFER ; type
dw MULTIBOOT_HEADER_TAG_OPTIONAL ; flags
dd 1024 ; width
dd 720 ; height
dd 32 ; depth
framebuffer_tag_end: ; I can't find this in the documentation :/
dw MULTIBOOT_HEADER_TAG_END
dw 0
dd 8
multiboot_header_end:
section .text
text_start:
global _start
_start:
cli
mov esp, stack_top ; Set stack pointer
mov ebp, stack_top ; Set stack base
lgdt [gdt_ptr]
push ebx ; Push pointer to multiboot info
push eax ; Push magic value
extern main32
call main32
; Kernel ended somehow
loop:
hlt
jmp loop
gdt:
; null descriptor
dd 0
dd 0
; code descriptor
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b; access
db 11001111b; granularity
db 0 ; base high
; data descriptor
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10010010b; access
db 11001111b; granularity
db 0 ; base high
end_of_gdt:
gdt_ptr:
dw end_of_gdt - gdt - 1 ; limit (Size of GDT)
dd gdt
text_end:
section .bootstrap_stack, nobits
bss_start:
align 4
stack_bottom:
resb 16384
stack_top:
bss_end:
While looking at the produced binary file in a hex editor I've come to the conclusion that the value 0x18 is actually the size specified in the address tag.
I have annotated what the hex editor showed me, I would appreciate it if you were tell me if I made any mistakes:
My linker.ld:
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)
*(.bootstrap_stack)
}
}
Code: Select all
nasm -f elf -isrc/headers/ src/kernel/arch/i686/boot.asm -o build/kernel/arch/i686/boot.o
/* A bunch c files are compiled inbetween */
i686-elf-gcc -T linker.ld -o build/isodir/boot/myos.bin -ffreestanding -O2 -nostdlib /* the object files compiled from the c code */ build/kernel/arch/i686/boot.o -lgcc