什么是Go汇编中的PCDATA的含义?

8
我正在使用以下命令将 Golang 代码编译成汇编语言:
go build -gcflags -S .

在汇编代码中,我写了很多类似于以下的行:
PCDATA  $2, $1

这是什么意思?在汇编快速指南中,它声明:

FUNCDATA和PCDATA指令包含垃圾收集器使用的信息;它们由编译器引入

但没有太多细节。

9
请访问 https://blog.altoros.com/golang-part-4-object-files-and-function-metadata.html。 - Michael
1个回答

5
正如你在答案中所说,《Go汇编快速指南》中提到:

FUNCDATA和PCDATA指令包含垃圾收集器使用的信息;它们由编译器引入。

Russ Cox的文章“Go 1.2运行时符号信息”提到:

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.


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接