$ cat x.go
package main
func main() {
println(3)
}
$ GOOS=linux GOARCH=amd64 go tool compile -S x.go # or: go build -gcflags -S x.go
--- prog list "main" ---
0000 (x.go:3) TEXT main+0(SB),$8-0
0001 (x.go:3) FUNCDATA $0,gcargs·0+0(SB)
0002 (x.go:3) FUNCDATA $1,gclocals·0+0(SB)
0003 (x.go:4) MOVQ $3,(SP)
0004 (x.go:4) PCDATA $0,$8
0005 (x.go:4) CALL ,runtime.printint+0(SB)
0006 (x.go:4) PCDATA $0,$-1
0007 (x.go:4) PCDATA $0,$0
0008 (x.go:4) CALL ,runtime.printnl+0(SB)
0009 (x.go:4) PCDATA $0,$-1
0010 (x.go:5) RET ,
...
The FUNCDATA and PCDATA directives contain information for use by the garbage collector; they are introduced by the compiler.
1) funcdata What is this .0 which is not a dot :)
2) pcdata what does $-1 mean here
3) Is there some more information on funcdata and pcdata? Doesn't have to be in detail, because i know its a can of worms, but just enough so I can tell what the garbage collector will be doing :)
--
When defining a TEXT, specifying frame size $-4 tells the linker that this is a leaf function that does not need to save LR on entry.
4) What is LR?
5) Leaf as in closure function?