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

# Class ElfDynamicTable

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

All Implemented Interfaces:
  `ElfFileSection`, `StructConverter`

public class ElfDynamicTable extends Object implements ElfFileSection
If an object file participates in dynamic linking, its program header table will have an element of type PT_DYNAMIC. This "segment" contains the ".dynamic" section. A special symbol, _DYNAMIC, labels the section, which contains an array of the Elf32_Dyn or Elf64_Dyn structures.

All address entries contained within this table should adjusted for pre-linking using `ElfHeader.adjustAddressForPrelink(long)`. If a pre-link adjustment is not applicable, this adjustment will have no affect.

- ## 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
  `ElfDynamicTable(BinaryReader reader, ElfHeader header, long fileOffset, long addrOffset)`
  Construct an ELF Dynamic data table

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addDynamic(ElfDynamic dyn, int index)`
  Adds the new dynamic at the specified index.
  `boolean`
  `containsDynamicValue(long type)`
  Returns true if the specified dynamic type has a value.
  `boolean`
  `containsDynamicValue(ElfDynamicType type)`
  Returns true if the specified dynamic (enum) type has a value.
  `long`
  `getAddressOffset()`
  Preferred memory address offset where data should be loaded.
  `ElfDynamic[]`
  `getDynamics()`
  Returns an array of the dynamics defined this dynamic header.
  `ElfDynamic[]`
  `getDynamics(long type)`
  Returns an array of the dynamics defined this dynamic header with the specified type.
  `ElfDynamic[]`
  `getDynamics(ElfDynamicType type)`
  Returns an array of the dynamics defined this dynamic header with the specified (enum) type.
  `long`
  `getDynamicValue(long type)`
  Returns the value of the specified dynamic type.
  `long`
  `getDynamicValue(ElfDynamicType type)`
  Returns the value of the specified dynamic (enum) type.
  `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
  `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

  - ### ElfDynamicTable

    public ElfDynamicTable(BinaryReader reader, ElfHeader header, long fileOffset, long addrOffset) throws IOException
    Construct an ELF Dynamic data table
    Parameters:
      `reader` - byte provider reader (reader is not retained and position is unaffected)
      `header` - elf header
      `fileOffset` - file offset which will be used to temporarily position reader
      `addrOffset` - memory address offset
    Throws:
      `IOException` - if IO error occurs during parse

- ## Method Details

  - ### addDynamic

    public void addDynamic(ElfDynamic dyn, int index)
    Adds the new dynamic at the specified index.
    Parameters:
      `dyn` - the new dynamic
      `index` - the new index

  - ### getDynamics

    public ElfDynamic[] getDynamics()
    Returns an array of the dynamics defined this dynamic header.
    Returns:
      an array of the dynamics defined this dynamic header

  - ### getDynamics

    public ElfDynamic[] getDynamics(long type)
    Returns an array of the dynamics defined this dynamic header with the specified type.
    Parameters:
      `type` - the desired dynamic type, e.g., DT_NEEDED
    Returns:
      an array of the dynamics defined this dynamic header

  - ### getDynamics

    public ElfDynamic[] getDynamics(ElfDynamicType type)
    Returns an array of the dynamics defined this dynamic header with the specified (enum) type.
    Parameters:
      `type` - the desired dynamic type, e.g., DT_NEEDED
    Returns:
      an array of the dynamics defined this dynamic header

  - ### getDynamicValue

    public long getDynamicValue(long type) throws NotFoundException
    Returns the value of the specified dynamic type.
    Parameters:
      `type` - the dynamic type
    Returns:
      the dynamic value
    Throws:
      `NotFoundException` - if requested value type not found

  - ### containsDynamicValue

    public boolean containsDynamicValue(ElfDynamicType type)
    Returns true if the specified dynamic (enum) type has a value.
    Parameters:
      `type` - the dynamic (enum) type
    Returns:
      true if dynamic value exists

  - ### containsDynamicValue

    public boolean containsDynamicValue(long type)
    Returns true if the specified dynamic type has a value.
    Parameters:
      `type` - the dynamic type
    Returns:
      true if dynamic value exists

  - ### getDynamicValue

    public long getDynamicValue(ElfDynamicType type) throws NotFoundException
    Returns the value of the specified dynamic (enum) type.
    Parameters:
      `type` - the dynamic (enum) type
    Returns:
      the dynamic value
    Throws:
      `NotFoundException` - if requested value type not found

  - ### 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

  - ### 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

  - ### 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`

  - ### 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