Unformatted text preview: nce should point to */ /* relocation type */ code/link/elfstructs.c Figure 7.8: ELF relocation entry. Each entry identiﬁes a reference that must be relocated. ELF deﬁnes 11 different relocation types, some quite arcane. We are concerned with only the two most basic relocation types: ¯ R 386 PC32: Relocate a reference that uses a 32-bit PC-relative address. Recall from Section 3.6.3 that a PC-relative address is an offset from the current run-time value of the program counter (PC). 7.7. RELOCATION 367 When the CPU executes an instruction using PC-relative addressing, it forms the effective address (e.g., the target of the call instruction) by adding the 32-bit value encoded in the instruction to the current run-time value of the PC, which is always the address of the next instruction in memory. ¯ R 386 32: Relocate a reference that uses a 32-bit absolute address. With absolute addressing, the CPU directly uses the 32-bit value encoded in the instruction as the effective address, without further modiﬁcations. 7.7.2 Relocating Symbol References
Figure 7.9 shows the pseudo-code for the linker’s relocation algorithm.
1 2 3 4...
View Full Document