Linking

Refer: https://en.wikipedia.org/wiki/Linker_(computing)

The motivation behind this is that sometimes, programs are very large, so it’s not convenient to assemble the whole program at once.

In practice, we often want to assemble and compile small parts of a program, typically one source file at a time.

Linking is a computer system program that takes one or more object files .o (generated by either the compiler or assembler) and combines them into a single executable file, library file or another object file.

Linking is the process of combining multiple object files into one. It involves two main activities:

  1. relocating addresses in object files to account for the code from those files starting at an offset other than 0 in the resulting linked file
  2. resolving labels that are used in a different file than the one in which they are defined, by finding the value of the label in the symbol table metadata of the defining file and writing the value in all the places where the symbol is used.

Relocation / Relocating

Adjusting addresses in machine language code so the code works at a different starting address.