Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
A self-relocating program is one that relocates its address-sensitive instructions to other parts of the memory. The program performs its own relocation and does not require a linker. Self-relocation is used in time-sharing operating systems where the load address of a program may change for each different execution.
A self-relocating program alters itself to execute from a different location of the memory. Self-relocation eliminates the need to have several copies of a program on a disk, with each copy having its own different load origin. However, self-relocating programs are not necessary when the computer uses virtual memory.
During the relocation process, the program relocates its sensitive address-sensitive instructions, which allows it to execute from any part of the memory. The requirements for the relocation process are as follows:
The two functions are inbuilt into the program; the start address of the relocating code is usually specified as the execution start address of the program. Once the program is loaded into the memory for execution, the relocating logic takes control and performs the relocation using the load address and the information regarding the address-sensitive instructions.
The self-relocation process may be either static or dynamic. Static relocation is performed before the program is executed, whereas dynamic relocation is performed during program execution. Dynamic relocation may first suspend the program execution and perform the relocation, or use a relocation register.
Self-relocating programs are less efficient compared to reloadable programs.
Apart from genuine self-relocating programs, malware programs use the same self-relocation method to propagate through systems and networks to spread their malicious code.