Class ElfNote
java.lang.Object
ghidra.app.util.bin.format.elf.info.ElfNote
- All Implemented Interfaces:
ElfInfoItem
- Direct Known Subclasses:
NoteAbiTag,NoteGnuBuildId,NoteGnuProperty,NoteGoBuildId
ELF note sections have a well-defined format that combines identity information along with a
binary blob that is specific to each type of note.
Notes are identified by the combination of a name string and vendorType number, and are usually stored in a ELF section with a specific name.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface ghidra.app.util.bin.format.elf.info.ElfInfoItem
ElfInfoItem.ItemWithAddress<T>, ElfInfoItem.ReaderFunc<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final byte[]protected final Stringprotected final intprotected final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static StructureDataTypecreateNoteStructure(CategoryPath cp, String structName, boolean templatedName, int noteNameLen, int noteDescLen, DataTypeManager dtm) voiddecorateProgramInfo(Options programInfoOptions) Adds a single entry to the Options, built from thegetProgramInfoKey()value andgetNoteValueString()value.byte[]Returns the bytes in the description portion of the note.Returns a hex string of the description bytes.intgetDescriptionReader(boolean isLittleEndian) Returns aBinaryReaderthat reads from this note's description blob.getName()Returns the name value of this note.intReturns a string that describes this note's type, used when creating the defaultgetProgramInfoKey()value.Returns a string representation of this note's 'value', used when creating the PROGRAM_INFO entry.Returns a string that is used to build a PROGRAM_INFO entry's key.intReturns the vendor type 'enum' value of this note.booleanisGnu()Shortcut test of name == "GNU"voidmarkupProgram(Program program, Address address) Markup a program's info and memory with this item.static ElfNoteread(BinaryReader reader) Reads a genericElfNoteinstance from the supplied BinaryReader.protected static <T extends ElfNote>
TreadFromProgramHelper(Program program, String sectionName, ElfNote.NoteReaderFunc<T> readerFunc) A helper method forread()methods defined in specific Note classes to attempt to read a specific Note type from a Program.toString()Returns a Structure datatype that matches the format of this ElfNote, or null if this ElfNote shouldn't be represented/marked up.
-
Field Details
-
nameLen
protected final int nameLen -
name
-
vendorType
protected final int vendorType -
description
protected final byte[] description
-
-
Constructor Details
-
ElfNote
-
ElfNote
-
-
Method Details
-
read
Reads a genericElfNoteinstance from the supplied BinaryReader.- Parameters:
reader- BinaryReader to read from- Returns:
- new
ElfNoteinstance, never null - Throws:
IOException- if bad data or error reading
-
readFromProgramHelper
protected static <T extends ElfNote> T readFromProgramHelper(Program program, String sectionName, ElfNote.NoteReaderFunc<T> readerFunc) A helper method forread()methods defined in specific Note classes to attempt to read a specific Note type from a Program.- Type Parameters:
T- Note type- Parameters:
program-ProgramsectionName- name of the note sectionreaderFunc-ElfNote.NoteReaderFuncthat converts a generic note instance into a specialized note.- Returns:
- new Note instance, or null if not present or error reading
-
isGnu
public boolean isGnu()Shortcut test of name == "GNU"- Returns:
- true if name is "GNU"
-
getName
Returns the name value of this note.- Returns:
- string name
-
getNameLen
public int getNameLen() -
getDescription
public byte[] getDescription()Returns the bytes in the description portion of the note.- Returns:
- byte array
-
getDescriptionLen
public int getDescriptionLen() -
getDescriptionAsHexString
Returns a hex string of the description bytes.- Returns:
- hex string
-
getDescriptionReader
Returns aBinaryReaderthat reads from this note's description blob.- Parameters:
isLittleEndian- flag, seeBinaryReader(ByteProvider, boolean)- Returns:
- new BinaryReader
-
getVendorType
public int getVendorType()Returns the vendor type 'enum' value of this note.- Returns:
- vendor type 'enum' value
-
getNoteTypeName
Returns a string that describes this note's type, used when creating the defaultgetProgramInfoKey()value.Specific Note subclasses can override this to return a better string than this default implementation, or can override the
getProgramInfoKey()method.- Returns:
- descriptive string
-
getNoteValueString
Returns a string representation of this note's 'value', used when creating the PROGRAM_INFO entry.Specific Note subclasses should override this to return a better string than this default implementation.
- Returns:
- string describing this note's value
-
getProgramInfoKey
Returns a string that is used to build a PROGRAM_INFO entry's key.Specific Note subclasses can override this to return a better key string.
- Returns:
- key string (avoid using '.' characters as they will be converted to '_'s)
-
decorateProgramInfo
Adds a single entry to the Options, built from thegetProgramInfoKey()value andgetNoteValueString()value.- Parameters:
programInfoOptions-Optionsto add entry to
-
markupProgram
Description copied from interface:ElfInfoItemMarkup a program's info and memory with this item.- Specified by:
markupProgramin interfaceElfInfoItem- Parameters:
program-Programto markupaddress-Addressof the item in the program
-
toStructure
Returns a Structure datatype that matches the format of this ElfNote, or null if this ElfNote shouldn't be represented/marked up.- Parameters:
dtm-DataTypeManagerthat will receive the structure- Returns:
- StructureDataType that specifies the layout of the ElfNote, or null
-
toString
-
createNoteStructure
protected static StructureDataType createNoteStructure(CategoryPath cp, String structName, boolean templatedName, int noteNameLen, int noteDescLen, DataTypeManager dtm)
-