I'm compiling golang code to assembly using:
go build -gcflags -S .
In the assembly code I'm saying a lot of lines like:
PCDATA $2, $1
What does it mean? In the quick guide to asm it states
The FUNCDATA and PCDATA directives contain information for use by the garbage collector; they are introduced by the compile
but there aren't many details
PPC64. This assembler is used by GOARCH values ppc64 and ppc64le.
The Go compiler outputs an abstract, portable form of assembly that doesn't actually map to any real hardware. The Go assembler then uses this pseudo-assembly output in order to generate concrete, machine-specific instructions for the targeted hardware.
As you stated in your answer, A Quick Guide to Go's Assembler states:
The FUNCDATA and PCDATA directives contain information for use by the garbage collector; they are introduced by the compiler.
Russ Cox's article "Go 1.2 Runtime Symbol Information" states:
Similarly, the pseudo-instruction
PCDATA $3, $45
declares that the value with index 3 associated with the current program counter is 45. Each of the pcdata indexes (PCDATA $1, PCDATA $2, and so on) encodes to a separate pc-value table. Just as with funcdata, the index allows the definition of multiple kinds of pcdata for a given function, and there will be a registry for those indexes too.
At run time, the runtime can, from a Func, retrieve the funcdata with a given index or the pcdata with a given index at a given program counter. A pcdata stream may produce an int32 interpreted by reference to corresponding data retrieved as a funcdata pointer.
The struct Func is followed immediately in memory by npcdata int32s giving the offsets to the pcdata tables; if nfuncdata > 0, the npcdata int32s are followed immediately by a possible int32 gap for alignment and then nfuncdata uintptrs giving the funcdata values. If pcsp, pcfile, pcln, or any of the pcdata offsets is zero, that table is considered missing, and all PCs take value -1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With