Unformatted text preview: ere is the disassembled listing of the .data section from swap.o:
00000000 <bufp0>: 0: 00 00 00 00 0: R_386_32 buf int *bufp0 = &buf; relocation entry We see that the .data section contains a single 32-bit reference, the bufp0 pointer, which has a value of 0x0. The relocation entry tells the linker that this is a 32-bit absolute reference, beginning at offset 0, which must relocated so that it points to the symbol buf. Now suppose that the linker has determined that
ADDR(r.symbol) = ADDR(buf) = 0x8049454 The linker updates the reference using line 13 of the algorithm in Figure 7.9:
*refptr = (unsigned) (ADDR(r.symbol) + *refptr) = (unsigned) (0x8049454 + 0) = (unsigned) (0x8049454) In the resulting executable object ﬁle, the reference has the following relocated form:
0804945c <bufp0>: 804945c: 54 94 04 08 Relocated! In words, the linker has decided that at run time, the variable bufp0 will be located at memory address 0x804945c and will be initialized to 0x8049454, which is the run-time address...
View Full Document