angr.go.signature

Language-level Go function signatures and named-type descriptions.

Every source of Go type information (the stdlib signature database, DWARF, runtime type descriptors, external tools) is normalized into these records before it is turned into SimTypes. Types are carried as Go type strings in canonical Go syntax with package-path-qualified names, e.g.:

int  uint8  uintptr  bool  string  error  unsafe.Pointer
*net/http.Server  []byte  [4]int  map[string][]int  chan<- int  func(int, string) (int, error)
struct { x int; y int }  interface { Error() string }  any

Rules: - Named types are qualified with the full import path (net/http.Server, main.point, os.File); a type

from package main is main.T. Predeclared types (int, string, error, any) are bare.

  • Struct field lists use ; separators; anonymous (embedded) fields are written as their type.

  • Function types never carry parameter names; only signatures do.

  • Generic instantiations use the compiler’s spelling, e.g. slices.Index[[]int,int].

JSON form (used by the on-disk signature databases):

{
  "go_version": "go1.22.5",
  "goarch": "amd64",
  "functions": {
    "strconv.Atoi": {"params": [["s", "string"]], "results": [["~r0", "int"], ["~r1", "error"]]},
    "os.(*File).Write": {"recv": ["f", "*os.File"], "params": [["b", "[]byte"]],
                         "results": [["n", "int"], ["err", "error"]]}
  },
  "types": {
    "os.File": {"kind": "struct", "size": 8, "align": 8, "fields": [["file", "*os.file", 0]]},
    "error": {"kind": "interface", "methods": [["Error", "func() string"]]},
    "time.Duration": {"kind": "named", "underlying": "int64", "size": 8, "align": 8}
  }
}

kind is one of struct, interface and named (any other named type; underlying is its Go type string). Sizes and offsets are in bytes for goarch.

class angr.go.signature.GoParam

Bases: object

A named parameter or result and its canonical Go type string.

name: str
type_str: str
__init__(name, type_str)
Parameters:
Return type:

None

class angr.go.signature.GoFuncSignature

Bases: object

A Go function or method signature. name is the linker symbol name (pkg.Func, pkg.(*T).Method, pkg.T.Method, pkg.Func.func1).

name: str
params: list[GoParam]
results: list[GoParam]
recv: GoParam | None
property all_params: list[GoParam]

receiver first.

Type:

Parameters in ABI order

to_json()
Return type:

dict

classmethod from_json(name, d)
Return type:

GoFuncSignature

Parameters:
__init__(name, params=<factory>, results=<factory>, recv=None)
Parameters:
Return type:

None

class angr.go.signature.GoStructField

Bases: object

A struct field: name, canonical Go type string and byte offset.

name: str
type_str: str
offset: int | None
__init__(name, type_str, offset)
Parameters:
  • name (str)

  • type_str (str)

  • offset (int | None)

Return type:

None

class angr.go.signature.GoNamedType

Bases: object

A named Go type. kind is struct (fields set), interface (methods set) or named (underlying set).

name: str
kind: str
size: int | None
align: int | None
fields: list[GoStructField]
methods: list[tuple[str, str]]
underlying: str | None
to_json()
Return type:

dict

classmethod from_json(name, d)
Return type:

GoNamedType

Parameters:
__init__(name, kind, size=None, align=None, fields=<factory>, methods=<factory>, underlying=None)
Parameters:
Return type:

None

class angr.go.signature.GoVariable

Bases: object

A package-level variable: its linker symbol name, (rebased) address and Go type.

name: str
addr: int
type_str: str
__init__(name, addr, type_str)
Parameters:
Return type:

None

class angr.go.signature.GoSignatureSet

Bases: object

A collection of signatures, named types and package-level variables from one source.

go_version: str | None
goarch: str | None
functions: dict[str, GoFuncSignature]
types: dict[str, GoNamedType]
variables: dict[str, GoVariable]
runtime_types: dict[int, str]

runtime type descriptor address -> type name (binary-specific, not serialized)

to_json()
Return type:

dict

classmethod from_json(d)
Return type:

GoSignatureSet

Parameters:

d (dict)

without_layout(goarch)

The same set with sizes, alignments and field offsets dropped: they were computed for another GOARCH.

Return type:

GoSignatureSet

Parameters:

goarch (str | None)

__init__(go_version=None, goarch=None, functions=<factory>, types=<factory>, variables=<factory>, runtime_types=<factory>)
Parameters:
Return type:

None