Package ghidra.app.util.bin.format.elf

# Class ElfStringTable

java.lang.Object
ghidra.app.util.bin.format.elf.ElfStringTable

All Implemented Interfaces:
  `ElfFileSection`, `StructConverter`

public class ElfStringTable extends Object implements ElfFileSection

- ## Field Summary

  ### Fields inherited from interface ghidra.app.util.bin.StructConverter

  `ASCII, BYTE, DWORD, IBO32, IBO64, POINTER, QWORD, SLEB128, STRING, ULEB128, UTF16, UTF8, VOID, WORD`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ElfStringTable(ElfHeader header, ElfSectionHeader stringTableSection, long fileOffset, long addrOffset, long length)`
  Construct and parse an Elf string table

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getAddressOffset()`
  Preferred memory address offset where data should be loaded.
  `int`
  `getEntrySize()`
  Size of each structured entry in bytes
  `long`
  `getFileOffset()`
  Offset within file where section bytes are specified
  `long`
  `getLength()`
  Length of file section in bytes
  `ElfSectionHeader`
  `getTableSectionHeader()`
  Get section header which corresponds to this table, or null if only associated with a dynamic table entry
  `String`
  `readString(BinaryReader reader, long stringOffset)`
  Read string from table at specified relative table offset
  `DataType`
  `toDataType()`
  Returns a structure datatype representing the contents of the implementor of this interface.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ElfStringTable

    public ElfStringTable(ElfHeader header, ElfSectionHeader stringTableSection, long fileOffset, long addrOffset, long length)
    Construct and parse an Elf string table
    Parameters:
      `header` - elf header
      `stringTableSection` - string table section header or null if associated with a dynamic table entry
      `fileOffset` - symbol table file offset
      `addrOffset` - memory address of symbol table (should already be adjusted for prelink)
      `length` - length of symbol table in bytes of -1 if unknown

- ## Method Details

  - ### readString

    public String readString(BinaryReader reader, long stringOffset)
    Read string from table at specified relative table offset
    Parameters:
      `reader` - byte reader (position remains unchanged)
      `stringOffset` - table relative string offset
    Returns:
      string or null on error

  - ### 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 interface `ElfFileSection`
    Returns:
      default memory address offset where data should be loaded

  - ### getTableSectionHeader

    public ElfSectionHeader getTableSectionHeader()
    Get section header which corresponds to this table, or null if only associated with a dynamic table entry
    Returns:
      string 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 interface `ElfFileSection`
    Returns:
      offset within file where section bytes are specified

  - ### getLength

    public long getLength()
    Description copied from interface: `ElfFileSection`
    Length of file section in bytes
    Specified by:
      `getLength` in interface `ElfFileSection`
    Returns:
      length of file section in bytes

  - ### getEntrySize

    public int getEntrySize()
    Description copied from interface: `ElfFileSection`
    Size of each structured entry in bytes
    Specified by:
      `getEntrySize` in interface `ElfFileSection`
    Returns:
      entry size or -1 if variable

  - ### toDataType

    public DataType toDataType() throws DuplicateNameException, IOException
    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 interface `StructConverter`
    Returns:
      returns a structure datatype representing the implementor of this interface
    Throws:
      `DuplicateNameException` - when a datatype of the same name already exists
      `IOException`
    See Also:
      - `StructureDataType`