SPRAB89A September 2011 – March 2014
Full position independence implies that code is independent of its own location, the location of its own data, and the location of any imported code or data, without requiring relocation patches at load time. In this context the word own means part of the same static link unit as the reference. Let's examine the implications of each case:
To avoid encoding position-dependent absolute addresses into the code segment, they are 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 symbol's address from the GOT and addresses it 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.
A GOT-based access involves two memory references: one to load the address from the GOT, and another to reference the variable itself. The first reference, to access the GOT itself, is essentially the same as a normal DP-relative data access (see Section 4.3.1). The vast majority of the time, we expect the GOT to be in a near-DP segment, and therefore accessible using near DP-relative addressing.