What Is Position-Independent Code (PIC)?
Position-independent code is machine code that executes correctly no matter where in memory it is placed, because it references addresses relative to the program counter or through indirection tables. It avoids hard-coded absolute addresses that would break when the load location changes. Shared libraries are normally compiled this way so they can be mapped at any address.
Why it matters
PIC is what lets one shared library be loaded at different addresses in different processes and underpins address-space layout randomization. Without it, libraries could not be relocated freely at load time.
Related guides
What Is a Shared Object?A shared object is a library file loaded into memory at runtime and shared by multiple programs, rather than…
What Is a Relocation Table?A relocation table lists the places in an object file whose addresses must be patched once the final load add…
What Is the Global Offset Table?The global offset table is a per-module table of addresses that position-independent code reads to reach glob…