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.
I made a few adaptions to the linker script in the barebones tutorial, so that the multiboot header is now a section of its own. However, when I build the kernel image, objdump reports that the .mbheader section is located after .text in the file even though the linker script says otherwise. It's not a problem now (kernel boots fine) but the multiboot spec says the header should be in the first 8 kB, so what if the text section grows beyond 8 kB? Is this a problem (and if so how do I fix it) or am I just being daft and not understanding the ELF format properly?
objdump reports that the .mbheader section is located after .text
00100000 .mbheader
0010000c .text
Right.....
Maybe try turning your screen the right side up and not look at the size
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
I was referring to the file offsets actually (1038 and 100c). Those are what GRUB looks for, not the load addresses.
An OS image must contain an additional header called Multiboot header, besides the headers of the format used by the OS image. The Multiboot header must be contained completely within the first 8192 bytes of the OS image, and must be longword (32-bit) aligned.
I interpret that to mean the first 8k of the file, not the first 8k of the loaded kernel. After all, why would GRUB go through all the trouble of mapping ELF sections before it even knows whether the kernel is properly bootable or not?
Putting it in .text does work, but why doesn't it work otherwise?