Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 2: Linkers & Loaders

Lesson 14 of 34 in the free Fundamentals of IT & Computers notes on Siksha Sarovar, written by Rohit Jangra.

Unit II — Linkers & Loaders

After a program is compiled, it goes through two more stages before it can run: linking and loading. These are critical steps in converting source code into a running process.

---

The Software Translation Pipeline

Source Code (.c)
      ↓  [Compiler / Assembler]
Object Code (.obj / .o)
      ↓  [Linker]
Executable File (.exe / a.out)
      ↓  [Loader]
Running Process (in RAM)

---

Linker

A linker (also called link editor) combines one or more object files produced by the compiler/assembler and resolves references between them into a single executable file.

What Does a Linker Do?

  1. Symbol Resolution — Matches function calls in one module with their definitions in another (e.g., printf defined in C standard library).
  2. Relocation — Assigns actual memory addresses to symbols.
  3. Library Linking — Incorporates library code into the executable.

Types of Linking

TypeDescription
Static LinkingAll library code is copied into the executable at link time. Larger file size; no runtime dependency.
Dynamic LinkingLibrary code is NOT copied; the executable references shared libraries (.dll on Windows, .so on Linux) loaded at runtime. Smaller executable; library must be present at runtime.

---

Loader

A loader is part of the operating system that takes an executable file from disk and loads it into main memory (RAM) for execution.

Functions of a Loader

  1. Allocation — Allocates sufficient memory for the program.
  2. Loading — Copies the program's machine code and data from disk to RAM.
  3. Relocation — Adjusts addresses in the program to reflect its actual position in memory.
  4. Linking — (In dynamic loading) Loads required shared libraries.
  5. Initialization — Sets up the program counter (PC) to the program's entry point and transfers control to the OS.

Types of Loaders

TypeDescription
Absolute LoaderLoads program at a fixed, predetermined address
Relocating LoaderCan load program at any available memory location
Dynamic LoaderLoads parts of a program on demand (lazy loading)
Bootstrap LoaderSmall loader stored in ROM; loads the OS at startup

---

Linker vs Loader

FeatureLinkerLoader
InputObject filesExecutable file
OutputExecutable fileRunning process in RAM
When?After compilationWhen program is run
RoleCombine modules + resolve symbolsCopy program into memory
Key Takeaway: The linker merges compiled object files into a runnable executable, resolving all cross-module references. The loader brings that executable into RAM and hands control to the CPU. Together they complete the journey from source code to a running program.