Program linkers link object file together to create either:
- An executable file
- A shared library
Dynamic linkers link the executing program to a shared library at runtime.
Defined symbols are static objects within the source code that are defined for the entirety of the program (function or global and static variables). A symbol is a name and value. The value is the address in the program (&my_var).
An undefined symbol is a reference to a defined symbol. When linking, the linker gives an address (value) to each defined symbol and resolve the undefined symbols to the value of the defined symbol.
The content is the actual byte of the program organized as segments: .text for the program .data for the initialized variable .bss for the uninitialized variable .rdata for static unamed data (like strings constants)
The linker will read all the content of all the object and concatenate all by type and then perform the relocation.
A relocation is the action of the linker to resolve the address of a symbol in the final program address. A jump will point to a label. This label position in the program is only known at link time. The linker will relocate the jump argument to the final address of the label.
Every object file is its own address spaces. Contents (.text, .data, etc.) have address and symbols and relocations points to these addresses.
The program will be loaded at the load address spaces in memory. This is the physical address space.
But when executing, the program and the shared library are in the virtual address spaces.
On unix, load address space and virtual address space are one and the same for programs. But shared library are loaded in some place and then mapped to the virtual address space of multiple different processes.