Dynamic linking is a powerful and useful technique

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: nce should point to */ /* relocation type */ code/link/elfstructs.c Figure 7.8: ELF relocation entry. Each entry identifies a reference that must be relocated. ELF defines 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 modifications. 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

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online