Using an assembly file as kernel image

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
dkandula
Posts: 1
Joined: Tue Mar 15, 2011 3:15 pm

Using an assembly file as kernel image

Post 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
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Using an assembly file as kernel image

Post 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.
Post Reply