gcc

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
Whatever5k

gcc

Post by Whatever5k »

Do I have to compile my kernel normally like
gcc -o kernel.bin kernel.c
I heard, that some people use
gcc -ffreestanding -o kernel.bin kernel.c
Does it make a difference and if yes, which?
K.J.

Re: gcc

Post by K.J. »

Actually, output it as a COFF file like this:

gcc -c kernel.c

You should find a file named kernel.o in the directory where kernel.c was. Now like the kernel.o to a binary with LD like this:

ld --oformat binary kernel.o

You should now find a file name a.out in the directory where kernel.c was. Rename a.out to kernel.bin and there you(should) have it!

K.J.
jkliff

Re: gcc

Post by jkliff »

Hi, I am new to the board. I am just in the process of learning where to begin to code an Operating System (which will, for sure, take a few months more).
Well, I heard about the -ffreestanding option on gcc meaning something like 'generates code to run without an operating system'. I also have seen that ld should link to 0x1000000 (perhaps there's a 0 more or less :P) and now I see here something different. What is correct/wrong and why?

Thanks,
John
The Legend

Re: gcc

Post by The Legend »

You need to specify an entry point for your kernel, this is the
option with the 0x10000. Note that it shouldn't be 0x0!!! Some structures are in the memory range in between (64 kb)!
Post Reply