Why is grub not properly parsing my multiboot2 header?

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
captiveMind
Posts: 2
Joined: Mon Oct 31, 2016 5:05 pm

Why is grub not properly parsing my multiboot2 header?

Post by captiveMind »

My multiboot header code looks like this:

Code: Select all

#multiboot section
.section .multiboot
.align 8

multiboot_start:
.long MAGIC
.long ARCH
.long HEADER_LENGTH
.long CHECKSUM

#information requests
info_tag_start:
.short INFO_REQUEST_TAG
.short NOT_OPTIONAL
.long info_tag_end - info_tag_start
.long BASIC_MEMINFO_TYPE
info_tag_end:

#address tag
address_tag_start:
.short ADDRESS_TAG
.short OPTIONAL
.long address_tag_end - address_tag_start
.long multiboot_start
.long _start #text start
.long _edata #data end
.long _end #bss end
address_tag_end:

#entry tag
entry_tag_start:
.short ENTRY_TAG
.short OPTIONAL
.long entry_tag_end - entry_tag_start
.long _start
entry_tag_end:

#end tag
.short END_TAG
.short NOT_OPTIONAL
.long 8
multiboot_end:
I can look in the resulting elf file and see the header as follows:

Code: Select all

0xe85250d6 //checksum
0x00000000 //i386 arch
0x00000048 //header size
0x17adaee2 //checksum

0x0001 //information request
0x0000 //non-optional
0x0000000c //size
0x00000004 //request basic memory info

0x0002 //address info
0x0001 //optional
0x00000018 //size
0x00100000 //multiboot header start
0x00100048 //code start
0x00101098 //end of .data
0x00101098 //end of .bss

0x0003 //entry tag
0x0001 //optional
0x0000000c //size
0x00100048 //entry point

0x0000 //end tag
0x0000
0x00000008
When I try to load my kernel with grub, I get an error message stating that 0x10002 is not a valid information request type. So grub is interpreting the beginning of the address tag header as another information request type. But why? That tag has the proper size and the multiboot spec doesn't mention anything about sentinel values or anything like that.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Why is grub not properly parsing my multiboot2 header?

Post by SpyderTL »

Does the Tag.Size field include the Tag itself? I can't find any documentation about what to put in this field.

Try changing Tag.Size to 4.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
captiveMind
Posts: 2
Joined: Mon Oct 31, 2016 5:05 pm

Re: Why is grub not properly parsing my multiboot2 header?

Post by captiveMind »

The multiboot2 spec says
‘size’ contains the size of tag including header fields
Changing the size to 4 does work, so it looks like this is an issue with grub not following the standard.
Post Reply