Loader and Linker in Operating system

Loader and Linker in Operating system

Since PCs, linkers and loaders have been essential for the programming toolbox since they are key apparatuses that permit to assemble of programs from modules instead of a huge stone monument. As right on time as 1947, software engineers started to utilize the first loader, which can blend program schedules put away on discrete tapes, and afterwards migrate them into a solitary program. By the mid-1960s, these uploaders had developed to 4,444 full connection editors. Since program memory is yet costly and restricted, and PCs (as per current principles) are slower, these linkers contain complex capacities that can make complex memory overlay structures to get huge projects into little memory and remake them. Alter the recently connected program to save the time needed to modify the program without any preparation.

During the 1970s and 1980s, there was little advancement in interface innovation. The linker will in general be less difficult, the virtual memory moves more from applications and overlays, the capacity the executive to the working framework is a long way from working, and as the PC gets quicker, the plate is bigger, it becomes simpler to make a connection without any preparation The program replaces a few modules as opposed to connecting just the changes. During the 1990s, the connector got more intricate once more, adding present day highlights, including dynamic connecting of shared libraries, and backing for uncommon C ++ needs. Broad guidance words and compiler-modified memory access, for example, the new Intel IA64 processor engineering, will likewise be supplanted with new connector necessities to guarantee that perplexing code restricting system prerequisites are met.

 Loader: A loader is an operating system component that is in charge of loading programmes and libraries. Because it loads programmes into memory and prepares them for execution, it is one of the most critical phases in the process of beginning a programme. Reading the contents of the executable file containing the programme instructions into memory and then executing the programme is what loading a programme entails.

All operating systems that support programme loading have loaders, with the exception of very specialised computer systems that only have a limited collection of specific programmes. Embedded systems do not usually have loaders, thus the code is read directly from ROM or something similar.

Loader Functions:

The loader oversees activities such as allocation, linking, relocation, and loading.

1) It calculates the size of the programme and allocates memory space for it. This is referred to as allocation.

2) It assigns addresses to all user and library subroutines, resolving symbolic references (code/data) between object modules. This is referred to as connecting.

3) There are some address dependent locations in the programme; such address constants must be updated according to allocated space; this activity is known as relocation and is performed by the loader.

4) Finally, it loads all the machine instructions and data from the corresponding programmes and subroutines into memory. As a result, the programme is now ready for execution; this process is referred to as loading.

Absolute loading:  This type of loader wants the load module to be loaded in the main memory into same location which means the loader must have a specific address/ absolute, main memory addresses. It is called as absolute loader as it has no need of relocating information instead this is obtained from the complier or programmer. The programmer must have the knowledge of the starting address of each module then it is stored into object files which then simplifies the loader task. Memory management is the crucial part of this type of loader that means the programmer must have knowledge about memory handling. The following two things must be taken into consideration by the programmers:

  1. Specification of starting address of every module to be used.
  2. In case of segment branching from one segment to another the absolute beginning address of respective module to be understood by the programmer.

Let us take an example to make the concept clear.


Main Program                                                     SQRT Subroutine

  Main start 100                                                    SQRT start 400

  ……………                                                         ..…………..

SQRT DC F 400    End                                          End

In the above example we have two program one is Main program, and another is sub program SQRT. As seen above in the figure in Main program it is clearly mentioned when loading main program into the main memory it must start at 100.And at the SQRT sub routine it is clearly shown that the starting program is at 400. This means that 100 is the absolute address for storing the main program and 400 is absolute address for storing the SQRT program.

Whenever the absolute loader is loading this means the object program and subroutine object program into the memory it must exactly store the absolute address 100 for the main program and 400 for SQRT program. The program should be stored at the specific address that’s why it is called as absolute loader.

Advantages of Absolute loader are:

  1. Loader task will be simplified as it follows the command in regard with the object code placement in the main memory.
  2. It has easier implementation, and the execution process is efficient.
  3. Supports programs written in multiple language.

Disadvantages of Absolute loader:

  1. Loading address in the assembly program must be specified by the programmer.
  2. If there are number of subroutines, then the address of every subroutine must be recall by the programmer.

Relocation Loader:

Relocation loaders are those loaders which allow object program relocation in the main memory for the program execution. It loads the object program into the any space available in the memory. The specific starting address of the relocatable segments is unknown until loading time. Relocation facilities the smooth division of the machine with larger memory and when various independent programs are to be operated together. It also supports the use of subroutine libraries effectively. To avoid chances of reassembling all subroutines in case of change in single subroutine and function task allocation and linking for programmers’ relocation loaders are used. Binary Symbolic Subroutine (BSS) is one example of this type of loader.

In the above figure we have three object programs and each of them has same starting address zero. As seen the length of each segment vary from each other. The length of the first program A has the length 0-57 which occupies 57 bytes similarly second object program B has the 0-13 which needs 13bytes and for the segment C 0-34 requires 34 bytes.

In this scenario we cannot be able to use the absolute loader to load all the three segments at the same location that’s why there is need of relocation.

In this figure in the main memory the object code which belongs to object program A can be loaded to the starting from 0 to 57 itself.

In case loading object program B we cannot be able to load from 0 in the main memory though the length of the segment starts from 0 but it can be relocated from 58 onwards which have 13 bytes length which ends at 71.

Similarly for C since it starts from 0-34, we cannot load it into the main memory starting from 0 in A and same for the B because the section is already occupied by A and B but can be loaded from 72 onwards and ends at 106. The space availability in the main memory is determined by the Operating system.

Advantages of Relocation Loaders:

  1. Avoids reassembling of all subroutines when single subroutine is changed.
  2. Functions task allocation and linking for the program.

  Disadvantages of Relocation Loaders:

  1. Difficulty in implementation.
  2. Performance is slower as compared to Absolute loader
  3. Algorithms rely on file structure of the object program.

Direct Linking Loader:

Direct linking loader is one of the relocatable loaders and one of the most common loading scans that is currently used. This type of loader cannot have direct access to the source code and to put the object code into the memory needs two states: either the address could be absolute and can be placed in particular address or it can be relative. If the assembler found that the received address is all relative, then the assembler will notify the loader about the

  1. Object code segment length.
  2. The list of all the symbols which are not defined in the current segment but can be used in  
  3.  The list of all the symbols which are defined in the current segment but can be referred by the other segments.

It stores the symbol list not defined in the current segment but that can be used in the current segment into a data structure called USE table. Symbol name, address, address relativity is placed in USE table. A data structure that is called as DEFINITION table store the list of symbols defined in the present segment and can be referred by other segments.it stores the information such as symbol and address.

Direct linking loader has 4 types of cards:

  1. ESD Card: it holds information regarding the symbols defined in program but reference somewhere. It has reference number, type id, relative location, symbol name and length. It is further classified into 3 types.
    1. SD: It denotes segment definition
    1. LD: it denotes local definition
    1. ER: it denotes external reference

  • TXT card: it holds information about already translated text.
  • RLD card: it holds location information in the program about the address at which the program is placed. Here we use -sign to denote relocation need and +sign to denote no need of relocation. It has the following format.
  • Reference number
  • Symbol
  •  Flag
  •  Length
  • Relative location
  •  END Card: It shows end of the object program

 Advantages of Direct Linking Loader:

  1. Provides relocation features.
  2. Facilities multiple data segment and procedure.
  3. Facilities independent program translation.

Disadvantages of Direct Linking Loader:

  1. It is not preferable for multitasking.
  2. Program loading time will be more time consuming as it requires allocation, relocation, link and load all the subroutines every time during program execution.


Liking is the method to collect and combine different pieces of codes and data into one file which can loaded into the main memory for execution. This process can be done during code compilation time means at the time of translating the source code to machine code, at the loading time means when the program is loading into the memory and can be done at the run time by application program. In the past linking used to be manually but nowadays it is done automatically with the help of programs called linker.

Due to the development of linker separate compilation of program has been possible. There is no need to manage a large application as one monolithic source file we simply can make smaller, more manageable modules that can be modified and complied separately. Linking is usually done invisibly by the linker and is not a major problem for programs that create small programs in introductory programming lessons. Understanding linkers helps you build large programs, helps you avoid programming errors, helps you use a shared library, and helps you understand how language scoping techniques are implemented.

Linkage Editor:

Linkage Editor is a processing program that accepts options such as object modules, load modules, control, and input declarations. These modules are combined into a single output load module according to the requirements outlined in the control statements and options. Linkage Editor provides other processing and service functions, including creating overlay programs, assistance with modifying the program, and creating and editing system libraries. Supports address and residence mode properties in 24-bit and 31-bit address ranges.

Static Linking: The method of copying all the library modules used in a program into the final executable code is called as static linking. This statically linked files include both the calling program and the called program. It is done by the linkers during the final step of compilation. During the loading phase OS will put only a single file to the memory that will have both source code and reference libraries. Processing speed is high but consumes more space.


Dynamic Linking:

The method of using only the name of the shared library module in program is dynamic linkage.it includes only the name of calling program and is performed by the linker at the run time. It allows different programs to use single copy of library module. The processing speed will be slower but consumes less disk space.


The relationship between the load and the link is that the connection is considered to have been created by viewing the executable records in the operating system’s program. However, in the stacking situation, it gets from the execution record obtained by connecting to the most memory in the working framework for execution. The program’s protest module is attempted by a connection handle made with the help of construction, agents. Stacking handles are made with the help of an era of feasible modules with the help of joins. The connection will collect all the protest modules of the program in the era of execution modules. You seem to be combining the library’s ability to demonstrate, it also increases the high level of programming dialects you appear in your working framework. Stacking seems to be allocating space to the executable module show in main memory.


Operating Systems: Internals and Design Principles, 9th Edition

William Stallings

Introduction To Loaders | Computer Program – Scribd.com

 Chapter 7: LOADERS AND LINKERS – jklp.org




Leave a Comment