Page 1 of 1

Creating a multiboot ELF image

Posted: Sat Dec 01, 2001 7:06 am
by jmmv
I'm new to the forum, HI ALL!

I'm starting some kernel stuff, just for fun ;D I've been at the FAQ but I didn't find answers to my questions. So, here they go:

I don't know how to compile an elf-multiboot kernel image. I've created a little head.asm file with a silly multiboot header and a main.c file that just contains an endless main() function (with a 'for' inside).

I assemble head.asm with:
nasm -f elf head.as head.o

I compile main.c with:
gcc -o main.o -c main.c

Then, I join them with the following command:
ld -Ttext 0x100000 -e start --oformat elf32-i386 boot/head.o kernel/main.o -o mykernel.o

But when trying to load the image file with GRUB, it says that it is invalid.

Are these commands valid for the compilation??

My silly multiboot header is now:

align 32
dd 0x1BADB002 ; Magic
dd 0 ; Flags...
dd 0 ; What here?

Am I supposed to create a valid Multiboot header inside the file? Where can I get good info about this? And an (clear) example?

Thanks a lot!!

PS: Maybe this should go to the FAQ, isn't it?  ;)

Re: Creating a multiboot ELF image

Posted: Sat Dec 01, 2001 4:48 pm
by Chris Giese
You may need to set the checksum in the Multiboot header (your "What here?" field).

You can use "mbchk" before booting to see if the Multiboot header is OK.

http://www.washingdishes.freeuk.com/grubtut.html
http://www.execpc.com/~geezer/osd/boot/grub-how.txt