Position-Independent Code

This product was added to computer science because of the content, defects on the quality assurance side of the editor. This is done to bring the quality of the articles from the computer science subject area to an acceptable level. Help us to eliminate the substantive shortcomings of this article and take part you in the discussion! ( ) Reason: structure and sources - Crazy1880 18:58, May 6, 2011 (UTC)

Position -independent code (PIC, engl. For position -independent code ) is machine code that can be executed, regardless of where absolute address in main memory it is located. PIC is commonly used for dynamic libraries, so they can be loaded for each program to a location where they do not overlap with other objects of this program. On older computers without MMU PIC was used to load the different programs at the same time in the memory, although such systems have only one address space.

Position -independent code can be copied to any location in memory and executed from there without any changes. Thus it differs from relozierbarem code that requires special processing by the linker or loader before it can be executed at a specific memory location. The source code that is generated from the PIC must meet certain requirements. Similarly, the compiler must support it. He has all the machine instructions, which refer to an absolute memory address, replaced by corresponding commands that work relative to the program counter (or the stack pointer ). This extra indirection may cause position -independent code runs slower than equivalent position-dependent code.

With the transition to virtual addressing by the MMU, it has become possible to program code to always load on the same ( virtual ) addresses so that PIC has lost meaning.