Grub Error 13 has me at wits' end...
Posted: Tue Mar 25, 2008 7:40 pm
Hello everyone,
I am a young programmer in way over my head. With that out of the way, let me explain my predicament:
I decided to start simple, using the barebones kernel provided in the OSDev Wiki (very useful for a beginner like me; kudos to whoever wrote that article)
Anyway, I copied the code in the tutorial, except that since I run a 64-bit OS (i.e, GAS and GCC both like to produce ELF64 output) and I plan to build a 64 bit OS anyway, I dedided to change the program so it would be 64-bit compatible by simply replacing the %exx registers with %rxx. I changed nothing else.
I built the code as follows:
$as loader.s -o loader.o
$gcc -o kernel.o -c kernel.c -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
$ld -T linker.ld loader.o kernel.o
When I try to emulate the produced a.out file on a GRUB boot-floppy image, GRUB gives me the infamous error 13 (Invalid or unsupported executable format)
Reading the wiki page more closely, I saw that this could be a symptom of a bad multiboot header. I used mbchk, and:
$mbchk a.out
a.out: No Multiboot header.
it's worth noting that:
$mbchk loader.o
loader.o: The Multiboot header is found at the offset 64.
loader.o: Page alignment is turned on.
loader.o: Memory information is turned on.
loader.o: Address fields is turned off.
loader.o: All checks passed.
Why is this? Can anyone help? Is it an issue w/ my linker.ld script??
P.S: I'm sorry to post such a n00bish question, but I couldn't find an answer in the wiki, or the forums
I am a young programmer in way over my head. With that out of the way, let me explain my predicament:
I decided to start simple, using the barebones kernel provided in the OSDev Wiki (very useful for a beginner like me; kudos to whoever wrote that article)
Anyway, I copied the code in the tutorial, except that since I run a 64-bit OS (i.e, GAS and GCC both like to produce ELF64 output) and I plan to build a 64 bit OS anyway, I dedided to change the program so it would be 64-bit compatible by simply replacing the %exx registers with %rxx. I changed nothing else.
I built the code as follows:
$as loader.s -o loader.o
$gcc -o kernel.o -c kernel.c -Wall -Werror -nostdlib -nostartfiles -nodefaultlibs
$ld -T linker.ld loader.o kernel.o
When I try to emulate the produced a.out file on a GRUB boot-floppy image, GRUB gives me the infamous error 13 (Invalid or unsupported executable format)
Reading the wiki page more closely, I saw that this could be a symptom of a bad multiboot header. I used mbchk, and:
$mbchk a.out
a.out: No Multiboot header.
it's worth noting that:
$mbchk loader.o
loader.o: The Multiboot header is found at the offset 64.
loader.o: Page alignment is turned on.
loader.o: Memory information is turned on.
loader.o: Address fields is turned off.
loader.o: All checks passed.
Why is this? Can anyone help? Is it an issue w/ my linker.ld script??
P.S: I'm sorry to post such a n00bish question, but I couldn't find an answer in the wiki, or the forums