Package ghidra.app.util.bin.format.golang

# Class GoFunctionFixup

java.lang.Object
ghidra.app.util.bin.format.golang.GoFunctionFixup

public class GoFunctionFixup extends Object
Utility class to fix Golang function parameter storage

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GoFunctionFixup()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `fixupFunction(Function func)`
  Assigns custom storage for a function's parameters, using the function's current parameter list (formal info only) as starting information.
  `static void`
  `fixupFunction(Function func, GoVer goVersion)`
  Assigns custom storage for a function's parameters, using the function's current parameter list (formal info only) as starting information.
  `static boolean`
  `isGolangAbi0Func(Function func)`
  `static boolean`
  `isInLocalVarStorageArea(Function func, long stackOffset)`
  `static DataType`
  `makeEmptyArrayDataType(DataType dt)`
  Returns a Ghidra data type that represents a zero-length array, to be used as a replacement for a zero-length array parameter.
  `static void`
  `reverseNonStackStorageLocations(List<Varnode> varnodes)`
  Invert the order of the any register storage locations to match the decompiler's logic for assigning storage to structs that varies on endianness.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### GoFunctionFixup

    public GoFunctionFixup()

- ## Method Details

  - ### fixupFunction

    public static void fixupFunction(Function func) throws DuplicateNameException, InvalidInputException
    Assigns custom storage for a function's parameters, using the function's current parameter list (formal info only) as starting information.
    Parameters:
      `func` - Ghidra `Function` to fix
    Throws:
      `DuplicateNameException` - if invalid parameter names
      `InvalidInputException` - if invalid data types or storage

  - ### fixupFunction

    public static void fixupFunction(Function func, GoVer goVersion) throws DuplicateNameException, InvalidInputException
    Assigns custom storage for a function's parameters, using the function's current parameter list (formal info only) as starting information.
    Parameters:
      `func` - Ghidra `Function` to fix
      `goVersion` - `GoVer` enum
    Throws:
      `DuplicateNameException` - if invalid parameter names
      `InvalidInputException` - if invalid data types or storage

  - ### makeEmptyArrayDataType

    public static DataType makeEmptyArrayDataType(DataType dt)
    Returns a Ghidra data type that represents a zero-length array, to be used as a replacement for a zero-length array parameter.
    Parameters:
      `dt` - data type that will donate its name to the created empty array type
    Returns:
      `DataType` that represents a specific zero-length array type

  - ### isGolangAbi0Func

    public static boolean isGolangAbi0Func(Function func)

  - ### isInLocalVarStorageArea

    public static boolean isInLocalVarStorageArea(Function func, long stackOffset)

  - ### reverseNonStackStorageLocations

    public static void reverseNonStackStorageLocations(List<Varnode> varnodes)
    Invert the order of the any register storage locations to match the decompiler's logic for assigning storage to structs that varies on endianness.

    Only valid for storage scheme that has all register storages listed first / contiguous.

    Parameters:
      `varnodes` - list of `varnodes` that will be modified in-place