Class ElfDynamic

java.lang.Object
ghidra.app.util.bin.format.elf.ElfDynamic
All Implemented Interfaces:
ByteArrayConverter

public class ElfDynamic extends Object implements ByteArrayConverter
A class to represent the Elf32_Dyn data structure.

 typedef  int32_t  Elf32_Sword;
 typedef uint32_t  Elf32_Word;
 typedef uint32_t  Elf32_Addr;
 
  typedef struct {
      Elf32_Sword     d_tag;
      union {
          Elf32_Word  d_val;
          Elf32_Addr  d_ptr;
      } d_un;
  } Elf32_Dyn;
 
 typedef   int64_t  Elf64_Sxword;
 typedef  uint64_t  Elf64_Xword;
 typedef  uint64_t  Elf64_Addr;
 
 typedef struct {
     Elf64_Sxword          d_tag;     //Dynamic entry type
     union {
         Elf64_Xword d_val;     //Integer value
         Elf64_Addr  d_ptr;     //Address value
     } d_un;
 } Elf64_Dyn;
 
 
  • Constructor Details

    • ElfDynamic

      public ElfDynamic(BinaryReader reader, ElfHeader elf) throws IOException
      Throws:
      IOException
    • ElfDynamic

      public ElfDynamic(int tag, long value, ElfHeader elf)
      Constructs a new ELF dynamic with the specified tag and value.
      Parameters:
      tag - the tag (or type) of this dynamic
      value - the value (or pointer) of this dynamic
      elf - the elf header
    • ElfDynamic

      public ElfDynamic(ElfDynamicType tag, long value, ElfHeader elf)
      Constructs a new ELF dynamic with the specified (enum) tag and value.
      Parameters:
      tag - the (enum) tag (or type) of this dynamic
      value - the value (or pointer) of this dynamic
      elf - the elf header
  • Method Details

    • getTag

      public int getTag()
      Returns the value that controls the interpretation of the the d_val and/or d_ptr.
      Returns:
      the tag (or type) of this dynamic
    • getTagType

      public ElfDynamicType getTagType()
      Returns the enum value that controls the interpretation of the the d_val and/or d_ptr (or null if unknown).
      Returns:
      the enum tag (or type) of this dynamic or null if unknown
    • getValue

      public long getValue()
      Returns the object whose integer values represent various interpretations. For example, if d_tag == DT_SYMTAB, then d_val holds the address of the symbol table. But, if d_tag == DT_SYMENT, then d_val holds the size of each symbol entry.
      Returns:
      the Elf32_Word object represent integer values with various interpretations
    • setValue

      public void setValue(long value)
      Sets the value of this dynamic. The value could be an address or a number.
      Parameters:
      value - the new value dynamic
    • setValue

      public void setValue(int value)
      Sets the value of this dynamic. The value could be an address or a number.
      Parameters:
      value - the new value dynamic
    • getTagAsString

      public String getTagAsString()
      A convenience method for getting a string representing the d_tag value. For example, if d_tag == DT_SYMTAB, then this method returns "DT_SYMTAB".
      Returns:
      a string representing the d_tag value
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toBytes

      public byte[] toBytes(DataConverter dc)
      Description copied from interface: ByteArrayConverter
      Returns a byte array representing this implementor of this interface.
      Specified by:
      toBytes in interface ByteArrayConverter
      Parameters:
      dc - the data converter to use
      Returns:
      a byte array representing this object
      See Also:
    • write

      public void write(byte[] data, int offset, DataConverter dc) throws ArrayIndexOutOfBoundsException
      Throws:
      ArrayIndexOutOfBoundsException
    • sizeof

      public int sizeof()
      Returns:
      the size in bytes of this object.