Any c file, a user wants to compile is not directly compiled. For example, there is c file having a name hello.c, this hello.c file is not directly provided to the compiler. Hello.c file first of all provided to the gcc preprocessor , this preprocessor converts this hello.c file into hello.i file. This hello.i file consists of two file stdio.h and hello.c file. The combination these two files together makes a new file which is hello.c file . This hello.c file is provided to the gcc compiler. The gcc compiler is basically a two pass compiler which passes file two times . Then the file moves to the lexical analysis ,this lexical analysis breaks the content of file into tokens , then the tokens are provided to the syntax analysis which analysis all the tokens of file according to the c format ,this analysis gave us an errors ,saying that tokens used are appropriate or not .After the analysis process, file passes through the intermediate code generation, code optimization and object code generation. After the 2-pass compilation process, the format of file changes into different format which is in hello.s format .The output of the compiler is provided to the assembly, which is in the format of hello.s file. This hello.s file through assembly passes to the assembler. Assembler converts this hello.s file into hello.o file. This hello.o file passes through the symbol table, data segment and code segment process . After passing through these processes, file is provided to linker .The output of linker generates a new file named as a.out file which is in executable format. This executable file is then provided to the executable linkable format (elf), data segment and code segment.
After this whole process loader loads the file into the RAM. File spreads out in the ram. Ram is basically a process context (virtual address space content ) which consists of stack segment, file descripter, data segment and code segment. Stack segment consists of local variable of the file. File descripter consists of three ports 0,1,2 . These three ports are connected to the standard input, standard output and standard error respectively via stream. Stream is used for moving data wheather for input, output or for error. Standard input is used for entering the data to the port 0. standard output takes out the data from port 1. And standard error is to takes out the error from port 2. Data segment consists of various variables like global variable, static variable, extreme variable, register variable, volatile variable, constant variable, macros variable and preprocessor directive. Code segment consists of compiled code. Stack segment, file directive, data segment and code segment all these have some logical addresses.