Since I am new to binutils, gcc ant others, I have some general questions that I have not found in the manuals.
I use C and assembly (nasm syntax) and I need the source binaries in the output. First of all, I compile my code into an objec file with parameters:
cc -nostartfiles -nostdlib -c -ffreestanding <input file(s)> ;cc or gcc no matter
Then I link all the files with a simple script that only puts the segments in the right order.
ld -T <script> -o <o.file> <in.file(s)> ;nothing special here
And to get the raw binary I use objcopy
objcopy -O binary <o.file> <in.file> ;can't be simplier
In general, I only need a binary file with .text and .data segments in it and 32-bit code.
1. Can I get this way what I want?
2. Are there other ways to do this? (it doesn't matter if it's easier or harder)
Thank you for your help.
I have no problems compiling ASM code, almost all problems with C code.
hrust source share