Misplaced Pages

Global Offset Table

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

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.

It maps symbols in programming code to their corresponding absolute memory addresses to facilitate Position Independent Code (PIC) and Position Independent Executables (PIE) which are loaded 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 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 which are loaded into the program's memory at startup. 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. 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.

References

  1. "Dynamic Linking". refspecs.linuxfoundation.org.
  2. "Code Gen Options (Using the GNU Compiler Collection)". gcc.gnu.org.
  3. "How programs get run: ELF binaries [LWN.net]". lwn.net.
  4. "Global Offset Tables". bottomupcs.sourceforge.net.
  5. ^ "Executable and Linkable Format (ELF)". stevens.netmeister.org.
  6. Wienand, Ian (May 10, 2011). "PLT and GOT - the key to code sharing and dynamic libraries". Technovelty. Retrieved 14 April 2020.
  7. Aichinger, Christian. "The ELF format - how programs look from the inside". Christian Aichinger's thoughts.
  8. Sidhpurwala, Huzaifa (28 January 2018). "Hardening ELF binaries using Relocation Read-Only (RELRO)". Red Hat.


Stub icon

This computer-programming-related article is a stub. You can help Misplaced Pages by expanding it.

Categories: