Reputation: 1490
How does a compiler generate binary code to a separate file? A reference to what file(s) in the source code of GCC handle this would be of great help. What I want to know is how exactly do compilers (gcc in particular) generate machine code from ASM?
Upvotes: 2
Views: 590
Reputation: 2347
To answer this question one would need books, not just a few lines.
The extremely short version is:
A compiler is divided in 2 parts:
a Front-end that translates a specific language (like C) into a syntax-tree (generic way to represent a program)
and a Back-end which translates the syntax-tree into machine specific (X86, ARM, ...) code.
There are several steps involved:
Googling around can give you more detailed info.
Upvotes: 9
Reputation: 64308
The assembler is a separate utility. You can find more information here: http://en.wikipedia.org/wiki/GNU_Assembler
The source code is part of the binutils package. You can find it here: ftp://ftp.gnu.org/gnu/binutils/
Upvotes: 6