---
📘 System Software – Module 3: Loaders and Linkers
(Detailed Explanation – Like Class Notes)
---
🔷 1. What Is a Loader?
Imagine you’ve written a program. You've compiled and assembled it, and now you want to run
it. But how does it actually get into memory and start running?
That’s the job of the Loader.
🔹 Loader = A program that:
Loads machine code from disk into main memory (RAM)
Adjusts addresses if needed
Starts execution of the program
---
🔷 2. Functions of a Loader
Function Meaning
Allocation Find memory space for the program
Loading Copy machine code into memory
LinkingCombine multiple programs (if needed)
Relocation Adjust addresses based on where it's loaded
Starting Execution Start running the program
---
🔷 3. What Is a Linker?
Let’s say your program uses a function from another file (like a library). The assembler only
knows the name, not the address.
That’s where the Linker comes in.
🔹 Linker = A program that:
Takes multiple object files
Connects (links) them together
Resolves external references
Produces one final executable file
---
🔷 4. Differences Between Loader and Linker
Feature Linker Loader
Job Combines object filesLoads program into memory
TimingHappens before loading Happens during execution
OutputOne executable file Starts execution
Resolves External symbols Final addresses
---
🔷 5. Types of Loaders
1️⃣ Absolute Loader
Loads code into fixed memory address.
No relocation.
Used in early systems.
💡 Fast, but not flexible.
2️⃣ Relocating Loader
Adjusts addresses depending on where the program is loaded.
More flexible.
3️⃣ Dynamic Linking Loader
Loads program first.
Then links functions during execution, only when needed.
Used in modern OS (like .dll in Windows or .so in Linux).
---
🔷 6. Loader Design Options
These are 4 strategies for implementing loaders:
Loader Type Description
Compile-and-Go Compiles → Loads → Runs in one step. No separate object file.
Absolute Loader Needs address info in advance. No relocation.
Relocating Loader Adjusts all addresses during loading.
Dynamic Loader Loads external functions only when needed. Saves memory!
---
🔷 7. Relocation and Linking Concept
When you write code like:
JSUB INPUT
INPUT might be in another program or file.
Linker finds its actual address from another object file.
Relocation happens if the program isn't loaded at its original location.
🧠 Example: If the original program was made to load at address 1000 but gets loaded at 2000,
then:
All address references must be updated by +1000
---
🔷 8. Linking and Relocation Information
Each object file contains extra information to help the linker/loader:
Linking Info:
Tells which external names are needed (e.g., INPUT, OUTPUT)
Relocation Info:
Tells which addresses need to be modified if base address changes
---
🔷 9. Program Linking Format (Object File Structure)
An object file contains:
Header record: Program name, size, start address
Text records: Machine code instructions
Modification records: Info on what addresses to update
End record: Entry point of program
🧠 Example:
H COPY 001000 00107A
T 001000 141033 281030 ...
M 001003 05 +INPUT
E 001000
---
🔷 10. Dynamic Linking
Used in modern systems to save memory.
When a program starts, it’s loaded without some functions.
If you call a function like printf(), only then the OS loads the real address.
This allows multiple programs to share libraries (e.g., system DLLs in Windows).
---
🧠 Summary
A Loader loads machine code into memory and starts execution.
A Linker connects multiple object files and resolves external labels.
Relocation adjusts addresses if the program is not loaded at its original base.
Dynamic Linking delays loading some code until runtime to save space.
✅ Diagrams (Loader flowchart, Linker process, Object file structure)
---
🎯⚔️
Module 3 into a fun story mode — like a cartoon adventure where your programs are little
characters trying to get ready for battle
---
📘 Module 3 – The Story of the Loader and the Linker
---
🌍 Once Upon a Time…
In the magical land of Software Kingdom, little programs were born in a village called Assembly
Town.
🧩
But they weren’t ready to fight dragons (run on the computer) yet… they were just tiny object
files — incomplete, scared, and in pieces.
So they needed help from two powerful wizards…
---
🧙♂️ Wizard Linker – The Great Connector
Wizard Linker was old and wise. His magic allowed him to look at multiple little object files and
link them into one complete hero.
Let’s say two object files said:
👦 File 1: “I will call INPUT, but I don’t know where it is.”
👧 File 2: “Here! I have a function called INPUT.”
🔮 Linker says: “Let me connect your missing pieces.”
✨ He links them together and gives them a magic suit — a complete executable file!
---
🧙♀️ Wizard Loader – The Gate Opener
Once the complete program is ready, it’s still not in the battlefield (the computer’s memory).
Here comes Wizard Loader.
She opens the gates to the memory kingdom, finds a perfect place for the program, and places
it there gently.
💬 “You shall now live in memory address 2000, not 1000 like you wanted,” she says kindly.
But WAIT! The program still thinks it lives at address 1000.
So Loader pulls out her magic wand 🪄 and fixes all the addresses (called relocation) to match
their new home.
---
🧭 What Is Relocation?
Let’s say a soldier (instruction) says: 🔹 “Jump to address 1003!”
But the program is actually at address 2000, so that jump is now wrong.
🧙♀️ Loader says:
“Don’t worry, I’ll add 1000 to every address so your jumps go to the right place.”
That's relocation – correcting addresses when the location changes.
---
🧩 What If Pieces Are Missing?
Sometimes, a hero needs a sword (a function), but it hasn’t arrived yet.
This is where Dynamic Linking comes in.
Wizard Loader says: 🧙♀️ “We’ll load that sword later, only when you actually use it. Why carry
heavy things now?”
🗣️
So when the hero finally shouts:
CALL printf()
The Loader quickly brings it from the Library of DLL and gives it to him. 💼⚔️
---
🏹 Types of Loaders in the Land
LoaderWhat It Does
👶 Absolute Loader Very basic. Puts code into memory as-is. No fixing.
🧑 Relocating LoaderAdjusts addresses to new memory space. Smart.
🧓 Dynamic Loader Doesn’t bring all tools. Loads tools (functions) when needed. Super
modern.
---
📜 Object Files Look Like Scrolls
Each program carries a scroll (object file) with:
1. Header: Who I am, where I start
2. Text Section: My powers (instructions)
3. Modification Record: Which parts need address fixing
4. End Record: Where to start running
Example scroll:
H HERO 001000 0000C0
T 001000 141033 281030 …
M 001003 05 +INPUT
E 001000
---
🧠 The Final Battle
🛡️👑
When the Linker and Loader finish their job, the once tiny object file becomes a fully armored
hero, standing in memory, ready to execute — ready to fight
And your program finally begins its adventure — printing, calculating, or playing music,
whatever you wanted it to do!
---
🎓 Moral of the Story
🔹 Linker joins programs together and solves missing parts
🔹 Loader loads them into memory and adjusts all addresses
🔹 Relocation makes sure everything points to the correct spot
🔹 Dynamic Linking is like just-in-time delivery of swords (functions) — smart and light
---