LOGBOOK

HELP

Quiz Entry - updated: 2026.07.14

What are the stages in transforming source code to executable machine code?

Four stages: preprocess (-E) → compile to assembly (-S) → assemble to an object file (-c) → link into an executable (-o).

Serpentine pipeline turning p24.c into the p24 executable through four gcc stages: preprocess (-E) to .i, compile (-S) to .s assembly, assemble (-c) to p24.o object, and link (-o) to the final executable.

* GCC transforms source into an executable in four stages, each producing an intermediate file until the linker emits the runnable program. *

Stage Input Output Tool
Preprocessing Source code (.c) Preprocessed source (.pp.c) gcc -E
Compiling Preprocessed source Assembly code (.s) gcc -S
Assembling Assembly code Relocatable object code (.o) gcc -c
Linking Object files Executable gcc -o

What each stage does:

  • Preprocessor: Expands #include, #define macros
  • Compiler: Translates C to assembly language
  • Assembler: Converts assembly to machine code (binary)
  • Linker/Loader: Combines object files, resolves external references, adds the C runtime, and produces the final loadable executable

Tip: Remember "PCAL" - Preprocess → Compile → Assemble → Link. The flags follow the same pattern: -E, -S, -c, then -o for output.

Go deeper:

  • doc Compiler (Wikipedia) — the front/middle/back-end pipeline, situating the preprocessor, assembler and linker as the toolchain stages that turn source into an executable.

From Quiz: REVE1 / Overview of Computer Systems | Updated: Jul 14, 2026