Mappings

状态: 开发中

本文档定义了 Mapping 消息的必需属性。

Attributes

表示 Mapping 的消息必须至少包含以下 进程属性 中的一个。

  • process.executable.build_id.gnu
  • process.executable.build_id.go
  • process.executable.build_id.htlhash

如果可能,Mapping 中应包含所有列出的属性。为了促进互操作性,建议每个 Mapping 中都包含 process.executable.build_id.htlhash。关于 process.executable.build_id.go 的使用和目的,请参阅 golang/go#68652

process.executable.build_id.htlhash 的算法

在某些环境中,GNU 和/或 Go 的 build_id 值会被剥离或不可用,例如 Alpine Linux,它常被用作 Docker 环境的基础。因此,为了促进互操作性,定义了一个确定性的 build_id 生成算法,该算法将文件的第一页和最后一页与其长度一起进行哈希处理,如下所示:

Input   ← Concat(File[:4096], File[-4096:], BigEndianUInt64(Len(File)))
Digest  ← SHA256(Input)
BuildID ← Digest[:16]

其中 Input 是文件的前 4096 字节和后 4096 字节的连接(可能重叠,不填充),以及文件长度的 8 字节大端序列化。生成的 BuildID 是哈希摘要截断到 16 字节(128 位)后的十六进制字符串形式。