liveBook · Manning

Linker

As explained in Modern C

A linker is a tool that combines translated program components, resolves references, and produces an executable or linkable program image.

A linker combines translated program components, resolves references between object files, and produces an executable or linkable program image. In ordinary C development, the compiler frontend usually invokes it invisibly. A dynamic linker may act later, during program startup. section 13.2

The linker becomes relevant when program structure crosses declaration, file, or library boundaries:

  • Identifiers accessed from different object files require external linkage so references can be associated with the same object or function. section 13.2
  • C library functions reside in a system library such as libc.so rather than in the object file produced for the program. section 13.2
  • Initialization involving another object’s address may require linker support because the address is generally computed when execution starts. section 13.2.1

External linkage and startup initialization

A file-scope object with external linkage can be defined in one object file and referenced from another through an extern declaration. The linker establishes that correspondence. It also supports startup initialization for identifiers with external linkage, before main begins; a dynamic linker may perform related work only at program startup. section 13.2 section 13.2.1

How Modern C covers it

How deep it goes
Explains external linkage and startup initialization, but stops short of platform-specific linker invocation details.
Examples
Uses extern references, C library functions in libc.so, and static initialization involving another object’s address.
What you can do after
Understand why cross-file references and some startup initialization require linker involvement.
How it connects
Connects external linkage with compilers, object files, system libraries, dynamic linking, and storage duration.

Also explained in

Compare how 2 books explain linker →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.