Lesson 9: From Source to Executable
Last lesson we saw that high-level code must ultimately become machine code. But who does the translation, and how do several files we wrote turn into one runnable program? The answer is a toolchain: a compiler that translates the source into assembly, an assembler that turns assembly into machine c
For code you wrote to run, it passes a few stations: first software translates it to machine code, then several parts are joined into one file, and finally the file is loaded into memory and runs. Each station is a separate tool with one job.
- Compiler
- Software that translates source code written in a high-level language into lower-level code, usually assembly or machine code.
- Assembler
- Software that translates assembly code into machine code and produces an object file.
- Object File
- The assembler's output for a single source file: machine code together with a symbol table, before linking.
- Linker
- Software that combines several object files and libraries into one executable and resolves cross-file references.
- Loader
- Part of the operating system that copies an executable from disk into memory and starts it as a process.
- Executable
- A ready-to-run file containing linked machine code, the final product of the build chain.
- Interpreter
- Software that executes code line by line at runtime, instead of translating it ahead of time into an executable.
- Bytecode
- An intermediate form, neither source nor the CPU's machine code, run by an interpreter or virtual machine.
- Static vs Dynamic Linking
- Static linking bakes the library into the executable; dynamic linking loads it separately at runtime and shares it between programs.
- Symbol
- A name of a function or variable in the symbol table, used by the linker to connect a call to its definition.