
This kind of thing is done by Linux, FreeBSD, etc. in building their
kernels.
First, produce your object files using gcc. Remember - you can`t
use normal C library functions, so you will need to define every
symbol you use.
Then use something like:
ld -Ttext <addr> -o <whatever> <objects>
to link your object files together, where <addr> is the hexadecimal
origin of the text segment (i.e. the address at which the code will
eventually get loaded). This does the "absolute" part.
(Assuming the entry point is the same as the address at which the
binary gets loaded, the first object file on the ld line will hold
your entry code.)
Finally, produce a plain binary using objcopy (which is included, with
GNU ld, in GNU binutils):
objcopy -O binary -R .note -R .comment -S <whatever> <outfile>
"-O binary" says to output in plain binary format. "-R .note -R
..comment" removes some unimportant sections produced by gcc (at least
for ELF, and probably for other object file formats that allow
arbitrary sections). "-S" strips out the symbol information.
<outfile> is your binary.
Look at the ld and objcopy man pages for more details.
Dave Wragg