Package ghidra.app.util.bin.format.elf
Class ElfSymbolTable
java.lang.Object
ghidra.app.util.bin.format.elf.ElfSymbolTable
- All Implemented Interfaces:
ElfFileSection
,StructConverter
A container class to hold ELF symbols.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionElfSymbolTable
(BinaryReader reader, ElfHeader header, ElfSectionHeader symbolTableSection, long fileOffset, long addrOffset, long length, long entrySize, ElfStringTable stringTable, int[] symbolSectionIndexTable, boolean isDynamic) Construct and parse an Elf symbol table -
Method Summary
Modifier and TypeMethodDescriptionlong
Preferred memory address offset where data should be loaded.int
Size of each structured entry in bytesint
Get the extended symbol section index value for the specified ELF symbol which originated from this symbol table.long
Offset within file where section bytes are specifiedfinal String
getFormattedSymbolName
(int symbolIndex) Get the formatted ELF symbol name which corresponds to the specified index.Returns all of the global symbols.long
Length of file section in bytesString[]
Returns all of the sources file names.Returns the associated string table section.final ElfSymbol
getSymbol
(int symbolIndex) Get the Elf symbol which corresponds to the specified index.getSymbolAt
(long addr) Returns the symbol at the specified address.int
int
getSymbolIndex
(ElfSymbol symbol) Returns the index of the specified symbol in this symbol table.final String
getSymbolName
(int symbolIndex) Get the ELF symbol name which corresponds to the specified index.Returns all of the symbols defined in this symbol table.Get the section header which corresponds to this table, or null if only associated with a dynamic table entryboolean
Returns true if this is the dynamic symbol tableReturns a structure datatype representing the contents of the implementor of this interface.
-
Constructor Details
-
ElfSymbolTable
public ElfSymbolTable(BinaryReader reader, ElfHeader header, ElfSectionHeader symbolTableSection, long fileOffset, long addrOffset, long length, long entrySize, ElfStringTable stringTable, int[] symbolSectionIndexTable, boolean isDynamic) throws IOException Construct and parse an Elf symbol table- Parameters:
reader
- byte reader (reader is not retained and position is unaffected)header
- elf headersymbolTableSection
- string table section header or null if associated with a dynamic table entryfileOffset
- symbol table file offsetaddrOffset
- memory address of symbol table (should already be adjusted for prelink)length
- length of symbol table in bytes of -1 if unknownentrySize
- size of each symbol entry in bytesstringTable
- associated string tablesymbolSectionIndexTable
- extended symbol section index table (may be null, used when symbolst_shndx == SHN_XINDEX
). SeeElfSymbol.getExtendedSectionHeaderIndex()
).isDynamic
- true if symbol table is the dynamic symbol table- Throws:
IOException
- if an IO or parse error occurs
-
-
Method Details
-
isDynamic
public boolean isDynamic()Returns true if this is the dynamic symbol table- Returns:
- true if this is the dynamic symbol table
-
getStringTable
Returns the associated string table section.- Returns:
- the associated string table section
-
getSymbolCount
public int getSymbolCount()- Returns:
- number of symbols
-
getSymbols
Returns all of the symbols defined in this symbol table.- Returns:
- all of the symbols defined in this symbol table
-
getExtendedSectionIndex
Get the extended symbol section index value for the specified ELF symbol which originated from this symbol table. This section index is provided by an associated SHT_SYMTAB_SHNDX section when the symbols st_shndx == SHN_XINDEX.- Parameters:
sym
- ELF symbol from this symbol table- Returns:
- associated extended section index value or 0 if not defined.
-
getSymbolIndex
Returns the index of the specified symbol in this symbol table.- Parameters:
symbol
- the symbol- Returns:
- the index of the specified symbol
-
getSymbolAt
Returns the symbol at the specified address.- Parameters:
addr
- the symbol address- Returns:
- the symbol at the specified address
-
getSymbol
Get the Elf symbol which corresponds to the specified index. Each relocation table may correspond to a specific symbol table to which the specified symbolIndex will be applied.- Parameters:
symbolIndex
- symbol index- Returns:
- Elf symbol which corresponds to symbol index or null if out of range
-
getSymbolName
Get the ELF symbol name which corresponds to the specified index.- Parameters:
symbolIndex
- symbol index- Returns:
- symbol name which corresponds to symbol index or null if out of range
-
getFormattedSymbolName
Get the formatted ELF symbol name which corresponds to the specified index. If the name is blank or can not be resolved due to a missing string table the literal string <no name> will be returned.- Parameters:
symbolIndex
- symbol index- Returns:
- formatted symbol name which corresponds to symbol index or the literal string <no name>
-
getGlobalSymbols
Returns all of the global symbols.- Returns:
- all of the global symbols
-
getSourceFiles
Returns all of the sources file names.- Returns:
- all of the sources file names
-
getLength
public long getLength()Description copied from interface:ElfFileSection
Length of file section in bytes- Specified by:
getLength
in interfaceElfFileSection
- Returns:
- length of file section in bytes
-
getAddressOffset
public long getAddressOffset()Description copied from interface:ElfFileSection
Preferred memory address offset where data should be loaded. The returned offset will already have the prelink adjustment applied, although will not reflect any change in the image base.- Specified by:
getAddressOffset
in interfaceElfFileSection
- Returns:
- default memory address offset where data should be loaded
-
getTableSectionHeader
Get the section header which corresponds to this table, or null if only associated with a dynamic table entry- Returns:
- symbol table section header or null
-
getFileOffset
public long getFileOffset()Description copied from interface:ElfFileSection
Offset within file where section bytes are specified- Specified by:
getFileOffset
in interfaceElfFileSection
- Returns:
- offset within file where section bytes are specified
-
getEntrySize
public int getEntrySize()Description copied from interface:ElfFileSection
Size of each structured entry in bytes- Specified by:
getEntrySize
in interfaceElfFileSection
- Returns:
- entry size or -1 if variable
-
toDataType
Description copied from interface:StructConverter
Returns a structure datatype representing the contents of the implementor of this interface.For example, given:
class A { int foo; double bar; }
The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.
- Specified by:
toDataType
in interfaceStructConverter
- Returns:
- returns a structure datatype representing the implementor of this interface
- Throws:
DuplicateNameException
- when a datatype of the same name already exists- See Also:
-