Page 1 of 1

Is it possible for GCC linker to make .asm as final output?

Posted: Wed Sep 19, 2012 2:35 am
by RajivKumarSrivastav
Hi all,
I have .c source files and .S source files. i compiled .c sources like below to generate .asm file.

Code: Select all

gcc -O3 -c -nostdinc -o file1.asm -S file1.c
gcc -O3 -c -nostdinc -o file2.asm -S file2.c

// compiled .S files to generate .o 
g cc -O3 -c -nostdinc -o file3.o file3.S
Now i want to link file1.asm, file2.asm and file3.o together to build 'target.asm' as final output.
Is it possible to use GCC here and make final output file as .asm?
Though, i have been Googling to to find the answer :( .
Thanks in advance for your help !!

Re: Is it possible for GCC linker to make .asm as final outp

Posted: Wed Sep 19, 2012 3:30 am
by bluemoon
How about cat file1.asm file2.asm file3.asm > target.asm (Unless some symbols conflicts, in that case do some /string/replace/)

Re: Is it possible for GCC linker to make .asm as final outp

Posted: Wed Sep 19, 2012 3:45 am
by RajivKumarSrivastav
i want all of them to be linked to produce single output 'target.asm', so 'cat' will not help.

Re: Is it possible for GCC linker to make .asm as final outp

Posted: Wed Sep 19, 2012 4:28 am
by bluemoon
I see, and we have different concept for link.

Re: Is it possible for GCC linker to make .asm as final outp

Posted: Wed Sep 19, 2012 9:56 am
by JamesM
rajiv123 wrote:i want all of them to be linked to produce single output 'target.asm', so 'cat' will not help.
A linker operates on machine code. It takes things known only at link time (symbol addresses, for example) and places them in the right place in the machine code, as well as doing some layout.

So, a linker on textual assembly does not make sense. Textual assembly refers to symbols by name, not by address.

Re: Is it possible for GCC linker to make .asm as final outp

Posted: Wed Sep 19, 2012 1:03 pm
by RajivKumarSrivastav
Thanks JamesM for the reply.

So finally i should assume that, it is not possible to use GCC to link these .asm & .o files?

Re: Is it possible for GCC linker to make .asm as final outp

Posted: Wed Sep 19, 2012 2:09 pm
by JamesM
rajiv123 wrote:Thanks JamesM for the reply.

So finally i should assume that, it is not possible to use GCC to link these .asm & .o files?
No, you should read what I took the time to write and learn how your tools work.

Re: Is it possible for GCC linker to make .asm as final outp

Posted: Wed Sep 19, 2012 2:50 pm
by iansjack
You can't link assembler source files to object files; it just doesn't make sense. As already suggested, you need to learn the basics - this is not the correct forum to do so.