Linkers

Overview

To build an executable, a linker must perform two main tasks:

  1. Symbol resolution. The linker phase in which each symbol reference is associated with exactly one symbol definition.
  2. 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:

  1. Relocatable object files. Contains binary code and data in a form that can be combined with other relocatable object files at compile time.
  2. Executable object files. Contains binary code and data in a form that can be copied directly into memory and executed.
  3. 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.

Powered by Forestry.md