Getting error in Hellow World Kernel: Error 13: Invalid or unsupported executable for
I was trying to make a hello world kernel as follows:
kernel.asm Code:
;States that the code is a 32 bit code nasm -f aout kernel.asm -o kernel_a.o It worked fine. Then I wrote this file: kernel.h Code:
#ifndef _KERNEL_H_ Code:
#include "kernel.h" gcc -c kernel.c Then I linked the both the .o files: ld kernel.o kernel_a.o -o kernel.bin Then I copied this to /boot folder and created a new entry in GRUB as follows along with existing one: title Fedora Core 1 (2.4.22-1.2115.nptl) root (hd0,6) kernel /vmlinuz-2.4.22-1.2115.nptl ro root=LABEL=/ hdc=ide-scsi rhgb initrd /initrd-2.4.22-1.2115.nptl.img title Windows XP Professional SP2 rootnoverify (hd0,0) chainloader +1 title My Kernel root (hd0,6) kernel /vmlinuz.mykernel and I booted the kernel with My Kernel. At that time it gave me the error as: Error 13: Invalid or unsupported executable format I am not able to get, why this error is coming. I also tried searching but could not get much info. Please assist. |
I'm pretty sure when compiling a kernel you need special compilation options for gcc. This is because normal executables don't directly access the hardware; they are interpreted through the kernel. It has to be compiled as something that can run the machine itself. I don't know exactly how to do this, however. I've never written a kernel, but I know even modules can't be compiled like normal ELF programs.
ta0kira |
Actually doing this was what prompted me to try and start learning assembly. Yes T is correct you need to compile the c program with special gcc stuff so that it does not link to standard library.
Below is from a online resource regarding this its actually a very good resource. Code:
gcc -Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I./include -c -o main.o main.c Got from http://www.osdever.net/bkerndev/index.php |
Hmmm, OK I will go through the website and will try. Thanks for the info.
|
All times are GMT -5. The time now is 01:37 PM. |