Monday, 25 September 2017

Compilation Process c Language

Q : How Compilation, Linking and Loading are related? Also explain the basic task of a Compiler, Linker and Loader?

Solution : 

First of all we need to understand relationship between compilation, linker and linker form following compilation steps.

Compilation Process C Language

Step 1

First step in compilation hierarchy is start with process preprocessor directory start with # symbol before get actual compilation get start.

Step 2

In second step user defined code (Source Code) and output generated from preprocessor directory. Combine them and generate assembler source code.

Step 3

It takes the assembly source code and produces an assembly listing with offsets. The assembler output is stored in an object file.

Step 4

It takes one or more object files or libraries as input and combines them to produce a single (usually executable) file. In doing so, it resolves references to external symbols, assigns final addresses to procedures/functions and variables, and revises code and data to reflect new addresses (a process called relocation).

Compilation :-

 Compilation is a process in which a program written in C language get translated into Machine  language. If there is some errors, the compiler will detect them and report it.


 In process of compilation steps compiler change source code into its equivalent assembly code If these piece of code needs some other source file to be linked, linker link them to make it a executable file.


It loads the executable code into memory; program and data stack are created, register gets initialized.