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
ASCII Values Alphabets ( A-Z, a-z & Special Character Table ) ASCII (American Standard Code for Information Interchange) is a standard character encoding used in telecommunication. The ASCII pronounced 'ask-ee', is strictly a seven-bit code based on the English alphabet. ASCII codes are used to represent alphanumeric data. The code was first published as a sta
7 min read
What is an Operating System? An Operating System is a System software that manages all the resources of the computing device. Acts as an interface between the software and different parts of the computer or the computer hardware. Manages the overall resources and operations of the computer. Controls and monitors the execution o
9 min read
What is a Neural Network? Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamental
12 min read
COCOMO Model - Software Engineering The Constructive Cost Model (COCOMO) It was proposed by Barry Boehm in 1981 and is based on the study of 63 projects, which makes it one of the best-documented models. It is a Software Cost Estimation Model that helps predict the effort, cost, and schedule required for a software development project
15+ min read
Phases of a Compiler A compiler is a software tool that converts high-level programming code into machine code that a computer can understand and execute. It acts as a bridge between human-readable code and machine-level instructions, enabling efficient program execution. The process of compilation is divided into six p
10 min read
Advanced Encryption Standard (AES) Advanced Encryption Standard (AES) is a highly trusted encryption algorithm used to secure data by converting it into an unreadable format without the proper key. It is developed by the National Institute of Standards and Technology (NIST) in 2001. It is is widely used today as it is much stronger t
7 min read
Supervised and Unsupervised learning Supervised and unsupervised learning are two main types of machine learning. In supervised learning, the model is trained with labeled data where each input has a corresponding output. On the other hand, unsupervised learning involves training the model with unlabeled data which helps to uncover pat
10 min read
Clustering in Machine Learning In real world, not every data we work upon has a target variable. Have you ever wondered how Netflix groups similar movies together or how Amazon organizes its vast product catalog? These are real-world applications of clustering. This kind of data cannot be analyzed using supervised learning algori
9 min read
What is TCP (Transmission Control Protocol)? Transmission Control Protocol (TCP) is a connection-oriented protocol for communications that helps in the exchange of messages between different devices over a network. It is one of the main protocols of the TCP/IP suite. In OSI model, it operates at the transport layer(Layer 4). It lies between th
5 min read
Data Warehousing A data warehouse is a centralized system used for storing and managing large volumes of data from various sources. It is designed to help businesses analyze historical data and make informed decisions. Data from different operational systems is collected, cleaned, and stored in a structured way, ena
10 min read