C Compilation Steps | C Programming and Computer Geeks

Search MY Blog

Monday, 10 June 2013

C Compilation Steps

C Compilation Steps


The above diagram shows the C Compilation steps.
STEP 1: Preprocessor
The main function of the C preprocessor is to remove comments from the source code and
interpret preprocessor directives which are given by the statements that begin with #. the preprocessor would strip the source of the comments contained
within the /*...*/ and would include the files assossiated with #include statement
and finally generates hello.i file

STEP 2:Compiler
Once the C preprocessor has stripped the source code of the comments and expanded the
preprocessor directives given by the lines that begin with # , the compiler translates the C
code into assembly language, which is a machine level code that contains instructions that
manipulate the memory and processor directly, in a layer beneath the operating system.
compiler is directly responsible for converting C syntax into this machine level code.
 And finally generates  hello.s 

STEP 3:Assembler
converts the machine-level instructions into binary code.
Assembler generates the objective file hello.o
The object file hello.o contains a binary version of the machine language

STEP 4:Linker/Link Editor
If a source file references library functions or functions defined in other source files the link editor combines these functions (with main()) to create an executable file. External Variable references resolved here also. 
means it will includes all the libraries,other Object files/Modules.

STEP 5: Loader
Makes use of binary format interpreter and process executable file header,it also determines the sizeof exe image.

coordinates with virtual memory subsystem and allocates Virtual memory address space required to load the program image.

Copies the exe image to virtual memory space allocated.

invokes process management sub system to process the registration of the exe.

Process management subsystem allocates a process control block(PCB) object and register a process

PCBs are linked up for CPU time from Scheduler.

A process once acquire CPU slice will start execution.


1 comment:

Search This Blog