Aymen Malakian
3 min readJun 10, 2020

--

All the steps in a compilation procees

the sequance of task that gcc do all times to make our codes work fine as a great programs ;)

The gcc compiler

As everybody knows the famous gcc compiler that make source code working as a an executable program

so what if we take a look inside the operations and tasks that this compiler do ?

Making programs start from an idea in mind of someone that want to transfer this idea into an automatic operations managed by the computer , so coder’s start transform this idea using a programming language

after they finish doing their codes and writing what they need they move to very important task

how make their codes work ?

here we need a compiler an eficent program that do our job

the gcc (GNU Compiler Collection ps: gnu C compiler as the old name of program)

have 4 essencials steps

1- PREPROCESSOR :

the first thing compiler do is to take a code written by a humain and remove comments and implements the macro language used to transform C, C++, and Objective-C programs before they are compiled. It can also be useful on its own.

the command to use gcc in just this level without moving forward is gcc -E

2- COMPILER :

compiler, translates high-level (humain) language into low-level machine language. The difference lies in the way they read the source code or input. A compiler reads the whole source code at once, creates tokens, checks semantics, generates intermediate code, executes the whole program and may involve many passes. In contrast, an interpreter reads a statement from the input, converts it to an intermediate code, executes it, then takes the next statement in sequence. If an error occurs, an interpreter stops execution and reports it. whereas a compiler reads the whole program even if it encounters several errors.

the command to use gcc in just this level without moving forward is gcc -c

3-ASSEMBLER

An assembler translates assembly language programs into machine code.The output of an assembler is called an object file, which contains a combination of machine instructions as well as the data required to place these instructions in memory.

in this phase of sequence of our program compiler the assembler have as final output a binary code who is ready to move to the next step

the command to use gcc in just this level without moving forward is gcc -S

4-LINKER

Linker is a computer program that links and merges various object files together in order to make an executable file. All these files might have been compiled by separate assemblers. The major task of a linker is to search and locate referenced module/routines in a program and to determine the memory location where these codes will be loaded, making the program instruction to have absolute references.

All those steps are necessary to have as a final result an executable file (program) ready to use .

--

--

Aymen Malakian

Junior Blockchain developer, passionate about P2P Decentralized Networks and System programming & Algorithms.