3.2.2 Linkage

In a main (static) image, the GP register is initialized to point to the shared global storage region at the beginning of program execution. The GP register must not be modified by any procedure that is included in either the main image or a dynamic-link library.

Because there is no GP or other base pointer available to code that is part of a dynamic-link library image, addressing data that is not part of the same compilation generally requires using an LDAH/LDA sequence to dynamically create a suitable base address. Such code thereby becomes non–position independent (non-PIC). That is, it requires relocation if it is to be moved and executed at a different virtual address. You can minimize the number of such relocations in the code stream by loading a linkage pointer (a sort of "procedure local GP" value) near the beginning of a procedure's execution, with the address of a linkage section, if needed, where the linkage section contains variables, addresses, and/or literal data that is needed by the code. (This decreases the density of non-PIC references in the code stream.)