first of all
, we create a file with touch command with extension .c
eg—hello.c
before the compilation ,it supply to the pre-processor...
pre-processor
create a file hello.i
=hello.i contain
stdi.h
prog.c
=stdi.h linked to
header file and it caontains all the header file which is need to our code.
= prog.c is our
code part
now it supply
to our cumplier which is called (2 pass compiler ) because it
complier check our code two times..
A
compiler has five stages..
when all the
stages complete then it generate a source code called “hello.s”
hello.s
contains..
symbol table =>symbol table
contains....deceleration and definition of the code
data
code
then
it supply down to the assembler ==> the work of the assembler is
to convert the code assembly language to machine level language..
A
assembler contains ....
symbol
table
data
code
links
==> it links to gnu g library
assembler contains linked to linker
linker
is responsible to link the rest of the code to library....
=>and generate a.out [which is executable linkeble formate]
=>and
these code stored in secondary memory
NOTE-we
can store the code in secondary memory but we cannot run here..
to
run the code it as to bought from secondary memory to memory with
help of loader
when
loader load the code in memory then a
stack
segment---------> it store local variable
file
discripter = which is connected to a connector
0
for std. Input
1
for std.output
2
for std. Error
0,1
and 2 all are connected to std. Input ,output .eroor through channel.
data
segment
code
segment
data
segment contains...
global variable
static
variable
register
volatile
constant
pre-processor directories
task
statement contains
p
id
pc
etc.
We create a c program file “hello.c”.
for compilation of hello.c file we use gcc .
If we need hello.i file then use gcc -i
And for hello.s file use gcc -s.
the phases of compilation is :-
1. Lexical Analysis.
2.Syntax Analysis.
3.Intermediate code generator.
4.code optimization.
5.object code creater.
The phases of compiler creates a hello.s file and goto the assembler.Assembler creates hello.o files and hello.o files goto the linker,hello.o fies generate links to the libraries.
Linker creates a ELF files that is executable files(a.out).
Process context :-
stack segments(it store local variables).
File Discriptors:-file discriptor contains the value 0,1,2.
0 take the input .
1 gives the output.
2 gives error.
It looks like you're new here. If you want to get involved, click one of these buttons!