| • Science | • People | • Locations | • Timeline |
Code must generally be written or compiled in a special fashion in order to be position independent. Instructions that refer to specific memory addresses, such as absolute branches, must be replaced with equivalent program counter relative instructions. The extra indirection may cause PIC code to be less efficient, although modern processors are designed to ameliorate this.
Procedure calls inside a shared library are typically made through small procedure linkage table stubs, which then call the definitive function. This notably allows a shared library to inherit certain function calls from previously loaded libraries rather than eg. using its own versions.
Data references from position independent code are usually made indirectly, thru global offset table s ( GOTs), which stores the addresses of all accessed global variables. There is one GOT per compilation unit or object module, and it is located at a fixed offset from the code (although this offset is not known till the library is linked). When the different modules are linked together by a linker in order to create the shared library, the GOTs are merged and the final offsets are set in code. It is no more necessary to adjust the offsets when loading the shared library later.
Position independent functions accessing global data start by determining the absolute address of the GOT given their own current program counter value. This often takes the form of a fake function call in order to obtain the return value on stack ( x86) or in a special register ( PowerPCPowerPC is a RISC microprocessor architecture created by the 1991 Apple- IBM- Motorola alliance, known as AIM''. The PowerPC was the CPU portion of the overall AIM platform, and is the only part to exist to date. History The history of the PowerPC begins), which can then be stored in a predefined standard register. Some processor architectures, like the Motorola 68000The Motorola 68000 is a CISC microprocessor, the first member of a successful family of microprocessors from Motorola, which were all mostly software compatible. The entire series was often referred to as the m68k or simply 68k History Originally, the MC6, the new AMD64The AMD64 is a 64-bit processor architecture invented by AMD. It is a superset of the x86 architecture, which it natively supports. Architecture overview TODO write about the AMD64 architecture. New instructions, capabilities, register sizes, etc. NX Bit, and probably IntelThe following article is about the multinational corporation; intel is also an abbreviation for intelligence, used in reference to military intelligence and espionage. Intel Corporation is a US-based multinational corporation that is best known for design's EM64TExtended Memory 64-bit Technology (EM64T is Intel's implementation of AMD's AMD64 architecture, an extension to the IA-32 instruction set which adds 64 bit extensions to the x86 architecture. It is almost entirely compatible with AMD64. Intel's first proc allow referencing data by offset from the program counter. This is specifically targeted at making position-independent code smaller, less register demanding and hence more efficient. Note however that there is still an indirection, since the address must be fetched from the GOT.