Compiler

Linking

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.

Screen Shot 2022-10-25 at 11.02.01 AM.png The above is sort of an idea on how we can do it.

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

Object files contain machine language with metadata about labels.

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.