The relocations that are listed in the following table are defined for 32–bit x86.
Table 7–15 32-bit x86: ELF Relocation Types
Name |
Value |
Field |
Calculation |
---|---|---|---|
R_386_NONE |
0 |
None |
None |
R_386_32 |
1 |
word32 |
S + A |
R_386_PC32 |
2 |
word32 |
S + A - P |
R_386_GOT32 |
3 |
word32 |
G + A |
R_386_PLT32 |
4 |
word32 |
L + A - P |
R_386_COPY |
5 |
None |
Refer to the explanation following this table. |
R_386_GLOB_DAT |
6 |
word32 |
S |
R_386_JMP_SLOT |
7 |
word32 |
S |
R_386_RELATIVE |
8 |
word32 |
B + A |
R_386_GOTOFF |
9 |
word32 |
S + A - GOT |
R_386_GOTPC |
10 |
word32 |
GOT + A - P |
R_386_32PLT |
11 |
word32 |
L + A |
R_386_16 |
20 |
word16 |
S + A |
R_386_PC16 |
21 |
word16 |
S + A - P |
R_386_8 |
22 |
word8 |
S + A |
R_386_PC8 |
23 |
word8 |
S + A - P |
Additional relocations are available for thread-local storage references. These relocations are covered in Chapter 8, Thread-Local Storage.
Some relocation types have semantics beyond simple calculation.
Computes the distance from the base of the GOT to the symbol's GOT entry. The relocation also instructs the link-editor to create a global offset table.
Computes the address of the symbol's procedure linkage table entry and instructs the link-editor to create a procedure linkage table.
Created by the link-editor for dynamic executables to preserve a read-only text segment. The relocation offset member refers to a location in a writable segment. The symbol table index specifies a symbol that should exist both in the current object file and in a shared object. During execution, the runtime linker copies data associated with the shared object's symbol to the location specified by the offset. See Copy Relocations.
Used to set a GOT entry to the address of the specified symbol. The special relocation type enable you to determine the correspondence between symbols and GOT entries.
Created by the link-editor for dynamic objects to provide lazy binding. The relocation offset member gives the location of a procedure linkage table entry. The runtime linker modifies the procedure linkage table entry to transfer control to the designated symbol address.
Created by the link-editor for dynamic objects. The relocation offset member gives the location within a shared object that contains a value representing a relative address. The runtime linker computes the corresponding virtual address by adding the virtual address at which the shared object is loaded to the relative address. Relocation entries for this type must specify a value of zero for the symbol table index.
Computes the difference between a symbol's value and the address of the GOT. The relocation also instructs the link-editor to create the global offset table.
Resembles R_386_PC32, except that it uses the address of the GOT in its calculation. The symbol referenced in this relocation normally is _GLOBAL_OFFSET_TABLE_, which also instructs the link-editor to create the global offset table.