Package net.fornwall.jelf
Class ElfSymbol
java.lang.Object
net.fornwall.jelf.ElfSymbol
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
FieldsModifier and TypeFieldDescriptionstatic final intBinding specifying that global symbols are visible to all object files being combined.static final intUpper bound binding values reserved for processor specific semantics.static final intBinding specifying that local symbols are not visible outside the object file that contains its definition.static final intLower bound binding values reserved for processor specific semantics.static final intBinding specifying that the symbol resembles a global symbol, but has a lower precedence.final longOffset from the beginning of the file to this symbol.final intfinal shortSpecifies the symbol type and binding attributes.final intIndex into the symbol string table that holds the character representation of the symbols.final shortCurrently holds the value of 0 and has no meaning.final shortIndex to the associated section header.final longSize of the symbol.final longValue of the associated symbol.static final byteThe symbol labels an uninitialized common block.static final byteType defining that the symbol is associated with a file.static final byteType specifying that the symbol is associated with a function or other executable code.static final byteUpper bound for range reserved for operating system-specific semantics.static final byteUpper bound for range reserved for processor-specific semantics.static final byteLower bound for range reserved for operating system-specific semantics.static final byteLower bound for range reserved for processor-specific semantics.static final byteType specifying that the symbol is unspecified.static final byteType specifying that the symbol is associated with an object.static final byteType specifying that the symbol is associated with a section.static final byteThe symbol specifies a Thread-Local Storage entity. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the binding for this symbol, extracted from thest_infofield.getName()Returns the name of the symbol or null if the symbol has no name.intgetType()Returns the symbol type, extracted from thest_infofield.net.fornwall.jelf.ElfSymbol.VisibilitytoString()
-
Field Details
-
BINDING_LOCAL
public static final int BINDING_LOCALBinding specifying that local symbols are not visible outside the object file that contains its definition.- See Also:
-
BINDING_GLOBAL
public static final int BINDING_GLOBALBinding specifying that global symbols are visible to all object files being combined.- See Also:
-
BINDING_WEAK
public static final int BINDING_WEAKBinding specifying that the symbol resembles a global symbol, but has a lower precedence.- See Also:
-
BINDING_LOPROC
public static final int BINDING_LOPROCLower bound binding values reserved for processor specific semantics.- See Also:
-
BINDING_HIPROC
public static final int BINDING_HIPROCUpper bound binding values reserved for processor specific semantics.- See Also:
-
STT_NOTYPE
public static final byte STT_NOTYPEType specifying that the symbol is unspecified.- See Also:
-
STT_OBJECT
public static final byte STT_OBJECTType specifying that the symbol is associated with an object.- See Also:
-
STT_FUNC
public static final byte STT_FUNCType specifying that the symbol is associated with a function or other executable code.- See Also:
-
STT_SECTION
public static final byte STT_SECTIONType 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_FILEType defining that the symbol is associated with a file.- See Also:
-
STT_COMMON
public static final byte STT_COMMONThe symbol labels an uninitialized common block.- See Also:
-
STT_TLS
public static final byte STT_TLSThe symbol specifies a Thread-Local Storage entity.- See Also:
-
STT_LOOS
public static final byte STT_LOOSLower bound for range reserved for operating system-specific semantics.- See Also:
-
STT_HIOS
public static final byte STT_HIOSUpper bound for range reserved for operating system-specific semantics.- See Also:
-
STT_LOPROC
public static final byte STT_LOPROCLower bound for range reserved for processor-specific semantics.- See Also:
-
STT_HIPROC
public static final byte STT_HIPROCUpper bound for range reserved for processor-specific semantics.- See Also:
-
st_name
public final int st_nameIndex 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_valueValue of the associated symbol. This may be a relative address for .so or absolute address for other ELFs. -
st_size
public final long st_sizeSize of the symbol. 0 if the symbol has no size or the size is unknown. -
st_info
public final short st_infoSpecifies the symbol type and binding attributes. -
st_other
public final short st_otherCurrently holds the value of 0 and has no meaning. -
st_shndx
public final short st_shndxIndex 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 offsetOffset from the beginning of the file to this symbol.
-
-
Method Details
-
getBinding
public int getBinding()Returns the binding for this symbol, extracted from thest_infofield.- Returns:
- the binding for this symbol
-
getType
public int getType()Returns the symbol type, extracted from thest_infofield.- Returns:
- the type of this symbol
-
getName
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
-