angr.go.knowledge_plugins.go_signatures¶
- angr.go.knowledge_plugins.go_signatures.placeholder_group(words)¶
The spelling of
wordsresult words read together that nobody typed: a struct, so that it still travels in result registers (an array would go through memory under ABIInternal).
- angr.go.knowledge_plugins.go_signatures.is_placeholder_type(type_str)¶
uintptror a word group nobody typed (struct { W0 uintptr; W1 uintptr },[]uintptr).
- class angr.go.knowledge_plugins.go_signatures.GoInferredSignature¶
Bases:
dictWhat the decompiler inferred about a function nobody names: parameter types from the callees its parameters reach, and result types from its own return statements (
results, word -> (type, words spanned)) and from how callers use the result registers (caller_results).groups(word -> (words spanned, type or None)) are caller-side groupings of result words read as one value, typed when the shape of the reads says what they are (an interface pair), else kept together as a placeholder. Word indices count ABIInternal integer result registers;fp_results(index -> type) counts the floating-point ones, which Go assigns independently. A plain dict underneath so records survive JSON and pickling between the processes of a sweep.- property return_words: int¶
unknown).
- Type:
How many result registers the function’s returns write, where that is fewer than the guess (0
- merge(params=None, results=None, caller_results=None, result_words=0, groups=None, return_words=0, fp_results=None)¶
Parameter types replace the earlier ones; result types accumulate (over callers, and over passes as callees get typed), the first to type a word wins unless a later one types a wider value there. A typed group replaces an untyped one of the same span. The smallest
return_wordswins. Returns whether the record changed.
- fp_result_types(floor)¶
The floating-point results, after the integer ones;
flooris how many the guessed prototype has.
- result_types(floor)¶
The result list: callee-side types win, caller-side types fill the gaps, then caller-side groups (an untyped group is spelled by
placeholder_group), words nobody typed stayuintptr.flooris the number of words the guessed prototype already returns, less any its own returns showed it never writes.
- angr.go.knowledge_plugins.go_signatures.available_signature_dbs()¶
Installed stdlib signature databases, keyed by minor version (
go1.22).
- angr.go.knowledge_plugins.go_signatures.load_signature_db(go_version)¶
The stdlib signature database for
go_version, falling back to the closest installed minor version.- Return type:
- Parameters:
go_version (str | None)
- class angr.go.knowledge_plugins.go_signatures.GoSignatures¶
Bases:
KnowledgeBasePluginGo function signatures and named types known for this binary, merged from every source (external tools, DWARF, the binary’s runtime type descriptors, the stdlib database, in that priority) and turned into Go SimTypes on demand.
- __init__(kb)¶
- record_version(key)¶
The counter value when the record
key(a function name,callsite:0x..orclosure:0x..) last changed; 0 when it was never written.
- record_fingerprint(key)¶
A process-independent spelling of the record
keyas it is now (None when absent), for comparing what a decompilation consulted with what another process knows.
- track()¶
Record which inference records are consulted while the block runs, each with the version it had when first consulted (
deps). Nested scopes report to the enclosing one.
- untracked()¶
Suspend dependency tracking: for one-off whole-binary scans that are nobody’s dependency.
- note(name)¶
Count the inferred record of
nameas consulted by the decompilation in progress.
- deps_current(deps, version)¶
Whether a decompilation that started from
versionand consulteddeps(key -> version seen) reflects the current records: none of them changed since. Without a dependency list only the global counter decides.
- is_current(cache)¶
Whether the decompilation in
cache(a DecompilationCache) reflects the current inference records.- Return type:
- stale_decompilations(kb=None)¶
The
(addr, flavor)keys of the Go decompilations inkb.decompilationsthat are out of date.
- add_source(sigs, priority=None)¶
Register a signature set; earlier sources win.
priority=0puts it in front.- Return type:
- Parameters:
sigs (GoSignatureSet)
priority (int | None)
- load_sources(go_version=None)¶
Load the binary’s own DWARF signatures (when present), its runtime type descriptors and the stdlib database for its Go version. Runs once.
- load_stdlib(go_version=None)¶
Load the binary’s own DWARF signatures (when present), its runtime type descriptors and the stdlib database for its Go version. Runs once.
- type_name_at(addr)¶
The name of the type whose runtime descriptor is at
addr, when a source (DWARF) recorded it.
- property parser: GoTypeParser¶
- prototype(name)¶
The function type of
name(receiver first), or None when the signature is unknown.- Return type:
- Parameters:
name (str)
- set_inferred(name, param_types=None, results=None, caller_results=None, result_words=0, groups=None, return_words=0, fp_results=None)¶
Record what was inferred for
name(kept until a real signature appears): parameter types, callee-side result types, caller-side result types and word groups, how many result registers its returns write, or a whole record (asinferred_recordreturns it, possibly after a round trip through JSON) in place of the parameter types.- Return type:
- Parameters:
- set_callsite_inferred(addr, caller_results=None, result_words=0, groups=None, fp_results=None)¶
Record what the caller’s reads say about the results of the indirect call at
addr(an interface method or closure without a known signature); the next decompilation types the call-site prototype from it.
- inferred(name)¶
The inferred parameter types of
name.
- results_guessed(func)¶
True when nothing but the calling-convention guess describes the results of
func: its prototype is guessed, or it was rebuilt (a promoted receiver, inferred parameters) around the guessed result type.
- fp_results_open(func)¶
True when callers may still add floating-point results to
func: no real signature and no user prototype describe it. Its integer results may already be typed (inferred), which says nothing about the float ones.
- untyped_params(func)¶
Indices of the parameters of
functhat only the calling-convention guess describes: a prototype rebuilt around a promoted receiver or inferred results keeps the guessed words (non-Go types, or theuintptran inferred record spells for words it could not type). Type inference may know better about those, so they are no ground truth. Parameters of a real signature always are.
- inferred_prototype(name, guessed)¶
The inferred signature of
nameas a function type: inferred parameter types (else the guessed ones) and inferred result types (else the guessed result typeguessed.returnty).- Return type:
- Parameters:
name (str)
- set_closure_context(addr, type_str)¶
Record the closure record type a parent function builds for the closure body at
addr.
- closure_context(addr)¶
The closure record type of the body at
addr(captures are its fields afterF), if known.
- arg_size_at(addr)¶
The byte size of the parameters of the function at
addrfrom the pclntab (results excluded).
- prototype_at(addr)¶
The function type of the method whose code starts at
addr, from the runtime type descriptors’ method tables (receiver first). Covers methods of named types in stripped binaries, which no signature source names.- Return type:
- Parameters:
addr (int)
- copy()¶