Actually, "position independent code" does not require "relocation" in the traditional sense, and that is the point. It requires that some CPU register point to the location (in virtual memory ...) where the code has been loaded, and all references are relative to that register's current value. The code could be "binary copied" to some other place in memory and, so long as the CPU register's value is once again correct, it will continue to run normally.
Non-position-independent code contains (virtual ...) memory references which must be resolved by the operating system's "loader" before the program begins to run, and it cannot be moved elsewhere. The program-file specifies where these memory references are located, and the loader "fixes them up" before the program starts.
Last edited by sundialsvcs; 12-14-2021 at 08:55 AM.
|