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.
Can't see you indicating a binary format anywhere, so it's probably a COFF file. I expect them to be page aligned, so the first 0x1000 bytes are probably the header.
Candy wrote:
You should be able to figure out a solution now
Do I need to use ELF as my object file format?But I don't know much about ELF.
If I use binary format,is it still OK to use .text .data .bss?
Still no solution....
Ok... a little more background:
Object files are compiled from source to a relocatable format (such as ELF, COFF, A.OUT and PE for example. There are more.). These relocatable objects are then linked to a single relocatable object (ld -r, or in the final linking step, in the memory of the linker). It then "finalizes" the link by fixing it up so it can be executed. At this time, it decides the format of the output and creates it accordingly.
You will want to use a relocatable format for the objects, you are already using one (I guess you're using COFF for that. That's ok.). You need to specify what needs to come out of the last link step in the linker file, and since you want a flat binary file (with no header), tell it to make a binary file. It will fix up all links, disallow shared libraries and so on.