Can GRUB2 boot a flat-binary kernel?

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
tuxid
Posts: 2
Joined: Sun Mar 09, 2014 1:14 pm

Can GRUB2 boot a flat-binary kernel?

Post by tuxid »

Hello!

So, as you can see above, I'm wondering if GRUB2 can load/boot a flat-binary kernel.
At this time, I'm compiling my kernel as ELF, but I would like to compile it as flat-binary in the future.

So, can GRUB2 boot a flat-binary kernel?
If yes, how? (I already googled a lot, but couln'd find anything helpful)

So long,
tuxid.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Can GRUB2 boot a flat-binary kernel?

Post by Combuster »

tuxid wrote:But I would like to compile it as flat-binary in the future.
Care to explain why? You're probably making things more difficult for yourself than needed.

If yes, how?
It's called the a.out kludge.
"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 ]
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Can GRUB2 boot a flat-binary kernel?

Post by Rusky »

Yes. Your flat-binary just needs the multiboot header, 4-byte aligned in the first 8192 bytes of the file.

Although, flat-binary is kind of a pain since you don't get the benefits of an actual executable format (tools for examining the binary, bss section not stored as literal zeros in the file, easy access to debug symbols, virtual address space placement of sections).
tuxid
Posts: 2
Joined: Sun Mar 09, 2014 1:14 pm

Re: Can GRUB2 boot a flat-binary kernel?

Post by tuxid »

Combuster wrote:Care to explain why? You're probably making things more difficult for yourself than needed.
Rusky wrote:Yes. Your flat-binary just needs the multiboot header, 4-byte aligned in the first 8192 bytes of the file.

Although, flat-binary is kind of a pain since you don't get the benefits of an actual executable format (tools for examining the binary, bss section not stored as literal zeros in the file, easy access to debug symbols, virtual address space placement of sections).
Explaintion ist pretty simple, I'm just always searching for a challenge (one reason why I began to develop a OS) and/or other techniques to solve a problem, haha :)

But you guys got some good points, so I will stay with ELF in the future, as I got my kernel up & running with it.
(Maybe I'm going to switch to a flat-binary-kernel at a later point.)

@Rusky: Of course I got a multiboot header, also with the header adress-fields set. Got surely something wrong there.
Post Reply