Global Offset Table
{{Short description|Structure present on executable files}}
The Global Offset Table, or GOT, is a section of a computer program's (executables and shared libraries) memory used to enable computer program code compiled as an ELF file to run correctly, independent of the memory address where the program's code or data is loaded at runtime.{{cite web |title=Dynamic Linking |url=http://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x2251.html |website=refspecs.linuxfoundation.org}}
It maps symbols in programming code to their corresponding absolute memory addresses to facilitate Position Independent Code (PIC) and Position Independent Executables (PIE){{cite web |title=Code Gen Options (Using the GNU Compiler Collection) |url=https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html |website=gcc.gnu.org}} which are loaded{{cite web |title=How programs get run: ELF binaries [LWN.net] |url=https://lwn.net/Articles/631631/ |website=lwn.net}} to a different memory address each time the program is started. The runtime memory address, also known as absolute memory address of variables and functions is unknown before the program is started when PIC or PIE code is run{{cite web |title=Global Offset Tables |url=http://bottomupcs.sourceforge.net/csbu/x3824.htm |website=bottomupcs.sourceforge.net}} so cannot be hardcoded during compilation by a compiler.
The Global Offset Table is represented as the .got and .got.plt sections in an ELF file{{cite web |title=Executable and Linkable Format (ELF) |url=https://stevens.netmeister.org/631/elf.html |website=stevens.netmeister.org}} which are loaded into the program's memory at startup.{{cite web | last=Wienand | first=Ian | title=PLT and GOT - the key to code sharing and dynamic libraries | website=Technovelty | date=May 10, 2011 | url=https://www.technovelty.org/linux/plt-and-got-the-key-to-code-sharing-and-dynamic-libraries.html | accessdate= 14 April 2020}} The operating system's dynamic linker updates the global offset table relocations (symbol to absolute memory addresses) at program startup or as symbols are accessed.{{cite web |last1=Aichinger |first1=Christian |title=The ELF format - how programs look from the inside |url=https://greek0.net/elf.html |website=Christian Aichinger's thoughts |language=en}}
It is the mechanism that allows shared libraries (.so) to be relocated to a different memory address at startup and avoid memory address conflicts with the main program or other shared libraries, and to harden computer program code from exploitation.{{cite web |last1=Sidhpurwala |first1=Huzaifa |title=Hardening ELF binaries using Relocation Read-Only (RELRO) |url=https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro |website=Red Hat |date=28 January 2018}}