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?
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With