best selling and shopping at eBay
Let's Take Example Of C Language..
It has 4 Stages..
(In gcc, it is the 'gcc -E' stage).Here, The Preprocessor replaces the #include files, include guards, #define (macros), etc with code.
(In gcc, It is the 'gcc -c' stage) Turns code (after preprocessor is done with it) from human understandable text to "machine code".
Basically, into assembly language (creates .o files for instance).
To be noted here is that the .o files so created still have textual symbols in them, not actual memory addresses.
Compilation itself has many sub-stages ( http://www.programcreek.com/2011/02/how-compiler-works/ ):
(in gcc,It is gcc -o stage) Turns the files produced from Compilation stage (object files like .o, .so files, etc) into actual executables (a.out, or a.exe).
This is where two things happen:
The Executable needs to be "built" into a format that the OS will understand. Whatever the compiler
hands off to the linker needs to be laid out into the executable's data segment (holds program data),
text segment (holds program code), heap (holds dynamically allocated memory through malloc, calloc, etc),
stack (holds program stacks - return addresses for functions called), etc.
B. Symbol resolution:
The symbols generated from step 2, are actually resolved into addresses here. These are not actual
physical addresses in memory; these are some "temp" addresses. Resolving them into actual addresses in
memory is a job that is done by the operating system's memory manager.
4. Runtime: The runtime loads the dynamically loaded dlls (dynamic link libraries) as needed for the executable so generated, resolves shared dependencies, etc.