Grub Won't Boot My 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
linguae

Grub Won't Boot My Kernel

Post by linguae »

Hello. I got my kernel to compile (I'm referring to the kernel that I have posted here: http://www.mega-tokyo.com/forum/index.php?board=1, with some corrections). I installed a cross compiler for gcc and binutils (they're cross-compiled for i586-pc-elf.) However, I was unable to get Grub to boot my kernel. Here is what I did:

1. Compiled my kernel sources using nasm (for the assembly sources) and the gcc crosscompiler. All of them are in the elf binary format.
2. Checked to see if my kernel was multiboot compliant (it is, this is the following report):

Code: Select all

kernel.bin: The Multiboot header is found at the offset 3997.
kernel.bin: Page alignment is turned on.
kernel.bin: Memory information is turned on.
kernel.bin: Address fields is turned off.
kernel.bin: All checks passed.
3. Placed the resulting kernel binary into a GRUB floppy image.

Every time I try to boot the kernel, though, I get the following message:
Error 13: Invalid or unsupported executable format.

In case you are wondering, I'm using bochs as my tool for booting, and I developing the OS under FreeBSD 5.4. Thanks in advance.
distantvoices
Member
Member
Posts: 1600
Joined: Wed Oct 18, 2006 11:59 am
Location: Vienna/Austria
Contact:

Re:Grub Won't Boot My Kernel

Post by distantvoices »

1. you shouldn't have needed to build an elf cross compiler for free bsd. Doesn't it produce elf binaries per se or with a flag on freeBSD?

2. What does your menu.lst look like? Have you pointed grub to your kernel image?
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
User avatar
Solar
Member
Member
Posts: 7635
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Grub Won't Boot My Kernel

Post by Solar »

1. ...but it doesn't hurt either. In the very least you don't get temted to #include parts of the standard library. ;)

2. Check out this thread and double-check you are actually using the cross-tools you have build.
Every good solution is obvious once you've found it.
Kim

Re:Grub Won't Boot My Kernel

Post by Kim »

Your object is an elf relocatable object or an elf executable file.
GRUB doesn't boot reloc obj because it doesn't have a program header inside the elf file and the executable type isn't set.

Use readelf -a kernel.bin kernel.info

And post header information... if you need relocations in your executable file pass this param to LD --emit-relocs...
Post Reply