Class ElfSectionHeader

java.lang.Object
net.fornwall.jelf.ElfSectionHeader

public class ElfSectionHeader extends Object
Class corresponding to the Elf32_Shdr/Elf64_Shdr struct.

An object file's section header table lets one locate all the file's sections. The section header table is an array of Elf32_Shdr or Elf64_Shdr structures. A section header table index is a subscript into this array. The ELF header's e_shoff member gives the byte offset from the beginning of the file to the section header table with each section header entry being e_shentsize bytes big.

e_shnum normally tells how many entries the section header table contains, but if the number of sections is greater than or equal to SHN_LORESERVE (0xff00), e_shnum has the value SHN_UNDEF (0) and the actual number of section header table entries is contained in the sh_size field of the section header at index 0 (otherwise, the sh_size member of the initial entry contains 0).

Some section header table indexes are reserved in contexts where index size is restricted, for example, the st_shndx member of a symbol table entry and the e_shnum and e_shstrndx members of the ELF header. In such contexts, the reserved values do not represent actual sections in the object file. Also in such contexts, an escape value indicates that the actual section index is to be found elsewhere, in a larger field.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Flag informing that section occupies memory during process execution.
    static final int
    Flag informing that section contains executable machine instructions.
    static final int
    Flag informing that all the bits in the mask are reserved for processor specific semantics.
    static final int
    Flag informing that this section contains data that should be writable during process execution.
    static final String
    Name for the section containing the dynamic string table.
    static final String
    Name for the section containing read-only initialized data.
    static final String
    Name for the section containing the string table.
    final long
    sh_addr.
    final long
    Address alignment constraints for the section.
    final long
    Size of a fixed-size entry, 0 if none.
    final long
    Flags.
    final int
    Extra information determined by the section type.
    final int
    Section header table index link.
    final int
    Index into the section header string table which gives the name of the section.
    final long
    Offset from beginning of file to first byte of the section.
    final long
    Size in bytes of the section.
    final int
    Section content and semantics.
    static final int
    Section holds information for dynamic linking.
    static final int
    The sh_type value for a section containing a minimal set of symbols needed for dynamic linking at runtime.
    static final int
     
    static final int
    A hash table for fast lookup of dynamic symbols.
    static final int
     
    static final int
     
    static final int
     
    static final int
     
    static final int
    Section holds symbol hash table.
    static final int
    Upper bound of the range of indexes reserved for operating system-specific semantics.
    static final int
    Upper bound of the range of indexes reserved for processor-specific semantics.
    static final int
    Upper bound of the range of indexes reserved for application programs.
    static final int
     
    static final int
    Lower bound of the range of indexes reserved for operating system-specific semantics.
    static final int
    Lower bound of the range of indexes reserved for processor-specific semantics.
    static final int
    Lower bound of the range of indexes reserved for application programs.
    static final int
    Section occupies no space but resembles TYPE_PROGBITS.
    static final int
    Section holds information that marks the file.
    static final int
    Marks the section header as inactive; it does not have an associated section.
    static final int
     
    static final int
    Section holds information defined by the program.
    static final int
    Section holds relocation entries without explicit addends.
    static final int
    Section holds relocation entries with explicit addends.
    static final int
    Section is reserved but has unspecified semantics.
    static final int
    Section holds string table information.
    static final int
    The sh_type value for a section containing complete symbol table information necessary for link editing.
    static final int
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the name of the section or null if the section has no name.
     

    Methods inherited from class java.lang.Object

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

    • SHT_NULL

      public static final int SHT_NULL
      Marks the section header as inactive; it does not have an associated section. Other members of the section header have undefined values.
      See Also:
    • SHT_PROGBITS

      public static final int SHT_PROGBITS
      Section holds information defined by the program.
      See Also:
    • SHT_SYMTAB

      public static final int SHT_SYMTAB
      The sh_type value for a section containing complete symbol table information necessary for link editing.

      See ElfSymbolTableSection, which is the class representing sections of this type, for more information.

      See Also:
    • SHT_STRTAB

      public static final int SHT_STRTAB
      Section holds string table information.
      See Also:
    • SHT_RELA

      public static final int SHT_RELA
      Section holds relocation entries with explicit addends.
      See Also:
    • SHT_HASH

      public static final int SHT_HASH
      Section holds symbol hash table.
      See Also:
    • SHT_DYNAMIC

      public static final int SHT_DYNAMIC
      Section holds information for dynamic linking. Only one per ELF file. The dynsym is allocable, and contains the symbols needed to support runtime operation.
      See Also:
    • SHT_NOTE

      public static final int SHT_NOTE
      Section holds information that marks the file.
      See Also:
    • SHT_NOBITS

      public static final int SHT_NOBITS
      Section occupies no space but resembles TYPE_PROGBITS.
      See Also:
    • SHT_REL

      public static final int SHT_REL
      Section holds relocation entries without explicit addends.
      See Also:
    • SHT_SHLIB

      public static final int SHT_SHLIB
      Section is reserved but has unspecified semantics.
      See Also:
    • SHT_DYNSYM

      public static final int SHT_DYNSYM
      The sh_type value for a section containing a minimal set of symbols needed for dynamic linking at runtime.

      See ElfSymbolTableSection, which is the class representing sections of this type, for more information.

      See Also:
    • SHT_INIT_ARRAY

      public static final int SHT_INIT_ARRAY
      See Also:
    • SHT_FINI_ARRAY

      public static final int SHT_FINI_ARRAY
      See Also:
    • SHT_PREINIT_ARRAY

      public static final int SHT_PREINIT_ARRAY
      See Also:
    • SHT_GROUP

      public static final int SHT_GROUP
      See Also:
    • SHT_SYMTAB_SHNDX

      public static final int SHT_SYMTAB_SHNDX
      See Also:
    • SHT_GNU_HASH

      public static final int SHT_GNU_HASH
      A hash table for fast lookup of dynamic symbols.

      See ElfGnuHashTable.

      See Also:
    • SHT_GNU_verdef

      public static final int SHT_GNU_verdef
      See Also:
    • SHT_GNU_verneed

      public static final int SHT_GNU_verneed
      See Also:
    • SHT_GNU_versym

      public static final int SHT_GNU_versym
      See Also:
    • SHT_LOOS

      public static final int SHT_LOOS
      Lower bound of the range of indexes reserved for operating system-specific semantics.
      See Also:
    • SHT_HIOS

      public static final int SHT_HIOS
      Upper bound of the range of indexes reserved for operating system-specific semantics.
      See Also:
    • SHT_LOPROC

      public static final int SHT_LOPROC
      Lower bound of the range of indexes reserved for processor-specific semantics.
      See Also:
    • SHT_HIPROC

      public static final int SHT_HIPROC
      Upper bound of the range of indexes reserved for processor-specific semantics.
      See Also:
    • SHT_LOUSER

      public static final int SHT_LOUSER
      Lower bound of the range of indexes reserved for application programs.
      See Also:
    • SHT_HIUSER

      public static final int SHT_HIUSER
      Upper bound of the range of indexes reserved for application programs.
      See Also:
    • FLAG_WRITE

      public static final int FLAG_WRITE
      Flag informing that this section contains data that should be writable during process execution.
      See Also:
    • FLAG_ALLOC

      public static final int FLAG_ALLOC
      Flag informing that section occupies memory during process execution.
      See Also:
    • FLAG_EXEC_INSTR

      public static final int FLAG_EXEC_INSTR
      Flag informing that section contains executable machine instructions.
      See Also:
    • FLAG_MASK

      public static final int FLAG_MASK
      Flag informing that all the bits in the mask are reserved for processor specific semantics.
      See Also:
    • NAME_STRTAB

      public static final String NAME_STRTAB
      Name for the section containing the string table.

      This section contains a string table which contains names for symbol structures by being indexed by the ElfSymbol.st_name field.

      See Also:
    • NAME_DYNSTR

      public static final String NAME_DYNSTR
      Name for the section containing the dynamic string table.
      See Also:
    • NAME_RODATA

      public static final String NAME_RODATA
      Name for the section containing read-only initialized data.
      See Also:
    • sh_name

      public final int sh_name
      Index into the section header string table which gives the name of the section.
    • sh_type

      public final int sh_type
      Section content and semantics.
    • sh_flags

      public final long sh_flags
      Flags.
    • sh_addr

      public final long sh_addr
      sh_addr. If the section will be in the memory image of a process this will be the address at which the first byte of section will be loaded. Otherwise, this value is 0.
    • sh_offset

      public final long sh_offset
      Offset from beginning of file to first byte of the section.
    • sh_size

      public final long sh_size
      Size in bytes of the section. TYPE_NOBITS is a special case.
    • sh_info

      public final int sh_info
      Extra information determined by the section type.
    • sh_addralign

      public final long sh_addralign
      Address alignment constraints for the section.
    • sh_entsize

      public final long sh_entsize
      Size of a fixed-size entry, 0 if none.
  • Method Details

    • getName

      public String getName()
      Returns the name of the section or null if the section has no name.
      Returns:
      the name of the section, if any
    • toString

      public String toString()
      Overrides:
      toString in class Object