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 classes/interfaces inherited from interface ghidra.app.util.bin.format.elf.info.ElfInfoItem
ElfInfoItem.ItemWithAddress<T>, ElfInfoItem.ReaderFunc<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected final byte[]
protected final String
protected final int
protected final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static StructureDataType
createNoteStructure
(CategoryPath cp, String structName, boolean templatedName, int noteNameLen, int noteDescLen, DataTypeManager dtm) void
decorateProgramInfo
(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.int
getDescriptionReader
(boolean isLittleEndian) Returns aBinaryReader
that reads from this note's description blob.getName()
Returns the name value of this note.int
Returns 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.int
Returns the vendor type 'enum' value of this note.boolean
isGnu()
Shortcut test of name == "GNU"void
markupProgram
(Program program, Address address) Markup a program's info and memory with this item.static ElfNote
read
(BinaryReader reader) Reads a genericElfNote
instance 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 genericElfNote
instance from the supplied BinaryReader.- Parameters:
reader
- BinaryReader to read from- Returns:
- new
ElfNote
instance, 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
-Program
sectionName
- name of the note sectionreaderFunc
-ElfNote.NoteReaderFunc
that 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 aBinaryReader
that 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
-Options
to add entry to
-
markupProgram
Description copied from interface:ElfInfoItem
Markup a program's info and memory with this item.- Specified by:
markupProgram
in interfaceElfInfoItem
- Parameters:
program
-Program
to markupaddress
-Address
of 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
-DataTypeManager
that 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)
-