SPRAB89A September 2011 – March 2014
Typically when the compiler sees a call to an extern function, it simply generates a CALL instruction without regard to where the called function is. During static linking, if the function is defined in another source file or within a statically-linked library, the linker simply relocates the displacement field in the CALL instruction to resolve the reference.
If the function is imported from a shared library, its address is unknown at static link time, eventually being resolved at dynamic link time. Additional instructions may be required to address and call imported functions. For this possibility, and to avoid having to patch the call at dynamic link time, the static linker instead generates a position-independent stub to call the function, and patches the original call to go through the stub. This stub is called a PLT entry. PLT stands for Procedure Linkage Table. (The designation of the PLT as a table is historical; its entries are independently generated code fragments and are not collected into any cohesive entity.) A PLT entry is conceptually similar to a far-call trampoline (see Section 3.2). Whereas the purpose of a trampoline is to call a far-away function, a PLT entry calls an imported function.