Pages1

Stepwise explanation of a “C” Program compilation till execution


C Program Compilation process involving Assembler, Linker, Loader; Pic is taken from www







Role of Compiler:  Preprocessing and translation of "middle level language C" into assembly language of respective target.



Role of Assembler: Converts Assembly language to Object file.
Assembler in detail:  
- Performs translation of assembly instruction into machine language. Converts data supplied by programmer in binary. Assembler make two pass over Assembly files;
First pass     -  Reads line by line and records Labels in symbol table.
Second Pass - Uses Information obtained in first pass and produces actual machine code of each line.

What is object file:
An object file is a file having code meaning relocatable format machine code. The object file code usually not directly executable. Object files are produced by an assembler, compiler, or other language translator, and used as input to the linker, which in turn typically generates an executable or library by combining parts of object files
  
Role of Linker: Links all the object files to form an executable.
it Mainly perform three steps:
- Search for library routine used by program e.g fprintf()...
- Resolves references among files
- Determines memory locations that code from each module will occupy and relocates instruction by adjusting absolute references.

Role of Loader: Part of OS that brings executable file in to main memory from disk to start execution.

No comments:

Post a Comment