This preview shows page 1. Sign up to view the full content.
Unformatted text preview: t module (including shared object modules) in memory, the data segment is always allocated immediately after the code segment. Thus, the distance between any instruction in the code segment and any variable in the data segment is a run-time constant, independent of the absolute memory locations of the code and data segments. To exploit this fact, the compiler creates a table called the global offset table (GOT) at the beginning of the data segment. The GOT contains an entry for each global data object that is referenced by the object module. The compiler also generates a relocation record for each entry in the GOT. At load time, the dynamic linker relocates each entry in the GOT so that it contains the appropriate absolute address. Each object module that references global data has its own GOT. At run time, each global variable is referenced indirectly through the GOT using code of the form:
call L1: popl addl movl movl L1 %ebx; $VAROFF, %ebx (%ebx), %eax (%eax), %eax # ebx contains the current PC # ebx points to the GOT entry for var # reference indirect through the...
View Full Document
- Spring '10
- The American