I'm new to assembly and hence want to understand more about the concept of relocation.
It would be great if someone could explain with a beginner level example.
Definition of relocate transitive verb. : to locate again : establish or lay out in a new place. intransitive verb. : to move to a new location.
Relocation is the act of displacing residents, community facilities, or businesses from structures or land taken by eminent domain for transportation projects.
What is relocation? Relocation in a professional sense is when an employer asks you to move in order to be closer to their office. Relocations are common for highly skilled professionals who attract the attention of employers from different cities. You may also experience having to move for your current employer.
“Relocating” technically means the same thing, although they could be different in slight ways. The term relocation is usually used more formally, especially if you are looking to move a considerable distance. In this case, an international relocation involves moving to another country.
The assembler has one source file to look at. It has to build a memory image based on that one source file. So it starts with 0 for the code, and also for 0 with the data. The results go into an object file.
Now, the linker comes along and needs to combine many object files into an executable (or kernel image, or whatever). It can't leave everyone at 0, they would overlap. So it must relocate the addresses to assign each object file's worth of data to a unique range.
Then, then the image is loaded into virtual memory, the operating system may have good reasons to want to use an address other than '0' as the base virtual address. So, at runtime, it wants to relocate everything again.
Finally, if there are shared libraries involved, neither the assembler nor the linker knows where they will be in the running environment, and so the references to them must be relocated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With