Relocation (computing): Difference between revisions

Content deleted Content added
Added {{More footnotes needed}} tag
start review: rm unsupported and unclear. mv alternatives to body. rm unnec anchors, if anchor/section is not found redirect takes you to the top of the article anyway.
Line 5:
{{Use list-defined references|date=December 2021}}
{{Use American English|date=January 2019}}
{{anchor|Static|Dynamic|Compile-time|Load-time|Run-Time|Virtual|Page boundary|Paragraph boundary|Segment|Offset|Line}}
'''Relocation''' is the process of assigning load addresses for position-dependent code and data of a program and adjusting the code and data to reflect the assigned addresses.<ref name="Intel_iRMX"/><ref name="Levine_1999_CH1_CH3"/> Prior to the advent of multiprocess systems, and still in many embedded systems, the addresses for objects are [[absolute address|absolute]] starting at a known ___location, often zero. Since multiprocessing systems dynamically link and switch between programs it became necessary to be able to relocate objects using [[position-independent code]].
A [[linker (computing)|linker]] usually performs relocation in conjunction with '''symbol resolution''', the process of searching files and libraries to replace symbolic references or names of [[library (computer science)|libraries]] with actual usable addresses in [[primary storage|memory]] before running a program.
 
In [[software development]], '''relocation''' is the process of assigning load addresses for [[position-dependent]] code and data of a program and adjusting the code and data to reflect the assigned addresses.<ref name="Intel_iRMX"/><ref name="Levine_1999_CH1_CH3"/>
Relocation is typically done by the linker at [[link time]], but it can also be done at [[load time]] by a relocating [[loader (computing)|loader]], or at [[run time (program lifecycle phase)|run time]] by the running program [[self-relocation|itself]]. Some architectures avoid relocation entirely by deferring address assignment to run time; as, for example, in stack machines with [[zero address arithmetic]] or in some segmented architectures where every compilation unit is loaded into a separate segment.
 
A [[linker (computing)|linker]] usually performs relocation in conjunction with '''symbol resolution''', the process of searching files and libraries to replace symbolic references or names of [[library (computer science)|libraries]] with actual usable addresses in [[primary storage|memory]] before running a program.
 
Relocation is typically done by the linker at [[link time]], but it can also be done at [[load time]] by a relocating [[loader (computing)|loader]], or at [[run time (program lifecycle phase)|run time]] by the running program [[self-relocation|itself]]. Some architectures avoid relocation entirely by deferring address assignment to run time; as, for example, in stack machines with <!--[[zero address arithmeticUser:Kvng/RTH]] or in some segmented architectures where every compilation unit is loaded into a separate segment.-->
 
== Segmentation ==
Line 48 ⟶ 49:
* (C) If ''SUBR'' is later linked with other code it may be stored at a ___location other than 1. In this example the linker places it at ___location 120. The address in the jump instruction, which is now at ___location 133, must be '''relocated''' to point to the new ___location of the code for statement ''ST'', now 125. [1 61 shown in the instruction is the MIX machine code representation of 125].
* (D) When the program is loaded into memory to run it may be loaded at some ___location other than the one assigned by the linker. This example shows ''SUBR'' now at ___location 300. The address in the jump instruction, now at 313, needs to be relocated again so that it points to the updated ___location of ''ST'', 305. [4 49 is the MIX machine representation of 305].
 
==Alternatives==
Some architectures avoid relocation entirely by deferring address assignment to run time; as, for example, in stack machines with [[zero address arithmetic]] or in some segmented architectures where every compilation unit is loaded into a separate segment.
 
== See also ==