Class GoFunctionMultiReturn

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

public class GoFunctionMultiReturn extends Object
Handles creating a Ghidra structure to represent multiple return values returned from a golang function.

Assigning custom storage for the return value is complicated by:

  • golang storage allocations depend on the formal ordering of the return values
  • stack storage must be last in a list of varnodes
  • the decompiler maps a structure's contents to the list of varnodes in an endian-dependent manner.
To meet these complications, the structure's layout is modified to put all items that were marked as being stack parameters to either the front or back of the structure.

To allow this artificial structure to adjusted by the user and reused at some later time to re-calculate the correct storage, the items in the structure are tagged with the original ordinal of that item as a text comment of each structure field, so that the correct ordering of items can be re-created when needed.

If the structure layout is modified to conform to an arch's requirements, the structure's name will be modified to include that arch's description at the end (eg. "_x86_64")