ELF 的 gnu_debuglink 部分给了我奇怪的名字

发布于 2025-01-09 22:15:08 字数 328 浏览 3 评论 0原文

我使用过 Ubuntu 20.04.3,当我运行时,

readelf  --string-dump=.gnu_debuglink /usr/bin/cp

我得到了奇怪的调试文件名,同时期待类似 cp.debug 的内容。

String dump of section '.gnu_debuglink':
  [     0]  674b3a5e9ca27e34cf3517aa997ba91ce6e0a0.debug
  [    31]  k`-

这是原始的 Ubuntu 映像,根本没有修改。 这有什么原因吗?

I've used Ubuntu 20.04.3, and when I run

readelf  --string-dump=.gnu_debuglink /usr/bin/cp

I got weird debug filename while expecting something like cp.debug

String dump of section '.gnu_debuglink':
  [     0]  674b3a5e9ca27e34cf3517aa997ba91ce6e0a0.debug
  [    31]  k`-

This is the original Ubuntu image, no modification at all.
Is there any reason for this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好多鱼好多余 2025-01-16 22:15:08

当我期待像 cp.debug 这样的东西时,我得到了奇怪的调试文件名

这个名字没有什么奇怪的。

有两种常见方案可用于关联程序和该程序的调试信息——程序名称或其链接器构建 ID。

您可以使用 readelf -n /usr/bin/cp 找到链接器 build-id。以下是我系统上的输出:

Displaying notes found in: .note.gnu.build-id
  Owner                Data size        Description
  GNU                  0x00000014       NT_GNU_BUILD_ID (unique build ID bitstring)         Build ID: 2f6b630344b1b72875f756dce05a40186d18c6d8

Displaying notes found in: .note.ABI-tag
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)            OS: Linux, ABI: 3.2.0

您的 cp 版本的链接器构建 ID 很可能是 674b3a5e9ca27e34cf3517aa997ba91ce6e0a0。

对于可能出现在多个不同名称下的程序,使用链接器 build-id 特别方便(仅使用程序名称,您将必须创建调试信息的多个副本(或链接))。

另外,如果程序更新,其链接器构建 ID 将会更改,因此调试器不可能加载“过时的”调试信息。

I got weird debug filename while expecting something like cp.debug

There is nothing weird about this name.

There are two common schemes for associating the program and debug info for that program -- name of the program, or its linker build-id.

You can find linker build-id with readelf -n /usr/bin/cp. Here is the output on my system:

Displaying notes found in: .note.gnu.build-id
  Owner                Data size        Description
  GNU                  0x00000014       NT_GNU_BUILD_ID (unique build ID bitstring)         Build ID: 2f6b630344b1b72875f756dce05a40186d18c6d8

Displaying notes found in: .note.ABI-tag
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)            OS: Linux, ABI: 3.2.0

Chances are, the linker build-id for your version of cp is 674b3a5e9ca27e34cf3517aa997ba91ce6e0a0.

Using linker build-id is especially convenient for programs which can appear under several different names (where using just the program name you would have to create several copies (or links) of the debug info).

Also, if the program is updated, its linker build-id will change, and so there is no chance that the "stale" debug info would be loaded by the debugger.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文