What is Position-independent code?

Machine code that runs without modification at any load address, also called PIC. It uses PC-relative references and the GOT and is used for shared libraries and PIEs.

Field: Linkers, Loaders & Executables

Position-independent code in the explanations

Questions that mention Position-independent code (5)

  1. Which describes position-independent code (PIC)?
  2. What is an advantage of using PC-relative addressing for branches and jumps?
  3. What does the RISC-V auipc instruction (add upper immediate to PC) do?
  4. What is the role of the GOT (global offset table) used in shared libraries?
  5. What is the main reason to build an executable as a PIE (position-independent executable)?

Related terms

Shared library PC-relative addressing Branch prediction Global offset table Dynamic linker Position-independent executable Address space layout randomization (ASLR) BSS section Dynamic linking Entry point

Back to the glossary