LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

What does the linker do?

The linker stitches object files and libraries into a single executable — resolving symbols, assigning final addresses, merging sections, and pulling in library code.

Multiple object files and a library fanning into the linker, producing one executable.

* The linker stitches object files and libraries into one program: resolve symbols, relocate addresses, merge sections, pull in library code. *

Each object file knows its own functions but not where everyone else's live. The linker's job is to make all those references point to real addresses.

Its responsibilities:

  1. Symbol resolution — match each call (e.g. to printf) to its definition
  2. Relocation — replace relative placeholders with final memory addresses
  3. Section merging — combine all the .text, .data, etc. from every object
  4. Library linking — fold in code from static or shared libraries
gcc main.o utils.o math.o -o program   # combine three objects + libs

Static vs. dynamic linking is a key trade-off: static linking copies library code into the executable (bigger file, no runtime dependencies), while dynamic linking loads shared .so/.dll files at run time (smaller file, but the libraries must be present).

Two errors you'll meet constantly: "undefined reference" (a symbol was never defined) and "multiple definition" (a symbol was defined twice).

Go deeper:

  • doc Linker (Wikipedia) — symbol resolution, relocation, section merging, static vs dynamic.

From Quiz: REVE1 / The Processor Interface | Updated: Jul 10, 2026