GOT
also: Global Offset Table
The Global Offset Table (GOT) is a section in executable files that holds addresses of global variables and functions, allowing position-independent code to dynamically resolve symbols at runtime.
The GOT is a fundamental component of shared libraries and position-independent executables (PIE). It stores pointers to global symbols (variables and functions) whose addresses are not known at compile time, enabling the dynamic linker to fill in the correct addresses after loading.
When code references a global symbol, it doesn't directly use the symbol's address. Instead, it loads the address from the GOT, which is located at a fixed offset from the current code. This indirection allows the same compiled code to run at different memory addresses without modification.
Example: A shared library function call might reference printf by loading its address from GOT entry 8, which the dynamic linker patches with the actual address of printf when the library loads. This is essential for Address Space Layout Randomization (ASLR) and allows multiple processes to share the same library code while each gets different data addresses.