Difference between Loading and Linking

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.





Differences between Linking and Loading:

  1. 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.
  2. The linking intakes the object module of a program generated by the assembler. However, the loading intakes the executable module generated by the linking.
  3. 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:

Static Dynamic
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 static 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.



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.