There are different phases through which our
program passes before being transformed into an executable form. The following
figure shows these phases –
Let us take one example program : onsettechie.c
Preprocessor:
The
source code is the code that we write using any text editor and the source code
file is given an extension ‘.c’. This source code is firstly passed through the
preprocessor. The preprocessor expands this code and passes it to the compiler.
gcc -E onsettechie.c -o onsettechie.i
Compiler :
The
expanded code is passed to the compiler. The compiler converts this code into
machine’s assembly language code.
gcc -S onsettechie.i -o onsettechie.s
Assembler:
This
assembly language code is converted to object code by the system’s assembler. The
name of the object file is same as that of source file. The extension in UNIX
is ‘.o’.
gcc -c onsettechie.s -o onsettechie.o
Linker:
All
programs written in C, use library functions. Library functions are precompiled
and their object code is stored in library files with ‘.lib’ ( or ‘.a’)
extension. The linker combines both the object code of library functions with
the object code of our program. The output of the linker is executable file. In
UNIX name is a.out or other name with -o option.
gcc -E onsettechie.o -o onsettechie
Here you get little bit confusion go forward then you understand about about all these files.
onsettechie.c is source code.
onsettechie.i is expanded code.
onsettechie.s is Assembly code.
onsettechie.o is Object code.
onsettechie is binary executable.
you can these codes by using Vim editor.
you can these codes by using Vim editor.

1 comments:
commentsgreat !!!
Reply