Unit 3
Unit 3
Static Link
Library Dynamic Link Library
Every program has its own copy Library code is shared among
of the library. multiple programs.
Q.2 What are the different types of Loaders? Explain compile and Go
loader
in detail.
Types of Loaders
Loaders are system programs that load executable files into memory and
prepare them for execution. There are various types of loaders, each with
its own specific functionality. Here are some common types:
1. Absolute Loader
2. Relocating Loader
o Can load programs into any memory location, adjusting
addresses in the program to match the loading location.
Key Characteristics
Advantages
Disadvantages
1. Absolute Loader
Explanation:
In this scheme, the loader loads the executable program into a pre-
defined and fixed memory location.
Advantages:
Disadvantages:
Explanation:
This makes the program more flexible and suitable for systems
where memory allocation must be dynamic.
Advantages:
Disadvantages:
Explanation:
Advantages:
Reduces the size of executable files since libraries are loaded only
when needed.
Facilitates sharing of common code among multiple programs,
reducing memory usage.
Disadvantages:
4. Compile-and-Go Loader
Explanation:
Advantages:
Disadvantages:
5. Bootstrap Loader
Explanation:
Advantages:
Essential for system startup and for loading the operating system.
Disadvantages:
structures.
4. Once all addresses are resolved, the code is loaded into memory,
and the program can be executed.
The design of a Direct Linking Loader relies on several key data structures
to manage information about the program and its external references:
2. Symbol Table
4. Load Map
5. Linking Table
REFER QUES 4
Q.7 Give complete design of Absolute Loader with suitable
example?
Explanation:
1. Input
2. Memory Layout
The object code contains both instructions and data, all with
predefined addresses.
3. Loading Process
Object Code:
Steps:
Once all addresses are resolved, the code is loaded into memory,
and the program can be executed.
The design of a Direct Linking Loader relies on several key data structures
to manage information about the program and its external references:
Symbol Table
Load Map
Linking Table
o The user writes the source code, which is input into the
compiler.
2. Compilation:
3. Loading:
o The compiler places the object code (machine code) into the
memory itself.
4. Execution:
Example Flow
1. Simplicity:
2. No Intermediate Files:
1. Wastage of Memory:
o Memory used for the compiler becomes unavailable for the
program, as the compiler and the program must reside in
memory simultaneously.
2. Limited Modularity:
3. Lack of Flexibility:
4. Error Handling:
without import.
Features of DLL:
Advantages of DLL:
2. Improved Maintainability:
3. Faster Compilation:
Dynamic Linking
1. Import Libraries:
3. Advantages:
4. Example:
1. Explicit Loading:
2. Process:
3. Advantages:
4. Disadvantages:
5. Example:
i) Subroutine Linkage
1. Call Mechanism:
2. Passing Parameters:
Registers
Stack
Memory locations
Global variables
3. Return Address:
5. Return Mechanism:
Key Concepts
Example in Assembly
assembly
Copy code
SUBROUTINE:
; Perform task
ii) Overlays
Structure of Overlays
Advantages of Overlays
Disadvantages of Overlays
1. Relocation:
2. Linking:
3. Loading:
4. Starting Execution:
1. Program Reading:
3. Loading:
4. Execution:
o Control is passed to the starting address for program
execution.
1. Flexibility:
3. Reusability:
4. Dynamic Linking:
1. Complexity:
2. Time Overhead:
3. Dependency on Tables: