Linkers, Loaders & Executables
Which describes the relocation a linker performs?
- AAfter final addresses of code and data are decided, rewriting the addresses inside instructions and data with the correct values
- BMoving a running program to another computer and continuing there
- CEvicting pages to storage when memory runs short
Show answer and explanation
Answer: A. After final addresses of code and data are decided, rewriting the addresses inside instructions and data with the correct values
The compiler builds each file as if it started at address 0 and records, as relocation entries, every place that uses the address of another file's function or of its own variables. After laying out all files and deciding real addresses, the linker computes the correct address (or PC-relative distance) for each recorded place and writes it into the instruction. With dynamic linking, part of this patching is done at run time by the dynamic linker.
- A. Correct. It patches the places listed in relocation entries.
- B. That is process migration.
- C. That is the OS paging out memory.