Q : How Compilation, Linking and Loading are related? Also explain the basic task of a Compiler, Linker and Loader?
First step in compilation hierarchy is start with process preprocessor directory start with # symbol before get actual compilation get start.
In second step user defined code (Source Code) and output generated from preprocessor directory. Combine them and generate assembler source code.
Step 3It takes the assembly source code and produces an assembly listing with offsets. The assembler output is stored in an object file.
Step 4It takes one or more object files or libraries as input and combines them to produce a single (usually executable) file. In doing so, it resolves references to external symbols, assigns final addresses to procedures/functions and variables, and revises code and data to reflect new addresses (a process called relocation).
Compilation is a process in which a program written in C language get translated into Machine language. If there is some errors, the compiler will detect them and report it.
In process of compilation steps compiler change source code into its equivalent assembly code If these piece of code needs some other source file to be linked, linker link them to make it a executable file.
It loads the executable code into memory; program and data stack are created, register gets initialized.