Compiler Assembler Linker Loader
Compiler Assembler Linker Loader
Learning Outcomes:
1. After learning this topic you should be able to tell the functions of
assembler, compiler, linker, loader.
2. You would be able to know what happens behind the scene when you
compile a program.
3. How is the output coming after compilation.
When you type cc at the command line a lot of stuff happens. There are
four entities involved in the compilation process: preprocessor, compiler,
assembler, linker (see Figure).
Linker: In high level languages, some built in header files or libraries are
stored. These libraries are predefined and these contain basic functions
which are essential for executing the program. These functions are linked to
the libraries by a program called Linker. If linker does not find a library of a
function then it informs to compiler and then compiler generates an error.
The compiler automatically invokes the linker as the last step in compiling a
program.
Not built in libraries, it also links the user defined functions to
the user defined libraries. Usually a longer program is divided into smaller
subprograms called modules. And these modules must be combined to
execute the program. The process of combining the modules is done by the
linker.
Loader: Loader is a program that loads machine codes of a program into the
system memory. In Computing, a loader is the part of an Operating
System that is responsible for loading programs. It is one of the essential
stages in the process of starting a program. Because it places programs into
memory and prepares them for execution. Loading a program involves
reading the contents of executable file into memory. Once loading is
complete, the operating system starts the program by passing control to the
loaded program code. All operating systems that support program loading
have loaders. In many operating systems the loader is permanently resident
in memory.