Package ghidra.app.util.bin.format.elf
Class ElfDynamic
- java.lang.Object
-
- ghidra.app.util.bin.format.elf.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.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ElfDynamic
createElfDynamic(FactoryBundledWithBinaryReader reader, ElfHeader elf)
int
getTag()
Returns the value that controls the interpretation of the the d_val and/or d_ptr.java.lang.String
getTagAsString()
A convenience method for getting a string representing the d_tag value.ElfDynamicType
getTagType()
Returns the enum value that controls the interpretation of the the d_val and/or d_ptr (or null if unknown).long
getValue()
Returns the object whose integer values represent various interpretations.void
setValue(int value)
Sets the value of this dynamic.void
setValue(long value)
Sets the value of this dynamic.int
sizeof()
Returns the size in bytes of this object.byte[]
toBytes(DataConverter dc)
Returns a byte array representing this implementor of this interface.java.lang.String
toString()
void
write(byte[] data, int offset, DataConverter dc)
-
-
-
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 dynamicvalue
- the value (or pointer) of this dynamicis32bit
- true if this object is a 32-bit dynamic, false if 64-bit dynamic
-
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 dynamicvalue
- the value (or pointer) of this dynamicis32bit
- true if this object is a 32-bit dynamic, false if 64-bit dynamic
-
-
Method Detail
-
createElfDynamic
public static ElfDynamic createElfDynamic(FactoryBundledWithBinaryReader reader, ElfHeader elf) throws java.io.IOException
- Throws:
java.io.IOException
-
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 classjava.lang.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 interfaceByteArrayConverter
- Parameters:
dc
- the data converter to use- Returns:
- a byte array representing this object
- See Also:
ByteArrayConverter.toBytes(ghidra.util.DataConverter)
-
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.
-
-