Understanding the GCC compiler

Chebbi Mounir
2 min readSep 17, 2020


The official GCC logo

The GCC compiler ( gcc stands for GNU Compiler Collection ), is one of the most used compiler systems in the world and played an important role in the growth of free software basically for being under the GNU General Public License (GNU GPL).

What is a compiler?

The compiler is a peace of software that translates computer code written in one programming language into another language.

How is GCC doing it?

* Preprocessing:

The compiler runs on each C source file before actual compilation, it

1- Removes Comments

2 -Expands Macros

3- Expands of the files included to the source code

The output will be a processed .c file sent to the standard output.

( ps: Input files that don’t require preprocessing are ignored.)

The -E flag stops “gcc” after the preprocessing stage; and before runing the compiler proper.

the preprocessed file of a simple printf(“Hello world!”) programm

* Compilation:

The compiler “translates” the preprocessed .c file from the “C” language to the Assembly code language (symbolic machine code),

The -S flag stops “gcc” after the stage of compilation proper, and the output will be in the form of an assembler code file.

The content of helloworld.s

* Assembly:

The compiler assemble the source files, but do not link and The ultimate output is in the form of an object file (.o) containing object code, that is, machine code.

The -c flag stops “gcc” after the stage of assembling.

* Linking:

The compiler operates the final phase in which all the linking of function calls with their definitions are made.

The final output will be an executable file with 755 permissions.