Page 1 of 1

Using an assembly file as kernel image

Posted: Tue Mar 15, 2011 3:25 pm
by dkandula
Hi All,
First of all thanks for all the links provided on OSDev.org. I am trying to write my own OS and hence want to initially just print a string to the screen. I am using GRUB as my bootloader. I have a .S file which is my assembly script to just print a string to the console continuously.

I used the following command to get .o file.

gcc -c Kernel.S

Then the following ld command.

ld Kernel.o -o kernel.bin --oformat=binary -Ttext=0x100000

Hence I get a .bin image now. What do I need to do now to make this .bin image bootable. I tried booting with this image but got the following error.

Error 13: Invalid or unsupported executable format.

I can directly load my computer with a good kernel image as it is a spare system that I am using. I dont want to use the QEMU/BOCHS that is mentioned on the website.

Hope I have provided all the required details.

Thanks in advance

Dheeraj

Re: Using an assembly file as kernel image

Posted: Tue Mar 15, 2011 3:38 pm
by Tosi
I would highly not recommend using a flat binary file, especially if you intend to have a higher-half kernel.

But if you want to get this to boot, it's not difficult since you're using GRUB. Just add a multiboot header with the AOUT kludge and it should be fine. Remember that the header needs to be 4-byte aligned.