Loading and Linking in Os
Loading and Linking in Os
Linking and Loading are the utility programs that play a important role in the execution of a
program. Linking intakes the object codes generated by the assembler and combines them to
generate the executable module. On the other hand, the loading loads this executable module
to the main memory for execution.
Loading:
Bringing the program from secondary memory to main memory is called Loading.
Linking:
Establishing the linking between all the modules or all the functions of the program in order to
continue the program execution is called linking.
If the static loading is used then accordingly If the dynamic loading is used then accordingly
static linking is applied. dynamic linking is applied.
Dynamic Linking:
Every dynamically linked program contains a small, statically linked function that is called
when the program starts. This static function only maps the link library into memory and runs
the code that the function contains. The link library determines what are all the dynamic
libraries which the program requires along with the names of the variables and functions
needed from those libraries by reading the information contained in sections of the library.
After which it maps the libraries into the middle of virtual memory and resolves the references
to the symbols contained in those libraries. We don’t know where in the memory these shared
libraries are actually mapped: They are compiled into position-independent code (PIC), that
can run at any address in memory.
Advantage:
Memory requirements of the program are reduced. A DLL is loaded into memory only once,
whereas more than one application may use a single DLL at the moment, thus saving memory
space. Application support and maintenance costs are also lowered.