Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the concept of relocation mean? [closed]

I'm new to assembly and hence want to understand more about the concept of relocation.

  1. Why exactly do we need to relocate programs, data?
  2. How exactly is it done?

It would be great if someone could explain with a beginner level example.

like image 813
Shivaji_Vidhale Avatar asked May 05 '13 15:05

Shivaji_Vidhale


People also ask

What does the term relocation mean?

Definition of relocate transitive verb. : to locate again : establish or lay out in a new place. intransitive verb. : to move to a new location.

What does relocation mean in social studies?

Relocation is the act of displacing residents, community facilities, or businesses from structures or land taken by eminent domain for transportation projects.

What does relocation work mean?

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.

What is the difference between moving and relocation?

“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.


1 Answers

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.

like image 133
bmargulies Avatar answered Oct 02 '22 16:10

bmargulies