Class GoFuncData

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

public class GoFuncData extends Object implements StructureMarkup<GoFuncData>
A structure that golang generates that contains metadata about a function.
  • Constructor Details

    • GoFuncData

      public GoFuncData()
  • Method Details

    • setEntryoff

      public void setEntryoff(long entryoff)
      Sets the function's entry point via a relative offset value

      Called via deserialization for entryoff fieldmapping annotation

      Parameters:
      entryoff - relative offset to function
    • setEntry

      public void setEntry(long entry)
      Sets the absolute entry address.

      Called via deserialization for entry fieldmapping annotation

      Parameters:
      entry - absolute value.
    • getFuncAddress

      public Address getFuncAddress()
      Returns the address of this function.
      Returns:
      the address of this function
    • getBody

      public AddressRange getBody()
      Returns the address range of this function's body, recovered by examining addresses in the function's pc-to-filename translation table, or if not present, a single address range that contains the function's entry point.
      Returns:
      AddressRange representing the function's known footprint
    • getFunction

      public Function getFunction()
      Returns the Ghidra function that corresponds to this go function.
      Returns:
      Ghidra Function, or null if there is no Ghidra function at the address
    • getPcDataValue

      public int getPcDataValue(GoPcDataTable tableIndex, long targetPC) throws IOException
      Returns a value from the specified pc->value lookup table, for a specific address (that should be within the function's footprint).
      Parameters:
      tableIndex - GoPcDataTable enum
      targetPC - address (inside the function) to determine the value of
      Returns:
      int value, will be specific to the table it comes from, or -1 if the requested table index is not present for this function
      Throws:
      IOException - if error reading lookup data
    • getPcDataValues

      public List<Integer> getPcDataValues(GoPcDataTable tableIndex) throws IOException
      Returns all values for the specified pc->value lookup table for the entire range of the function's footprint.
      Parameters:
      tableIndex - GoPcDataTable enum
      Returns:
      list of int values, will be specific to the table it comes from, or an empty list if the requested table index is not present for this function
      Throws:
      IOException - if error reading lookup data
    • getFuncDataValue

      public long getFuncDataValue(GoFuncDataTable tableIndex) throws IOException
      Returns a value associated with this function.
      Parameters:
      tableIndex - GoFuncDataTable enum
      Returns:
      requested value, or -1 if the requested table index is not present for this function
      Throws:
      IOException - if error reading lookup data
    • recoverFunctionSignature

      public String recoverFunctionSignature() throws IOException
      Attempts to build a 'function signature' string representing the known information about this function's arguments, using go's built-in stack trace metadata.

      The information that can be recovered about arguments is limited to:

      • the size of the argument
      • general grouping (eg. grouping of arg values as a structure or array)
      Return value information is unknown and always represented as an "undefined" data type.
      Returns:
      pseduo-function signature string, such as "undefined foo( 8, 8 )" which would indicate the function had 2 8-byte arguments
      Throws:
      IOException - if error reading lookup data
    • findMethodSignature

      public FunctionDefinition findMethodSignature() throws IOException
      Attempts to return a FunctionDefinition for this function, based on this function's inclusion in a golang interface as a method.
      Returns:
      FunctionDefinition
      Throws:
      IOException - if error
    • findMethodInfo

      public GoMethod.GoMethodInfo findMethodInfo()
      Attempts to return a GoMethod.GoMethodInfo for this function, based on this function's inclusion in a golang interface as a method.
      Returns:
      GoMethod.GoMethodInfo
    • getNameAddress

      public Address getNameAddress()
      Returns the address of this function's name string.

      Referenced from nameoff's markup annotation

      Returns:
      Address
    • getName

      public String getName()
      Returns the name of this function.
      Returns:
      String name of this function
    • getSymbolName

      public GoSymbolName getSymbolName()
      Returns the name of this function, as a parsed symbol object.
      Returns:
      GoSymbolName containing this function's name
    • getDescription

      public String getDescription()
      Returns a descriptive string.

      Referenced from the entry, entryoff field's markup annotation

      Returns:
      String description
    • isInline

      public boolean isInline()
      Returns true if this function is inline
      Returns:
      true if this function is inline
    • getFlags

      public Set<GoFuncFlag> getFlags()
      Returns the func flags for this function.
      Returns:
      GoFuncFlags
    • isAsmFunction

      public boolean isAsmFunction()
      Returns true if this function is an ASM function
      Returns:
      true if this function is an ASM function
    • getFuncIDEnum

      public GoFuncID getFuncIDEnum()
      Returns the GoFuncID enum that categorizes this function
      Returns:
      the GoFuncID enum that categorizes this function
    • getSourceFileInfo

      public GoSourceFileInfo getSourceFileInfo() throws IOException
      Returns information about the source file that this function was defined in.
      Returns:
      GoSourceFileInfo, or null if no source file info present
      Throws:
      IOException - if error reading lookup data
    • getModuledata

      public GoModuledata getModuledata()
      Returns a reference to the GoModuledata that contains this function.
      Returns:
      GoModuledata that contains this function
    • getStructureContext

      public StructureContext<GoFuncData> getStructureContext()
      Specified by:
      getStructureContext in interface StructureMarkup<GoFuncData>
    • 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<GoFuncData>
      Returns:
      string name, or null if this instance does not have a name
      Throws:
      IOException - if error getting name
    • additionalMarkup

      public void additionalMarkup(MarkupSession session) throws IOException, CancelledException
      Description copied from interface: StructureMarkup
      Called to allow the implementor to perform custom markup of itself.
      Specified by:
      additionalMarkup in interface StructureMarkup<GoFuncData>
      Parameters:
      session - state and methods to assist marking up the program
      Throws:
      IOException - if error during markup
      CancelledException - if cancelled
    • toString

      public String toString()
      Overrides:
      toString in class Object