Basic Functions of Loader
Last Updated :
21 Nov, 2022
Assemblers and compilers are used to convert source code to object code. The loader will accept that object code, make it ready for execution, and helps to execute. Loader performs its task via four functions, these are as follows:
- Allocation: It allocates memory for the program in the main memory.
- Linking: It combines two or more separate object programs or modules and supplies necessary information.
- Relocation: It modifies the object program so that it can be loaded at an address different from the location.
- Loading: It brings the object program into the main memory for execution.
A general loading scheme is shown below:
Functions of LoaderAllocation:
In order to allocate memory to the program, the loader allocates the memory on the basis of the size of the program, this is known as allocation. The loader gives the space in memory where the object program will be loaded for execution.
Linking:
The linker resolves the symbolic reference code or data between the object modules by allocating all of the user subroutine and library subroutine addresses. This process is known as linking. In any language, a program written has a function, it can be user-defined or can be a library function. For example, in C language we have a printf() function. When the program control goes to the line where the printf() is written, then the linker comes into the picture and it links that line to the module where the actual implementation of the printf() function is written.
Relocation:
There are some address-dependent locations in the program, and these address constants must be modified to fit the available space, this can be done by loader and this is known as relocation. In order to allow the object program to be loaded at a different address than the one initially supplied, the loader modifies the object program by modifying specific instructions.
Loading:
The loader loads the program into the main memory for execution of that program. It loads machine instruction and data of related programs and subroutines into the main memory, this process is known as loading. The loader performs loading; hence, the assembler must provide the loader with the object program.
eg. Absolute Loader
Absolute Loader:
The absolute loader transfers the text of the program into memory at the address provided by the assembler after reading the object program line by line. There are two types of information that the object program must communicate from the assembler to the loader.
It must convey the machine instructions that the assembler has created along with the memory address.
It must convey the start of the execution. At this point, the software will begin to run after it has loaded.
The object program is the sequence of the object records. Each object record specifies some specific aspect of the program in the object module. There are two types of records:
Text record containing a binary image of the assembly program.
Transfer the record that contains the execution's starting or entry point.
The formats of text and transfer records are shown below:
Algorithm:
The algorithm for the absolute loader is quite simple. The object file is read record by record by the loader, and the binary image is moved to the locations specified in the record. The final record is a transfer record. When the control reaches the transfer record, it is transferred to the entry point for execution.
Flowchart:
Similar Reads
Compiler and Go Loader
The loader is one of the essential parts of the operating system which loads the program and libraries in memory. There are multiple loading schemes to do the four functions of the loader. Following are the basic function of the loader. Compiler is a software tool that converts human-readable source
4 min read
Loader in Compiler Design
Pre-requisites: Introduction To Compilers In compiler design, a loader is a program that is responsible for loading executable programs into memory for execution. The loader reads the object code of a program, which is usually in binary form, and copies it into memory. It also performs other tasks s
7 min read
Introduction of Basic Input Output System (BIOS)
When a computer system is turned on it requires a series of initialization and test before the user can work on it. This process is called booting. Basic Input Output System (BIOS) : It provides a set of instructions and is responsible for booting the computer. The BIOS performs all the test needed
3 min read
Difference between Load Time and Execution Time address binding
Prerequisite - Address Binding Methods Address Binding is the association of program instructions and data to the actual physical memory location. There are various types of address binding in the operating system. There are 3 types of Address Binding: Compile Time Address Binding Load Time Address
2 min read
What is Warm Booting?
Booting is the process of loading and executing the operating system when the user presses the power button. Warm booting is a process of rebooting a system. It can be set up by running the operating system. In Windows, you can warm boot by selecting the restart option from the Start menu. What is W
5 min read
Phases of a Assembler
The Assembler is a program that converts assembly language into machine language that can be executed by a computer. The Assembler operates in two main phases: Analysis Phase and Synthesis Phase. The Analysis Phase validates the syntax of the code, checks for errors, and creates a symbol table. The
4 min read
What is a Mount? Working and Types
Mounting is a basic concept in computing, particularly in operating systems. It involves making files and directories from one file system available to use within another file system. This process is essential for allowing us to interact effectively with our digital devices, providing the flexibilit
5 min read
Batch Processing Operating System
In the beginning, computers were very large types of machinery that ran from a console table. In all-purpose, card readers or tape drivers were used for input, and punch cards, tape drives, and line printers were used for output. Operators had no direct interface with the system, and job implementat
6 min read
What is Command Line Interface (CLI)?
Command Line Interface is used to communicate with a computer program, you can input text into a by typing command lines. In this article, we will understand the workings of the command line interface, features of the command line interface, and more. What is the Command Line Interface?Command line
6 min read
What is Cold Booting?
Turning on a computer system after it has been shut off is known as âcold booting.â Usually, this is done by pushing the power button of the computer. Using cold booting, the âPower on Self-Testâ (POST) is carried out. It is a series of system checks carried out when the boot process first begins. W
4 min read