What Runs Before Your Program Does: The Dynamic Linker, PLT, and GOT

In the previous post, we saw that dynamically linked binaries don’t include library code, they just reference it. Which raises an obvious question: who actually loads that code at runtime, and how does the program find it? The answer is ld.so, the dynamic linker. And it runs before your main() does. The Bootstrap Problem When you execute a binary, the kernel reads its ELF header. One of the fields in that header (stored in the .interp section) contains a path like: ...

March 14, 2026 · Giulia

What Actually Happens When You Compile a C Program

Most developers treat compilation as a black box: you put source code in, you get a binary out. But there are actually three distinct stages happening, each with its own job and its own output. Understanding them has made me significantly better at debugging linker errors, understanding dependencies, and reasoning about what ends up in a binary. Let’s walk through what happens when you run gcc hello.c -o hello. Stage 1: The Preprocessor Before the compiler sees a single line of your code, the preprocessor runs. Its job is mechanical: it handles all the # directives. ...

March 8, 2026 · Giulia