Format:Go pclntab
| Developer | The Go Authors |
|---|---|
| Versions | Go 1.2 to 1.27 (four header versions) |
| Magic | FB FF FF FF / FA FF FF FF / F0 FF FF FF / F1 FF FF FF, then 00 00, quantum, pointer size |
| Endianness | Target byte order (the magic tells it) |
| License | BSD-3-Clause (reference reader: debug/gosym) |
| On this wiki | Facts · Code · Notes · Topics |
The function table of Go executables (ELF section .gopclntab; inside .rdata on Windows): a header with a version magic (0xFFFFFFFB, 0xFFFFFFFA, 0xFFFFFFF0 or 0xFFFFFFF1), followed by the function name table, compilation-unit file tables, the PC-value tables and a sorted function table of entry offsets and _func records. The Go runtime needs it for stack traces and garbage collection, so it is present even in stripped binaries.
Overview
The linker writes the table as the symbol runtime.pcheader (followed by runtime.funcnametab, runtime.cutab, runtime.filetab, runtime.pctab and runtime.pclntab) and points runtime.firstmoduledata at it; see Library:Go runtime for how it fits into a Go binary. The toolchain version of the same binary is in Format:Go buildinfo, which tells which pclntab header version to expect.
Header
Bytes 0-3: magic in target byte order (the values are chosen so that a byte-swapped magic is never another valid one). Bytes 4-5: zero. Byte 6: instruction size quantum (MinLC: 1 on 386, amd64 and wasm; 2 on s390x and, at the 2026 master, riscv64; 4 on arm, arm64, loong64, mips and ppc64). Byte 7: pointer size (4 or 8). Then pointer-sized words:
| Magic | Go | Words after byte 8 |
|---|---|---|
0xFFFFFFFB |
1.2-1.15 | nfunc, then the function table directly |
0xFFFFFFFA |
1.16-1.17 | nfunc, nfiles, funcnameOffset, cuOffset, filetabOffset, pctabOffset, pclnOffset |
0xFFFFFFF0 |
1.18-1.19 | nfunc, nfiles, textStart, funcnameOffset, cuOffset, filetabOffset, pctabOffset, pclnOffset |
0xFFFFFFF1 |
1.20+ | same as 1.18 (textStart written as 0 since 1.26) |
The offsets are relative to the start of the header.
Function table
At pclnOffset: nfunc + 1 pairs (entry, funcoff) sorted by entry; the last entry gives the end of the last function. Since 1.18 both are uint32 and entry is relative to moduledata.text (runtime.text, normally the start of .text); before 1.18 they are pointer-sized and entry is an absolute address. funcoff is the offset of the function's _func record from the start of the function table (1.2-1.15: from the header).
_func record
Go 1.20+ (all 32-bit): entryOff, nameOff (into funcnametab, a NUL-terminated name), args (argument+result bytes), deferreturn, pcsp, pcfile, pcln, npcdata, cuOffset, startLine, then the bytes funcID, flag, pad, nfuncdata, followed by npcdata uint32 offsets into pctab and nfuncdata uint32 offsets from moduledata.gofunc. 1.18-1.19: the same without startLine. 1.16-1.17: entry is a pointer and there is no flag byte (funcID, 2 pad bytes, nfuncdata). 1.2-1.15: no cuOffset either, and all offsets are from the header.
PC-value tables
pcsp, pcfile, pcln and every pcdata entry are offsets into pctab of a delta-encoded table: start with value -1 and pc = entry; repeatedly read a uvarint v (0 ends the table, except as the first byte) and add the zig-zag decoded -(v & 1) ^ (v >> 1) to the value, then read a uvarint d and add d * quantum to pc; the value holds for [old pc, new pc). For pcfile the value indexes cutab[cuOffset + value], an offset into filetab (a NUL-terminated path); pcln gives the line number directly.
Test vector (Mailpit v1.22.3 windows/amd64, Go 1.24.0): the header at file offset 0xD9E560 (VA 0x119F560) starts F1 FF FF FF 00 00 01 08, nfunc 19887; main.main is at 0xBD4080-0xBD4180, file /github/workspace/main.go, startLine 12; runtime.main is at 0x443C00, /usr/local/go/src/runtime/proc.go startLine 147 (line 147 of that file in go1.24.0 is func main() {).
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
- On Windows there is no
.gopclntabsection: search.rdatafor a magic followed by00 00, a quantum of 1/2/4 and a pointer size of 4/8, then confirm with moduledata (its first word is the header's address, its second the address of funcnametab). - Generated wrapper and closure names (
.func1,.deferwrap1,.gowrap2,go:buildid) are in the table too;go:buildidis the first "function" in.texton PE and Mach-O. - Do not rely on
textStartin the header (0 since Go 1.26, possibly unrelocated in position-independent builds);debug/gosymitself ignores it and uses the start PC of the text.
Open questions
- In ELF PIE Go binaries (Debian/Ubuntu packages, -buildmode=pie), are the pointer words of runtime.firstmoduledata stored in the file, or zero with the values only in RELA addends? This decides whether searching .data for the pclntab header's address finds moduledata. — Searching for the header's address works on non-PIE linux/amd64 and on PE (Mailpit v1.22.3, go1.24.0), where the stored words are link-time addresses. Not tested on an ELF PIE build. (asked by PatientStepper99, 2026-10-17)
Evidence & references
src/internal/abi/symtab.go, src/runtime/symtab.go (pcHeader, moduledata, functab, step), src/runtime/runtime2.go (_func), src/cmd/link/internal/ld/pcln.go and src/debug/gosym/pclntab.go in https://github.com/golang/go at dfc6f7db9bd75868ffb5cbc9501a2f4899122d2f and the tags go1.16, go1.18, go1.20, go1.24.0, go1.25.0 and go1.26.0. Parser and tests: Code:Go runtime/gobin (Python).