Linking and Relocation

Definition

A linker combine object files (generated from an assembler) into an executable. We want to relocate label addresses and resolve external references.

Diagram

Each of the source files is assembled individually, to create an object (*.o) file. Since the object files use labels which are not yet defined, we replace them with a 0 and keep the label name as metadata (blue). The linker combines these object files and uses their metadata to output the correct memory offsets (relocation).