1) Explain absolute loader. State its advantages and disadvantages.
— 5
Absolute Loader
An absolute loader is the simplest type of loader.
It loads the object program into memory at the exact address given in the program.
No address modification is done.
Working
The assembler produces object code with fixed addresses.
The loader places the code directly into memory.
It does not relocate addresses.
It does not perform linking.
Advantages
Very simple to design and use.
Fast loading.
No extra processing overhead.
Disadvantages
Program must be loaded only at the given address.
No relocation is possible.
Cannot handle multiple modules easily.
Not flexible for large systems.
2) Explain Direct Linking Loader in suitable example. — 10
Direct Linking Loader
A direct linking loader loads several object modules into memory and links them during loading
time.
It resolves external references between modules and places them in memory directly.
Main Functions
Allocation: assigns memory addresses.
Linking: connects different modules.
Relocation: adjusts address values.
Loading: copies object code into memory.
Working
1. The loader reads all object modules.
2. It checks external symbols used by each module.
3. It creates a common symbol table.
4. It assigns memory addresses to each module.
5. It updates all address references.
6. Finally, it loads the program into memory.
Example
Suppose:
Module A defines X
Module B uses X
The loader:
stores the address of X from Module A
replaces the reference of X in Module B with that address
Simple Flow
Read object files
Collect symbols
Assign addresses
Resolve references
Load into memory
Advantages
No need for a separate linking step.
External references are resolved automatically.
Easy to use for multi-module programs.
Disadvantages
Loading time becomes longer.
Loader becomes more complex.
Needs memory for symbol tables and reference handling.
3) Discuss the databases used in direct linking loader. — 10
In a direct linking loader, the loader maintains some important tables or databases to manage
symbols, addresses, and linking.
1. ESTAB (External Symbol Table)
This is the most important table.
Purpose
Stores all external symbols defined in different modules.
Keeps their addresses.
Contents
Control section name
Symbol name
Relative/absolute address
Length of control section
Use
Helps the loader find the address of external references.
2. PROGADDR
It stores the starting address of the whole program in memory.
Use
Used as the base address for loading the first control section.
3. CSADDR (Control Section Address)
It stores the starting address of the current control section.
Use
Helps calculate actual addresses of symbols in each module.
4. CSLTH (Control Section Length)
It stores the length of the current control section.
Use
Helps decide where the next control section should be placed.
5. REFER Table / External Reference Table
It stores symbols that are used but not defined in the current module.
Use
Helps in resolving external references during loading.
6. Modification Records
These are records in the object program that tell the loader which addresses must be updated.
Use
Helpful in relocation and external symbol adjustment.
Summary
The databases used in direct linking loader are:
ESTAB
PROGADDR
CSADDR
CSLTH
Reference table
Modification records
These tables make linking and relocation possible during loading.
4) Explain Dynamic Linking Loader in Detail. — 10
Dynamic Linking Loader
A dynamic linking loader loads and links some program parts only when they are needed during
execution, not all at the beginning.
It is also called runtime linking.
Idea
The main program is loaded first.
Other routines are linked only when they are called.
This saves memory and loading time.
Working
1. The program starts execution.
2. If a function or library routine is needed, the loader searches for it.
3. The required routine is loaded into memory.
4. The address is linked with the calling program.
5. Execution continues.
Example
A program uses functions from a library like:
printf()
sqrt()
file handling routines
These may be loaded only when required.
Advantages
Saves main memory.
Faster initial loading.
Useful for large programs.
Only needed routines are loaded.
Disadvantages
Execution may become slower at the time of first use.
More complex system design.
Needs support from operating system.
Important Point
Dynamic linking is very useful for shared libraries in modern systems.
5) Explain different functions of loader in detail. — 5
Functions of Loader
A loader performs the following main functions:
1. Loading
Copies object program into memory.
2. Allocation
Assigns memory space to the program.
3. Linking
Connects different program modules.
Resolves external symbols.
4. Relocation
Adjusts address values according to the actual memory location.
5. Address Resolution
Converts symbolic addresses into actual memory addresses.
6. Execution Start
Transfers control to the starting address of the program.
In one line
A loader loads the program, assigns memory, links modules, relocates addresses, and starts
execution.
6) Explain the process of loading and linking with a neat diagram. — 5
Loading and Linking
Loading means placing object code into memory.
Linking means connecting different object modules and resolving external references.
Process
1. Object modules are produced by assembler/compiler.
2. Loader reads all modules.
3. It finds external symbols.
4. It assigns memory addresses.
5. It updates address references.
6. It loads the complete program into memory.
Neat Diagram
Key Point
Loading = place program in memory
Linking = join modules and resolve symbols
7) Discuss the concept of “Relocation” in loaders. Explain the various methods of handling
relocation during the loading process with examples. — 10
Relocation
Relocation means modifying address values in the object program so that the program can run
correctly when loaded at a memory address different from the one originally assumed.
Why relocation is needed
A program may not always be loaded at the same address.
The loader may place it in any free memory location.
So address values must be adjusted.
Relocation Methods
1. Absolute Addressing
Addresses are fixed.
No change is allowed.
Example
If code is written for address 1000, it must be loaded at 1000.
Limitation
Very rigid.
2. Relocating Loader with Relocation Bits
This is a common method.
Working
The object program contains a relocation bit for each address field.
If the bit is 1, the address must be modified.
If the bit is 0, no change is needed.
Example
If actual loading start address is 3000 and instruction address is 100,
then relocated address becomes:
3000 + 100 = 3100
3. Modification Records
In this method, the object program contains modification records.
Working
Each record tells the loader which field must be changed.
It also gives the length of the field and adjustment value.
Example
If a field contains address 200 and program is loaded at 5000,
new address = 5200
4. Self-Relocating Code
Program can adjust its own addresses during execution.
Uses relative addressing or base registers.
Example
If base register contains 4000, and offset is 120,
effective address = 4120
Advantages of Relocation
Program can be loaded anywhere in memory.
Better memory use.
Supports multiprogramming.
Conclusion
Relocation is necessary for flexible program loading and proper execution.
8) Define Relocation and Linking. Why are they crucial functions of a linking loader? — 10
Relocation
Relocation is the process of changing address values in a program so it can run from a different
memory location.
Linking
Linking is the process of combining multiple object modules and resolving external references
between them.
Why Relocation is Important
Programs are not always loaded at the same address.
It allows the loader to place programs wherever memory is available.
Makes programs flexible and reusable.
Why Linking is Important
Large programs are divided into modules.
One module may call functions in another module.
Linking connects these modules correctly.
Why Both Are Crucial in a Linking Loader
A linking loader must do both jobs:
1. Relocation
Adjust addresses to actual memory location.
2. Linking
Resolve external symbols and connect modules.
Without them:
The program may jump to wrong addresses.
External function calls may fail.
The program cannot execute correctly.
Simple Example
Module A defines SUM
Module B uses SUM
The loader:
links B to A
relocates both modules to actual memory locations
Conclusion
Relocation and linking are essential because they make modular programs work correctly in any
memory location.