Module goblin::elf::reloc

source ·
Expand description

§Relocation computations

The following notation is used to describe relocation computations specific to x86_64 ELF.

  • A: The addend used to compute the value of the relocatable field.
  • B: The base address at which a shared object is loaded into memory during execution. Generally, a shared object file is built with a base virtual address of 0. However, the execution address of the shared object is different.
  • G: The offset into the global offset table at which the address of the relocation entry’s symbol resides during execution.
  • GOT: The address of the global offset table.
  • L: The section offset or address of the procedure linkage table entry for a symbol.
  • P: The section offset or address of the storage unit being relocated, computed using r_offset.
  • S: The value of the symbol whose index resides in the relocation entry.
  • Z: The size of the symbol whose index resides in the relocation entry.

Below are some common x86_64 relocation computations you might find useful:

RelocationValueSizeFormula
R_X86_64_NONE0NONENONE
R_X86_64_64164S + A
R_X86_64_PC32232S + A - P
R_X86_64_GOT32332G + A
R_X86_64_PLT32432L + A - P
R_X86_64_COPY5NONENONE
R_X86_64_GLOB_DAT664S
R_X86_64_JUMP_SLOT764S
R_X86_64_RELATIVE864B + A
R_X86_64_GOTPCREL932G + GOT + A - P
R_X86_64_321032S + A
R_X86_64_32S1132S + A
R_X86_64_161216S + A
R_X86_64_PC161316S + A - P
R_X86_64_8148S + A
R_X86_64_PC8158S + A - P
R_X86_64_DTPMOD641664
R_X86_64_DTPOFF641764
R_X86_64_TPOFF641864
R_X86_64_TLSGD1932
R_X86_64_TLSLD2032
R_X86_64_DTPOFF322132
R_X86_64_GOTTPOFF2232
R_X86_64_TPOFF322332
R_X86_64_PC642464S + A - P
R_X86_64_GOTOFF642564S + A - GOT
R_X86_64_GOTPC322632GOT + A - P
R_X86_64_SIZE323232Z + A
R_X86_64_SIZE643364Z + A
R_X86_64_GOTPC32_TLSDESC3432
R_X86_64_TLSDESC_CALL35NONE
R_X86_64_TLSDESC3664 × 2
R_X86_64_IRELATIVE3764indirect (B + A)

TLS information is at http://people.redhat.com/aoliva/writeups/TLS/RFC-TLSDESC-x86.txt

R_X86_64_IRELATIVE is similar to R_X86_64_RELATIVE except that the value used in this relocation is the program address returned by the function, which takes no arguments, at the address of the result of the corresponding R_X86_64_RELATIVE relocation.

Read more https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-54839.html

Modules§

Structs§

Constants§

Functions§