SPRAB89A September 2011 – March 2014
Some contexts, including libraries shared among multiple executables, require position independent addressing. To avoid encoding position-dependent addresses into the code segment, such addresses are instead generated into a table called the Global Offset Table (GOT) which is part of each static link unit's data segment. Instead of accessing the object directly, a program reads the variable's address from the GOT and addresses it the variable indirectly. The GOT is part of the data segment and is always addressed DP-relative using offsets that are fixed at static link time. It is generated by the linker in response to special GOT-generating relocations emitted by the compiler. The addresses in the GOT are patched at dynamic link time when the addresses are known.
The compiler references the GOT using special relocation entries. The static linker generates the table itself in response to the special relocations. The table entries themselves have (dynamic) relocations that the dynamic loader uses to patch in the final resolved address of the referenced object. GOT-based addressing is covered in Section 6.7. Relocations that apply to GOT entries are described in Section 13.6.1.
Executables and libraries using the bare-metal model may or may not require GOT-based addressing.