Samiksha Jaiswal (Editor)

Self relocation

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In computer programming, a self-relocating program is a program that relocates its own address-dependent instructions and data when run, and is therefore capable of being loaded into memory at any address. In most cases, self-relocating code is also a form of self-modifying code.

Discussion

Self-relocation is similar to the relocation process employed by the linker-loader when a program is copied from external storage into main memory; the difference is that it is the loaded program itself rather than the loader in the operating system or shell that performs the relocation. As an example, self-relocation is often employed in the early stages of bootstrapping operating systems on architectures like IBM PC compatibles, where lower-level chain boot loaders (like the Master Bootstrap Record, Volume Boot Record and initial boot stages of operating systems such as DOS) move themselves out of place in order to load the next stage into memory. Under DOS, self-relocation was sometimes also used by more advanced drivers and TSRs loading themselves "high" more effectively than possible for the operating system's built-in loaders in order to maximize the memory available for applications.

Self-relocation typically happens at load-time, sometimes also when changing the program's configuration at a later stage during runtime.

As an extreme example of self-relocation it is possible to construct a computer program so that it does not stay at a fixed address in memory, even as it executes. The Apple Worm is a dynamic self-relocator.

References

Self-relocation Wikipedia