Self-Relocating Program

Why Trust Techopedia

What Does Self-Relocating Program Mean?

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.


Techopedia Explains Self-Relocating Program

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:

  • A table of the address-sensitive instructions. The program must know the translated origin and the execution start address as well as the addresses of the address-sensitive instructions.
  • A relocating logic, which is the code that performs the relocation process.

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.


Related Terms

Margaret Rouse
Technology Expert
Margaret Rouse
Technology Expert

Margaret is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical business audience. Over the past twenty years, her IT definitions have been published by Que in an encyclopedia of technology terms and cited in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine, and Discovery Magazine. She joined Techopedia in 2011. Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages.