Deep dive into a go binary
summary
A compiled Go ELF is about 2.2MB for a Hello World and splits into headers, six segments and 26 sections: text ~604KB (machine code), rodata ~313KB (strings, types, interfaces), gopclntab ~490KB (PC→file/line/function for stack traces), and DWARF ~622KB (debug info). readelf, go tool objdump, xxd and go tool buildid reveal these; strip removes debug/symbol sections reducing the binary to 1.5MB and garble obfuscates leaked names/paths.
AI-written summary · about
chapters (24)
- 0:00Go binary deep dive
- 1:33Hello world binary size
- 3:19ELF binary structure
- 8:44ELF headers in execution
- 11:15ELF sections in Go
- 14:27Read-only data in Go
- 16:39Symbol and string tables
- 19:29DWARF debugging info
- 20:14Go-specific binary sections
- 23:13Go stack traces
- 29:22Garbage collection efficiency
- 30:26Segments in binary data
- 32:36Stripping Go binaries
- 33:59Binary metadata risks
- 35:45Stack traces without symbols
- 36:50Reflect optimization
- 37:34Go binary layout
- 39:01Further learning
- 42:14Q&A: Architecture differences
- 42:57Q&A: Build ID sections
- 44:45Q&A: Static linking
- 45:48Q&A: Runtime access to sections
- 47:14Q&A: Compressing Go binaries
- 48:40Q&A: TinyGo and UPX
related talks
24m(Ab)using Compiler Tools
01h 04mThe Bits Between the Bits: How We Get to main()
43mDebugging Code Generation in Go
43mUnderstanding the Go Compiler
01h 00mFrom Program to Process - What Happens After the Compiler
31mHow to Write a Self-Hosted Go Compiler from Scratch
01h 23mC++ Linkers and the One Definition Rule
31mThe Road to CGO-Less is Paved
