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.
Bringing the program from secondary memory to main memory is called Loading.
Establishing the linking between all the modules or all the functions of the program in order to continue the program execution is called linking.
Differences between Linking and Loading:
- The key difference between linking and loading is that the linking generates the executable file of a program whereas, the loading loads the executable file obtained from the linking into main memory for execution.
- The linking intakes the object module of a program generated by the assembler. However, the loading intakes the executable module generated by the linking.
- The linking combines all object modules of a program to generate executable modules it also links the library function in the object module to built-in libraries of the high-level programming language. On the other hand, loading allocates space to an executable module in main memory.
Loading and Linking are further categorized into 2 types:
|Loading the entire program into the main memory before start of the program execution is called as static loading.||Loading the program into the main memory on demand is called as dynamic loading.|
|Inefficent utilization of memory because whether it is required or not required entire program is brought into the main memory.||Efficent utilization of memory.|
|Program execution will be faster.||Program execution will be slower.|
|Statically linked program takes constant load time every time it is loaded into the memory for execution.||Dynamic linking is performed at run time by the operating system.|
|If the static loading is used then accordingly static linking is applied.||If the dynamic loading is used then accordingly dynamic linking is applied.|
|Static linking is performed by programs called linkers as the last step in compiling a program. Linkers are also called link editors.||In dynamic linking this is not the case and individual shared modules can be updated and recompiled.This is one of the greatest advantages dynamic linking offers.|
|In static linking if any of the external programs has changed then they have to be recompiled and re-linked again else the changes won’t reflect in existing executable file.||In dynamic linking load time might be reduced if the shared library code is already present in memory.|
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.