How can I use GCC to Compile Flat Binary files (*.c, *.cpp)
How can I use GCC to Compile Flat Binary files (*.c, *.cpp)
ok... I am very new to OSdev and I was wondering how to get a simple *.cpp or *.c file compiled to a flat binary file for my bootloader to run at startup.. I have very little experience with C and CPP, but i have been programming in ASM for several months now. thx in advance
RE:How can I use GCC to Compile Flat Binary files (*.c, *.cp
compile all your c-code like this:
gcc -c -o a.o a.c
gcc -c -o b.o b.c
you'll get a bunch of object files. link those together using ld:
ld --oformat binary -Ttext 0x100000 -o mykernel.bin a.o b.o
this instructs ld to create a flat binary file called mykernel.bin that has to be loaded at 1 MB. if you prefer a different loading address, change the value after Ttext.
gcc -c -o a.o a.c
gcc -c -o b.o b.c
you'll get a bunch of object files. link those together using ld:
ld --oformat binary -Ttext 0x100000 -o mykernel.bin a.o b.o
this instructs ld to create a flat binary file called mykernel.bin that has to be loaded at 1 MB. if you prefer a different loading address, change the value after Ttext.
RE:How can I use GCC to Compile Flat Binary files (*.c, *.cp
You could also add -e <function_name> to add an entry point to your new binary.