Linkers
Overview
To build an executable, a linker must perform two main tasks:
- Symbol resolution. The linker phase in which each symbol reference is associated with exactly one symbol definition.
- Relocation. The linker phase in which code and data sections across input modules are combined. Each section, along with the symbols defined in them, are assigned unique run-time memory addresses. Additionally, references to symbols are updated so they point to the correct run-time addresses.
Object Files
Object files come in three forms:
- Relocatable object files. Contains binary code and data in a form that can be combined with other relocatable object files at compile time.
- Executable object files. Contains binary code and data in a form that can be copied directly into memory and executed.
- Shared object files. A special type of relocatable object file that can be loaded into memory and linked dynamically, at either load time or run time.
An object module is a sequence of bytes whereas an object file is an object module stored on disk.