Class ElfSymbol

java.lang.Object
net.fornwall.jelf.ElfSymbol

public final class ElfSymbol extends Object
An entry in the ElfSymbolTableSection, which holds information needed to locate and relocate a program's symbolic definitions and references.

In the elf.h header file the struct definitions are:

 typedef struct {
     uint32_t      st_name;
     Elf32_Addr    st_value;
     uint32_t      st_size;
     unsigned char st_info;
     unsigned char st_other;
     uint16_t      st_shndx;
 } Elf32_Sym;

 typedef struct {
     uint32_t      st_name;
     unsigned char st_info;
     unsigned char st_other;
     uint16_t      st_shndx;
     Elf64_Addr    st_value;
     uint64_t      st_size;
 } Elf64_Sym;
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Binding specifying that global symbols are visible to all object files being combined.
    static final int
    Upper bound binding values reserved for processor specific semantics.
    static final int
    Binding specifying that local symbols are not visible outside the object file that contains its definition.
    static final int
    Lower bound binding values reserved for processor specific semantics.
    static final int
    Binding specifying that the symbol resembles a global symbol, but has a lower precedence.
    final long
    Offset from the beginning of the file to this symbol.
    final int
     
    final short
    Specifies the symbol type and binding attributes.
    final int
    Index into the symbol string table that holds the character representation of the symbols.
    final short
    Currently holds the value of 0 and has no meaning.
    final short
    Index to the associated section header.
    final long
    Size of the symbol.
    final long
    Value of the associated symbol.
    static final byte
    The symbol labels an uninitialized common block.
    static final byte
    Type defining that the symbol is associated with a file.
    static final byte
    Type specifying that the symbol is associated with a function or other executable code.
    static final byte
    Upper bound for range reserved for operating system-specific semantics.
    static final byte
    Upper bound for range reserved for processor-specific semantics.
    static final byte
    Lower bound for range reserved for operating system-specific semantics.
    static final byte
    Lower bound for range reserved for processor-specific semantics.
    static final byte
    Type specifying that the symbol is unspecified.
    static final byte
    Type specifying that the symbol is associated with an object.
    static final byte
    Type specifying that the symbol is associated with a section.
    static final byte
    The symbol specifies a Thread-Local Storage entity.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the binding for this symbol, extracted from the st_info field.
    Returns the name of the symbol or null if the symbol has no name.
    int
    Returns the symbol type, extracted from the st_info field.
    net.fornwall.jelf.ElfSymbol.Visibility
     
     

    Methods inherited from class java.lang.Object

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

    • BINDING_LOCAL

      public static final int BINDING_LOCAL
      Binding specifying that local symbols are not visible outside the object file that contains its definition.
      See Also:
    • BINDING_GLOBAL

      public static final int BINDING_GLOBAL
      Binding specifying that global symbols are visible to all object files being combined.
      See Also:
    • BINDING_WEAK

      public static final int BINDING_WEAK
      Binding specifying that the symbol resembles a global symbol, but has a lower precedence.
      See Also:
    • BINDING_LOPROC

      public static final int BINDING_LOPROC
      Lower bound binding values reserved for processor specific semantics.
      See Also:
    • BINDING_HIPROC

      public static final int BINDING_HIPROC
      Upper bound binding values reserved for processor specific semantics.
      See Also:
    • STT_NOTYPE

      public static final byte STT_NOTYPE
      Type specifying that the symbol is unspecified.
      See Also:
    • STT_OBJECT

      public static final byte STT_OBJECT
      Type specifying that the symbol is associated with an object.
      See Also:
    • STT_FUNC

      public static final byte STT_FUNC
      Type specifying that the symbol is associated with a function or other executable code.
      See Also:
    • STT_SECTION

      public static final byte STT_SECTION
      Type specifying that the symbol is associated with a section. Symbol table entries of this type exist for relocation and normally have the binding BINDING_LOCAL.
      See Also:
    • STT_FILE

      public static final byte STT_FILE
      Type defining that the symbol is associated with a file.
      See Also:
    • STT_COMMON

      public static final byte STT_COMMON
      The symbol labels an uninitialized common block.
      See Also:
    • STT_TLS

      public static final byte STT_TLS
      The symbol specifies a Thread-Local Storage entity.
      See Also:
    • STT_LOOS

      public static final byte STT_LOOS
      Lower bound for range reserved for operating system-specific semantics.
      See Also:
    • STT_HIOS

      public static final byte STT_HIOS
      Upper bound for range reserved for operating system-specific semantics.
      See Also:
    • STT_LOPROC

      public static final byte STT_LOPROC
      Lower bound for range reserved for processor-specific semantics.
      See Also:
    • STT_HIPROC

      public static final byte STT_HIPROC
      Upper bound for range reserved for processor-specific semantics.
      See Also:
    • st_name

      public final int st_name
      Index into the symbol string table that holds the character representation of the symbols. 0 means the symbol has no character name.
    • st_value

      public final long st_value
      Value of the associated symbol. This may be a relative address for .so or absolute address for other ELFs.
    • st_size

      public final long st_size
      Size of the symbol. 0 if the symbol has no size or the size is unknown.
    • st_info

      public final short st_info
      Specifies the symbol type and binding attributes.
    • st_other

      public final short st_other
      Currently holds the value of 0 and has no meaning.
    • st_shndx

      public final short st_shndx
      Index to the associated section header. This value will need to be read as an unsigned short if we compare it to ELFSectionHeader.NDX_LORESERVE and ELFSectionHeader.NDX_HIRESERVE.
    • section_type

      public final int section_type
    • offset

      public final long offset
      Offset from the beginning of the file to this symbol.
  • Method Details

    • getBinding

      public int getBinding()
      Returns the binding for this symbol, extracted from the st_info field.
      Returns:
      the binding for this symbol
    • getType

      public int getType()
      Returns the symbol type, extracted from the st_info field.
      Returns:
      the type of this symbol
    • getName

      public String getName() throws ElfException
      Returns the name of the symbol or null if the symbol has no name.
      Returns:
      the name of this symbol, if any
      Throws:
      ElfException
    • getVisibility

      public net.fornwall.jelf.ElfSymbol.Visibility getVisibility()
    • toString

      public String toString()
      Overrides:
      toString in class Object