indexToolchain & Linking#toolchain#linker#elf#debugging#sanitizers#metal

Toolchain & Linking

gcc main.c hides four programs and a small mountain of conventions. This branch opens them up: preprocess → compile → assemble → link, what an object file contains, how the linker resolves symbols, the ELF format, static vs dynamic linking, and the loader that maps it all into a running process. Then the discipline half: gdb/lldb, sanitizers (ASan/UBSan/TSan), and valgrind — the tools that turn "it crashed" into a precise diagnosis.

Linking is where separate compilation, libraries, and the loader meet. Understand it and "undefined reference" / "symbol not found" stop being mysteries.

Planned notes

Core sources

  • John Levine — Linkers and Loaders — the spine of this branch.
  • Ian Lance Taylor — Linkers (20-part series) — how a linker really works, from the gold author. lwn.net/Articles/276782
  • Ulrich Drepper — How To Write Shared Libraries — dynamic linking in depth. akkadia.org/drepper/dsohowto.pdf
  • David Drysdale — Beginner's Guide to Linkers — the gentle on-ramp. lurklurk.org/linkers/linkers.html
  • ELF specification; Clang sanitizer docs (clang.llvm.org/docs); GDB manual (sourceware.org/gdb).

Connects to: Assembly & Compiler Output · C from the Metal · OS from Scratch