Quiz Entry - updated: 2026.07.14
What are the steps to turn C source code into an executable?
Four stages run in sequence: preprocess → compile → assemble → link, turning .c text into a runnable binary.
* C becomes a program in four steps — preprocess, compile, assemble, link — each producing a concrete artifact; only the link stage pulls in libraries. *
gcc is really a driver that quietly runs four separate tools. Understanding the chain is essential for reverse engineering, because each stage produces an artifact you can inspect.
source.c → [preprocess] → .i → [compile] → .s → [assemble] → .o → [link] → executable
| Stage | Input | Output | What it does |
|---|---|---|---|
| Preprocess | .c | .i | Expand #include, #define, conditionals |
| Compile | .i | .s | Translate C into assembly text |
| Assemble | .s | .o | Encode assembly into machine code (object file) |
| Link | .o + libs | executable | Resolve symbols, assign addresses, pull in libraries |
gcc -E source.c -o source.i # preprocess only
gcc -S source.c -o source.s # stop at assembly
gcc -c source.c -o source.o # stop at object file
gcc source.o -o program # link to executable
Tip: gcc -S -O1 produces readable optimized assembly — the quickest way to see how the compiler turned your C into machine instructions.
Go deeper:
GNU Compiler Collection (Wikipedia) — how gcc drives compile, assemble and link.