Position-independent code

from Wikipedia, the free encyclopedia

Position-independent code ( PIC ; German: position -independent code ) or position-independent executable ( PIE ; German: position-independent executable program ) denotes machine code that can be executed regardless of the address at which it is located in the main memory . PIC is typically used for dynamic libraries so that they can be loaded into any memory location for any program where they do not overlap with other objects in the program. On older computers without an MMU , PIC was used to load the various programs into memory at the same time, although such systems only have one address space .

Position-independent code differs from relocatable code , in which all addresses used for memory accesses by the linker or loader must be adapted to the current position in the memory before execution . In order to generate position-independent code, the compiler must support this type of addressing. He must replace all machine commands that refer to an absolute memory address with corresponding commands that work relative to the current position. This additional indirection can cause positional code to execute more slowly than the identical program in positional code.

With the transition to virtual addressing by the MMU, it has become possible to always load program code to the same virtual address, so that PIC has lost its importance.

Web links