Library:Go runtime
| Developer | The Go Authors (Google) |
|---|---|
| Platforms | Windows, Linux, macOS, FreeBSD and others; amd64, 386, arm64, arm, riscv64, ppc64, s390x, mips, loong64, wasm |
| Versions | Go 1.0 (2012) to Go 1.27 (2026) |
| Magic | \xff Go buildinf: (build info), \xff Go build ID: (PE/Mach-O .text start) |
| License | BSD-3-Clause |
| Website | https://go.dev |
| On this wiki | Facts · Code · Notes · Topics |
The runtime and standard library that the Go gc toolchain links statically into every Go executable (garbage collector, goroutine scheduler, maps, interfaces, reflection). Even a stripped Go binary keeps its function names and source lines in the Format:Go pclntab, its toolchain version and module list in a build-info blob, and type names for reflection, so most of a Go binary can be named without debug info.
Identification
A binary built by the gc toolchain (go build) can be recognised without running it:
| Indicator | Where | Notes |
|---|---|---|
FF 20 47 6F 20 62 75 69 6C 64 69 6E 66 3A (\xff Go buildinf:) at a 16-byte aligned address |
ELF section .go.buildinfo; PE: start of .data |
inline-string format since Go 1.18, pointer format before (seen in a Go 1.17 binary) |
\xff Go build ID: "..."\n \xff |
first bytes of .text on PE and Mach-O (symbol go:buildid); ELF has a note section .note.go.buildid (owner "Go", type 4) instead |
the build ID is four base64-like hashes joined by /
|
PC-line table magic F1 FF FF FF 00 00 01 08 (amd64: quantum 1, pointer size 8; 386 ends in 04) |
ELF .gopclntab; PE inside .rdata |
Go 1.20+; older magics on Format:Go pclntab |
Entry point is _rt0_<arch>_<os> (_rt0_amd64_windows, _rt0_amd64_linux) |
image entry | |
About 2/3 of functions start with the stack-growth check 49 3B 66 10 (cmp rsp, [r14+10h]) |
amd64 code | Go 1.17+ (register ABI) |
Section names .typelink, .itablink, .gosymtab, .gopclntab, .go.buildinfo, .noptrdata, .noptrbss |
ELF | seen in Go 1.24 linux/amd64 |
Strings runtime.morestack_noctxt, runtime.gopanic, go:buildid, /usr/local/go/src/runtime/proc.go (or the builder's GOROOT) |
pclntab name and file tables | |
Custom section go:buildid as the very first section; producers language: Go / processed-by: Go cmd/compile; imports from module gojs (runtime.wasmExit, syscall/js.*) and exports run, resume, getsp, mem (GOOS=js), or _start / _initialize and memory (GOOS=wasip1) |
.wasm modules (Format:WebAssembly binary format) |
Go linker src/cmd/link/internal/wasm/asm.go at dfc6f7db (lines 238-259, 317-333, 412-467, 584-602)
|
Unstripped Windows builds (no -ldflags=-s) also carry a COFF symbol table (a .symtab section in the PE, pointed to by the COFF header) with every function and global name, including runtime.firstmoduledata, runtime.text, runtime.types and go:buildinfo. Stripped builds still have the pclntab.
Build information
The linker writes a blob go:buildinfo (16-byte aligned): a 32-byte header (14-byte magic, pointer-size byte, flags byte, then two pointers that are only used before Go 1.18) followed, since Go 1.18 (flags bit 1 set), by two uvarint-length-prefixed strings: the toolchain version (go1.24.0) and the module info. Before 1.18 the two pointers lead to Go string headers (pointer, length) instead, and flags bit 0 gives their byte order. The module info is framed by two 16-byte sentinels (30 77 AF 0C 92 74 08 02 41 E1 C1 07 E6 D6 18 E6 before, F9 32 43 31 86 18 20 72 00 82 42 10 41 16 D8 F2 after) and holds tab-separated lines path, mod, dep (module path, version, h1: hash) and build (settings such as -ldflags, GOARCH, vcs.revision). go version -m BINARY prints it, and so does Code:Go runtime/gobin (Python). The blob has its own page: Format:Go buildinfo (reference reader, locating it per container, flags).
Test vector (Mailpit v1.22.3, linux/amd64, file offset 0x1293000): FF 20 47 6F 20 62 75 69 6C 64 69 6E 66 3A 08 02, 16 zero bytes, 08 67 6F 31 2E 32 34 2E 30 (length 8, go1.24.0), E4 25 (uvarint 4836, the module info length), then the start sentinel.
Function names and line tables
All function metadata (entry offsets, names, files, line numbers, frame sizes, inlining trees, GC liveness maps) is in the Format:Go pclntab, which the runtime needs for stack traces and garbage collection, so it survives stripping. The runtime reaches it through runtime.firstmoduledata (type moduledata, in .noptrdata/.data), whose first word points to the pclntab header and whose second word points to the function name table. Searching the data sections for the header's address is the easiest way to find moduledata in a stripped binary.
Calling convention
Since Go 1.17 on amd64 (Go 1.18 on arm64 and ppc64, 1.19 on riscv64, per the release notes) Go functions use the register-based ABIInternal: integer arguments and results in RAX, RBX, RCX, RDI, RSI, R8, R9, R10, R11 (in that order), floating point in X0-X14, RDX = closure context, R14 = current goroutine g (always), X15 = zero, R12/R13 scratch, R15 GOT temporary in dynamically linked code. Assembly functions keep the old stack-based ABI0 (all arguments and results on the stack), and the toolchain generates wrappers between the two. A decompiler that assumes the Windows x64 or System V convention shows wrong arguments for Go functions.
The usual prologue compares the stack pointer with g.stackguard0 (offset 0x10 of g, after stack.lo and stack.hi) and calls runtime.morestack_noctxt when the stack must grow:
49 3B 66 10 cmp rsp, [r14+10h]
0F 86 xx xx xx xx jbe <block at the end of the function that calls runtime.morestack_noctxt>
Functions with large frames compute the new stack pointer first (4C 8D 64 24 F8 lea r12, [rsp-8], then 4D 3B 66 10 cmp r12, [r14+10h]), as runtime.main does in Go 1.24. Before 1.17, g was loaded from thread-local storage instead: src/runtime/go_tls.h defines get_tls(r) as MOVQ TLS, r and g(r) as 0(r)(TLS*1) on amd64, and runtime/asm_amd64.s at go1.16 (commit f21be2fdc6f1becdbed1592ea0b245cdeedc5ac8) starts its g-dependent code with get_tls(BX) (lines 193, 201); at go1.17 (commit ec5170397c724a8ae440b2bc529f857c86f0e6b1) the same file loads g into R14 (MOVQ DX, R14 // set the g register, line 266). Unverified: the machine form mov rcx, fs:[-8] on linux/amd64 (the linker's TLS offset is not read here); test on a Go 1.16 binary.
Data layouts
On 64-bit targets (all fields pointer-sized):
| Go value | Layout |
|---|---|
string |
data pointer, length (no NUL terminator; literals are packed together in .rodata, so a decompiler shows one huge string)
|
slice []T |
data pointer, length, capacity |
interface{} / any |
*abi.Type, data pointer
|
| non-empty interface | *abi.ITab (interface type, concrete type, hash, method table), data pointer
|
map |
pointer to the runtime map header (Swiss table since Go 1.24) |
chan, func |
pointer (a func value points to a closure whose first word is the code pointer) |
Type descriptors
Every type that can reach an interface or reflection has an abi.Type (48 bytes on 64-bit) in .rodata (between moduledata.types and etypes), followed by kind-specific data (ArrayType, StructType, InterfaceType...) and, for named types with methods, an UncommonType. Its Str field is a 32-bit offset from moduledata.types to an abi.Name: one flag byte (1 exported, 2 tag follows, 4 package path follows, 8 embedded), the length (a uvarint since Go 1.17, two big-endian bytes in Go 1.16 and earlier) and the UTF-8 name, such as *io.LimitedReader (with TFlagExtraStar the leading * is dropped for the base type). The kind is the low 5 bits of Kind_ (1 Bool ... 22 Pointer, 23 Slice, 24 String, 25 Struct, 26 UnsafePointer). The itabs for concrete-type/interface pairs known at link time are listed by moduledata.itablinks (ELF section .itablink), which tells which interfaces each type implements.
Version differences
- 1.2: pclntab format introduced (magic
FB FF FF FF). 1.16: new header and per-CU file tables (FA FF FF FF). 1.18: function entries as 32-bit offsets fromruntime.text(F0 FF FF FF); build-info strings inline. 1.20:startLinein_func, magicF1 FF FF FF. - 1.17: register ABI on amd64;
abi.Namelengths became uvarints. - 1.24: Swiss-table maps;
KindGCProggone (GC masks built on demand,TFlagGCMaskOnDemand); new ELF section.go.fipsinfo. - 1.26: the "direct interface" bit moved from
Kind_bit 5 (KindDirectIface) toTFlagbit 5 (TFlagDirectIface);moduledatagainedepclntab; the pclntab header'stextStartword is written as 0. - 1.27:
moduledata.typelinks/itablinksreplaced bytypedesclen,itaboffsetanditabsize.
Code & repositories
- https://github.com/golang/go @
dfc6f7db9bd75868ffb5cbc9501a2f4899122d2f· license: BSD-3-Clause
The Go toolchain and runtime. The pclntab, moduledata, type descriptors and build info are defined in src/runtime/symtab.go, src/runtime/runtime2.go, src/internal/abi/{symtab,type,iface}.go and written by src/cmd/link/internal/ld/{pcln,data}.go; debug/gosym and debug/buildinfo are the reference readers.
Tested on: Read at master dfc6f7d (Oct 2026) and tags go1.16, go1.18, go1.20, go1.23.0, go1.24.0, go1.25.0, go1.26.0, go1.27.0; layouts checked against Mailpit v1.22.3 (go1.24.0) windows/linux amd64 binaries and the repo's Go 1.15/1.17 test binaries. · checked 2026-10-17; last activity 2026-10-17
Pitfalls
- Function names contain
.,/,*,(,)and[...](generics), e.g.net/http.(*http2clientConnReadLoop).processPing.deferwrap2; IDA/Ghidra scripts must sanitise them. FuncIDnumbers in_funcchange between releases (Go 1.24:goexit= 8,runtime.main= 18; at the 2026 masterruntime_mainis 17); compare by name, not number.- Function sizes taken from the next pclntab entry include the
CCpadding between functions. - Unverified: obfuscators such as garble rename packages and functions but cannot remove the pclntab, which the runtime needs; its structure stays parseable.
Tools
go version -m BINARY(build info),go tool nm,go tool objdump, and thedebug/gosymanddebug/buildinfopackages.- Recent Ghidra and IDA versions ship Go analyzers that apply pclntab names; Code:Go runtime/gobin (Python) is a dependency-free reader for PE and ELF.
Evidence & references
Source: https://github.com/golang/go at commit dfc6f7db9bd75868ffb5cbc9501a2f4899122d2f (master, October 2026), with older layouts read from the tags go1.16, go1.18, go1.20, go1.24.0, go1.25.0, go1.26.0 and go1.27.0. Tested on the public Mailpit v1.22.3 release binaries (Go 1.24.0, windows/amd64 and linux/amd64, see Software:Mailpit), the Go 1.17 and Go 1.15 test binaries in the Go repository (src/debug/buildinfo/testdata/go117, src/debug/gosym/testdata/pcln115.gz) and one closed-source Go 1.25.5 windows/amd64 program.