Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Position-independent code
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Machine instruction code that executes properly regardless of where in memory it resides}} {{redirect|PIC code|"presubscribed interexchange carrier code"|Carrier access code}} {{Use dmy dates|date=February 2020|cs1-dates=y}} {{Use list-defined references|date=January 2022}} In [[computing]], '''position-independent code'''<ref name="Intel_iRMX"/> ('''PIC'''<ref name="Intel_iRMX"/>) or '''position-independent executable''' ('''PIE''')<ref name="RedHat_PIE"/> is a body of [[machine code]] that executes properly regardless of its [[memory address]].{{efn|This allows each process using a shared copy to see it at a different virtual address.}} PIC is commonly used for [[shared library|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 [[Memory management unit|MMU]],<ref name="Levine_1999_CH8"/> 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,<ref name="Intel_iRMX"/> which must be loaded at a specific location to function correctly,<ref name="Intel_iRMX"/> and [[load-time locatable]] (LTL) code,<ref name="Intel_iRMX"/> in which a [[Linker (computing)|linker]] or [[Loader (computing)|program loader]] modifies a program before execution, so it can be run only from a particular memory location.<ref name="Intel_iRMX"/> The latter terms are sometimes referred to as ''position-dependent code''.<ref>{{cite web |url=https://docs.oracle.com/cd/E26505_01/html/E26506/glmqp.html |title=Position-Independent Code |publisher=[[Oracle]] |quote=The code within a dynamic executable is typically position-dependent, and is tied to a fixed address in memory.}}</ref> Generating position-independent code is often the default behavior for [[compiler]]s, 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 address]]ing). 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.<ref name="Gabert_2004"/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)