Hi
This post is regarding
"How to use C in a boot loader " in the post http://www.brokenthorn.com/Resources/OSDev0.html.
It is said in the first part that we can have C code along with a stub of assembly in a single file.
But my question is, when the above C code (in the single file along with the stub of assembly) is compiled it will generate object code in elf format (gcc), but we want a flat binary file for bootloader.
In that case how our objective is fullfilled.
Can the author throw more light on this?
I have seen a bootloader (from utexas cs395t course) with two files one an assembly file and other a C file. The assembly file starts and calls the C code. I am not understanding how one get flat binary in this case while compiling the above two files(in linux gcc environment).
bootloader
Moderator:Moderators
Re: bootloader
For gcc, you need to:
1) compile the c file to an object file (.o)
2) assemble the asm file to an object file (.o)
3) use ld to link the two object files into a single binary.
In your linker script, specify that the output format should be binary rather than elf.
see http://wiki.osdev.org/Bare_bones for a tutorial on how to set this up
~Andrew
1) compile the c file to an object file (.o)
2) assemble the asm file to an object file (.o)
3) use ld to link the two object files into a single binary.
In your linker script, specify that the output format should be binary rather than elf.
see http://wiki.osdev.org/Bare_bones for a tutorial on how to set this up
~Andrew

Re: bootloader
praveen wrote:Hi
This post is regarding
"How to use C in a boot loader " in the post http://www.brokenthorn.com/Resources/OSDev0.html.
I have seen a bootloader (from utexas cs395t course) with two files one an assembly file and other a C file. The assembly file starts and calls the C code. I am not understanding how one get flat binary in this case while compiling the above two files(in linux gcc environment).
When the above two bootloader files are compiled and linked, it said that the bootloader size is 414 bytes. But none of those files took care of boot signature to be placed at bytes 511 and 512.
Is it that there are other means of putting the bootsignature at those bytes using loader/linker instead of taking care of it in the bootloader code (the assembly file and the c file)?