The function remains in the servers address space so

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: 5 6 7 8 9 10 11 12 13 14 15 foreach section s { foreach relocation entry r { refptr = s + r.offset; /* ptr to reference to be relocated */ /* relocate a if (r.type == refaddr = *refptr = } PC-relative reference */ R_386_PC32) { ADDR(s) + r.offset; /* ref’s runtime address */ (unsigned) (ADDR(r.symbol) + *refptr - refaddr); /* relocate an absolute reference */ if (r.type == R_386_32) *refptr = (unsigned) (ADDR(r.symbol) + *refptr); } } Figure 7.9: Relocation algorithm. Lines 1 and 2 iterate over each section s and each relocation entry r associated with each section. For concreteness, assume that each section s is an array of bytes and that each relocation entry r is a struct of type Elf32 Rel, as defined in Figure 7.8. Also, assume that when the algorithm runs, the linker has already chosen run-time addresses for each section (denoted ADDR(s)), and each symbol (denoted ADDR(r.symbol)). Line 3 computes the address in the s array of the 4-byte reference that needs to be relocated. If this reference uses PC-relative addressing, then it is relocated by lines 5–9. If the reference uses absolute addressing, then it is relocated by lines 11–13...
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