Class ElfSegment

java.lang.Object
net.fornwall.jelf.ElfSegment

public class ElfSegment extends Object
Class corresponding to the Elf32_Phdr/Elf64_Phdr struct.

An executable or shared object file's program header table is an array of structures, each describing a segment or other information the system needs to prepare the program for execution. An object file segment contains one or more sections. Program headers are meaningful only for executable and shared object files. A file specifies its own program header size with the ELF header's e_phentsize and e_phnum members.

http://www.sco.com/developers/gabi/latest/ch5.pheader.html#p_type http://stackoverflow.com/questions/22612735/how-can-i-find-the-dynamic-libraries-required-by-an-elf-binary-in-c

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final long
    Elf{32,64}_Phdr#p_align.
    final long
    Elf{32,64}_Phdr#p_filesz.
    final int
    Flags relevant to this segment.
    final long
    Elf{32,64}_Phdr#p_memsz.
    final long
    Elf{32,64}_Phdr#p_offset.
    final long
    Reserved for the physical address of the segment on systems where physical addressing is relevant.
    final int
    Elf{32,64}_Phdr#p_type.
    final long
    Elf{32,64}_Phdr#p_vaddr.
    static final int
    The array element specifies dynamic linking information.
    static final int
    Upper bound of the range reserved for operating system-specific semantics.
    static final int
    Upper bound of the range reserved for processor-specific semantics.
    static final int
    The array element specifies the location and size of a null-terminated path name to invoke as an interpreter.
    static final int
    Type defining that the array element specifies a loadable segment.
    static final int
    Lower bound of the range reserved for operating system-specific semantics.
    static final int
    Lower bound of the range reserved for processor-specific semantics.
    static final int
    The array element specifies the location and size of auxiliary information.
    static final int
    Type defining that the array element is unused.
    static final int
    The array element, if present, specifies the location and size of the program header table itself, both in the file and in the memory image of the program.
    static final int
    This segment type is reserved but has unspecified semantics.
    static final int
    The array element specifies the Thread-Local Storage template.
  • Method Summary

    Modifier and Type
    Method
    Description
    Only for PT_INTERP headers.
    boolean
     
    boolean
     
    boolean
     
     

    Methods inherited from class java.lang.Object

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

    • PT_NULL

      public static final int PT_NULL
      Type defining that the array element is unused. Other member values are undefined.
      See Also:
    • PT_LOAD

      public static final int PT_LOAD
      Type defining that the array element specifies a loadable segment.
      See Also:
    • PT_DYNAMIC

      public static final int PT_DYNAMIC
      The array element specifies dynamic linking information.
      See Also:
    • PT_INTERP

      public static final int PT_INTERP
      The array element specifies the location and size of a null-terminated path name to invoke as an interpreter. Meaningful only for executable files (though it may occur for shared objects); it may not occur more than once in a file. If it is present, it must precede any loadable segment entry.
      See Also:
    • PT_NOTE

      public static final int PT_NOTE
      The array element specifies the location and size of auxiliary information.
      See Also:
    • PT_SHLIB

      public static final int PT_SHLIB
      This segment type is reserved but has unspecified semantics.
      See Also:
    • PT_PHDR

      public static final int PT_PHDR
      The array element, if present, specifies the location and size of the program header table itself, both in the file and in the memory image of the program. This segment type may not occur more than once in a file.
      See Also:
    • PT_TLS

      public static final int PT_TLS
      The array element specifies the Thread-Local Storage template.
      See Also:
    • PT_LOOS

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

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

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

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

      public final int p_type
      Elf{32,64}_Phdr#p_type. Kind of segment this element describes.
    • p_flags

      public final int p_flags
      Flags relevant to this segment. Values for flags are defined in ELFSectionHeader.
    • p_offset

      public final long p_offset
      Elf{32,64}_Phdr#p_offset. File offset at which the first byte of the segment resides.
    • p_vaddr

      public final long p_vaddr
      Elf{32,64}_Phdr#p_vaddr. Virtual address at which the first byte of the segment resides in memory.
    • p_paddr

      public final long p_paddr
      Reserved for the physical address of the segment on systems where physical addressing is relevant.
    • p_filesz

      public final long p_filesz
      Elf{32,64}_Phdr#p_filesz. File image size of segment in bytes, may be 0.
    • p_memsz

      public final long p_memsz
      Elf{32,64}_Phdr#p_memsz. Memory image size of segment in bytes, may be 0.
    • p_align

      public final long p_align
      Elf{32,64}_Phdr#p_align. The value to which the segments are aligned in memory and in the file.
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getIntepreter

      public String getIntepreter()
      Only for PT_INTERP headers.
      Returns:
      the interpreter path, if any
    • isReadable

      public boolean isReadable()
    • isWriteable

      public boolean isWriteable()
    • isExecutable

      public boolean isExecutable()