Page 1 of 1

Grub - Error 13 - Invalid or unsupported executable format

Posted: Tue Feb 24, 2004 8:41 pm
by gommo
I'm trying to right a simple kernel following
http://www.osdever.net/tutorials/basick ... ?the_id=12

I also am using grub as the bootloader. To enable this I need to make my kernel image multiboot. So rather than simply use the kernel_start.asm file in the tutorial I used the boot.S and multiheader.h files from grub.

in boot.S I changed the call to main to EXT_C(k_main) and then called hlt straight after that. Removing references to printf and stuff

I then compiled that with gcc
gcc -c boot.S -o ks.o

My kernel.c file is the same as in the tutorial so
gcc -c kernel.c -o kernel.o

I then use the tutorials linker script and go
ld -T link.ld -o kernel.bin ks.o kernel.o

I now have a kernel.bin file of about 20k or so

I downloaded the grub_disk.img file that has grub installed on it. I then prepared this as /dev/loop0 and mounted it under /mnt/temp
browsing into temp I can see the dir /boot. I copy my kernel.bin file into /mnt/temp/boot, unmount the image

I then setup Bochs and pointed its floppya and my image file,
it boots grub fine but when I select 'My Kernel' from the list it attempts to load but generates a

Error 13: Invalid or unsupported executable format

Is there something wrong that I am doing above or is there something else I need to do? I am assuming grub puts the computer into protected mode etc.. etc..

Thanks for any help

Re:Grub - Error 13 - Invalid or unsupported executable forma

Posted: Wed Feb 25, 2004 3:13 am
by bubach
Comments on the article:
Retro:
when i use the command "ld -T link.ld -o kernel.bin ks.o kernel.o" it keep getting the error message "ks.0: file not recongnized: File format not recognized" ne1 know what i'm doing wrong and sort it?
Pype:
@retro & friends:
it looks like your version of LD does not support A.OUT files. Either try "-f coff" instead of "-f aout" (for DjGpp) or "-f elf" (for Linux)
Maybe this helps?

/ Christoffer

Re:Grub - Error 13 - Invalid or unsupported executable forma

Posted: Wed Feb 25, 2004 5:19 am
by gommo
I'm using gcc to compile both my boot.S and kernel.c. What does gcc compile to by default? Or is it LD that I need to specificy the aout or elf file? I'm assuming gcc defaults to elf? but maybe not?

Re:Grub - Error 13 - Invalid or unsupported executable forma

Posted: Wed Feb 25, 2004 7:07 am
by bubach
i don?t use C for os dev so i don?t know... u will have to test.. :-P

Re:Grub - Error 13 - Invalid or unsupported executable forma

Posted: Wed Feb 25, 2004 7:53 am
by Pype.Clicker
gcc generates a .S file which it passes to AS ... so it's up to AS and LD to know what binary format you use, not 'GCC' (the compiler) itself... iirc, there is a switch to pass options directly to the linker (it might be -D .... i should RTFM again) and a similar one to pass options to the assembler ...

If it sounds confusing, remind that gcc plays both the role of the front-end *and* the compiler ...

Re:Grub - Error 13 - Invalid or unsupported executable forma

Posted: Wed Feb 25, 2004 12:21 pm
by Therx
You need the multiboot header for grub and if you use the aout features then it can load basically any format

Pete

Re:Grub - Error 13 - Invalid or unsupported executable forma

Posted: Wed Feb 25, 2004 5:10 pm
by gommo
Yep, thanks all.

I went away from using grubs boot.S and did my own kernel starting asm file. Then I used NASM with the -f aout option and it works now.

However, I'm using Bochs and it seems to run although the screen doesn't show anything on it.

Could this be because the machine is being halted (hlt)??