Class ElfRelocation

java.lang.Object
net.fornwall.jelf.ElfRelocation

public final class ElfRelocation extends Object
A relocation connects a symbolic reference with its actual definition. Relocatable files must have information that describes how to modify their section contents, thus allowing executable and shared object files to hold the right information for a process's program image. Relocation entries are these data.

These elf relocation entries can be obtained from ElfRelocationSection:s.

Corresponds to the below C structs:


 typedef struct {
   Elf32_Addr r_offset;
   Elf32_Word r_info;
 } Elf32_Rel;

 typedef struct {
   Elf64_Addr   r_offset;
   Elf64_Xword r_info;
 } Elf64_Rel;
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final long
    This member gives both the symbol table index to which the relocation must be made, and the type of relocation to apply.
    final long
    The location at which to apply the relocation.
  • Method Summary

    Modifier and Type
    Method
    Description
    The symbol with respect to which the relocation must be made.
    int
    The symbol table index, with respect to which the relocation must be made.
    long
    Corresponds to the ELF32_R_TYPE / ELF64_R_TYPE macros.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • r_offset

      public final long r_offset
      The location at which to apply the relocation. For a relocatable file, this is the byte offset from the beginning of the section. For an executable or shared object, the value is the virtual address.
    • r_info

      public final long r_info
      This member gives both the symbol table index to which the relocation must be made, and the type of relocation to apply. Relocation types are processor specific.
  • Method Details

    • getType

      public long getType()
      Corresponds to the ELF32_R_TYPE / ELF64_R_TYPE macros.
      See Also:
    • getSymbolIndex

      public int getSymbolIndex()
      The symbol table index, with respect to which the relocation must be made. Use getSymbol() to get the resolved ElfSymbol from this index.

      Corresponds to the ELF32_R_SYM / ELF64_R_SYM macros.

    • getSymbol

      public ElfSymbol getSymbol()
      The symbol with respect to which the relocation must be made. Use getSymbolIndex()} to get the resolved ElfSymbol from this index.