Position-independent code

In computing, position-independent code[1] (PIC[1]) or position-independent executable (PIE)[2] is a body of machine code that executes properly regardless of its memory address.[a] PIC is commonly used for shared libraries, so that the same library code can be loaded at a location in each program's address space where it does not overlap with other memory in use by, for example, other shared libraries. PIC was also used on older computer systems that lacked an MMU,[3] so that the operating system could keep applications away from each other even within the single address space of an MMU-less system.

Position-independent code can be executed at any memory address without modification. This differs from absolute code,[1] which must be loaded at a specific location to function correctly,[1] and load-time locatable (LTL) code,[1] in which a linker or program loader modifies a program before execution, so it can be run only from a particular memory location.[1] Generating position-independent code is often the default behavior for compilers, but they may place restrictions on the use of some language features, such as disallowing use of absolute addresses (position-independent code has to use relative addressing). Instructions that refer directly to specific memory addresses sometimes execute faster, and replacing them with equivalent relative-addressing instructions may result in slightly slower execution, although modern processors make the difference practically negligible.[4]

  1. ^ a b c d e f Cite error: The named reference Intel_iRMX was invoked but never defined (see the help page).
  2. ^ Cite error: The named reference RedHat_PIE was invoked but never defined (see the help page).
  3. ^ Cite error: The named reference Levine_1999_CH8 was invoked but never defined (see the help page).
  4. ^ Cite error: The named reference Gabert_2004 was invoked but never defined (see the help page).


Cite error: There are <ref group=lower-alpha> tags or {{efn}} templates on this page, but the references will not show without a {{reflist|group=lower-alpha}} template or {{notelist}} template (see the help page).