Class ElfDynamic

  • All Implemented Interfaces:
    ByteArrayConverter

    public class ElfDynamic
    extends java.lang.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 Summary

      Constructors 
      Constructor Description
      ElfDynamic()
      DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
      ElfDynamic​(int tag, long value, ElfHeader elf)
      Constructs a new ELF dynamic with the specified tag and value.
      ElfDynamic​(ElfDynamicType tag, long value, ElfHeader elf)
      Constructs a new ELF dynamic with the specified (enum) tag and value.
    • Constructor Detail

      • ElfDynamic

        public ElfDynamic()
        DO NOT USE THIS CONSTRUCTOR, USE create*(GenericFactory ...) FACTORY METHODS INSTEAD.
      • 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 Detail

      • 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 java.lang.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • write

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

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