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

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.
Post Reply
RajivKumarSrivastav
Member
Member
Posts: 26
Joined: Wed Sep 28, 2011 6:46 am
Location: Bangalore - India

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

Post 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 !!
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

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

Post by bluemoon »

How about cat file1.asm file2.asm file3.asm > target.asm (Unless some symbols conflicts, in that case do some /string/replace/)
RajivKumarSrivastav
Member
Member
Posts: 26
Joined: Wed Sep 28, 2011 6:46 am
Location: Bangalore - India

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

Post by RajivKumarSrivastav »

i want all of them to be linked to produce single output 'target.asm', so 'cat' will not help.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

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

Post by bluemoon »

I see, and we have different concept for link.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

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

Post 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.
RajivKumarSrivastav
Member
Member
Posts: 26
Joined: Wed Sep 28, 2011 6:46 am
Location: Bangalore - India

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

Post 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?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

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

Post 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.
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

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

Post 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.
Post Reply