java.lang.Object
ghidra.app.util.bin.format.golang.rtti.GoName
All Implemented Interfaces:
StructureMarkup<GoName>, StructureReader<GoName>

public class GoName extends Object implements StructureReader<GoName>, StructureMarkup<GoName>
Represents a golang "name" construct, which isn't represented in go as a normal structure since it is full of variable length and optional fields.
 struct {
        byte flag;
        varint strlen;
        char[strlen] chars; 
        (optional: varint tag_strlen; char [tag_strlen];)
        (optional: int32 pkgpath)
 }
 
Because this type has variable length fields (@FieldOutput(isVariableLength=true)), there will be unique structure data types produced for each size combination of a GoName structure, and will be named "GoName_N_M", where N and M are the lengths of the variable fields [name, tag]
  • Constructor Details

    • GoName

      public GoName()
  • Method Details

    • readStructure

      public void readStructure() throws IOException
      Description copied from interface: StructureReader
      Called after an instance has been created and its context has been initialized.
      Specified by:
      readStructure in interface StructureReader<GoName>
      Throws:
      IOException
    • getName

      public String getName()
      Returns the name value.
      Returns:
      name string
    • getTag

      public String getTag()
      Returns the tag string.
      Returns:
      tag string
    • getPkgPath

      public GoName getPkgPath() throws IOException
      Returns the package path string, or null if not present.
      Returns:
      package path string, or null if not present
      Throws:
      IOException - if error reading data
    • getPkgPathDataType

      public DataType getPkgPathDataType()
      Returns the data type needed to store the pkg path offset field, called by serialization from the fieldoutput annotation.
      Returns:
      Ghidra data type needed to store the pkg path offset field, or null if not present
    • getFullNameString

      public String getFullNameString()
      Returns a descriptive string containing the full name value.
      Returns:
      descriptive string
    • getFlags

      public int getFlags()
      Returns the flags found in this structure.
      Returns:
      flags, as an int
    • getFlagsSet

      public Set<GoName.Flag> getFlagsSet()
      Returns the flags found in this structure.
      Returns:
      flags, as a set of GoName.Flag enum values
    • getStructureContext

      public StructureContext<GoName> getStructureContext()
      Specified by:
      getStructureContext in interface StructureMarkup<GoName>
    • getStructureName

      public String getStructureName() throws IOException
      Description copied from interface: StructureMarkup
      Returns the name of the instance, typically retrieved from data found inside the instance.
      Specified by:
      getStructureName in interface StructureMarkup<GoName>
      Returns:
      string name, or null if this instance does not have a name
      Throws:
      IOException - if error getting name
    • toString

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

      public static GoName createFakeInstance(String fakeName)
      Create a GoName instance that supplies a specified name.
      Parameters:
      fakeName - string name to return from the GoName's getName()
      Returns:
      new GoName instance that can only be used to call getName()