如何使用 only-keep-debug 反转 objcopy 的条带?

发布于 2024-08-26 13:25:41 字数 426 浏览 5 评论 0原文

在现代 Linux 中,几乎所有对象都被剥离并分成两部分(两个文件)。第一个是可执行文件本身,第二个是从原始 ELF 中剥离出来的调试符号。此类文件是通过

objcopy --only-keep-debug original.elf binary.dbg
mv original.elf binary
objcopy --strip-debug binary

如何将 binarybinary.dbg 合并到带有调试信息的 ELF 文件中创建的?我想重新创建未剥离的原始二进制文件。它可以不逐字节等于原来的,但里面必须有调试符号。

PS 是的,我知道 gnu.debuglink 部分,但它不适用于某些调试器(etnus)和反汇编器(objdump 无法恢复符号信息)

In modern linux almost all objects are stripped and splitted in two parts (two files). First is executable itself and second is debug symbols, stripped out from original ELF. Such files are created with

objcopy --only-keep-debug original.elf binary.dbg
mv original.elf binary
objcopy --strip-debug binary

How can I merge binary and binary.dbg into ELF file with debugging info? I want to recreate unstripped, original binary. It can be not byte-to-byte equal to the original, but it must to have a debug symbols inside.

PS Yes, I know about gnu.debuglink section, but it doesn't work for some debuggers (etnus) and disassemblers (objdump can't restore symbols info)

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

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

发布评论

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

评论(2

落在眉间の轻吻 2024-09-02 13:25:41

对于 ELF,elftils 包包含一个名为 eu-unstrip 的工具来完成这项工作。在您的示例的上下文中:

eu-unstrip binary binary.dbg

binary.dbg 现在同时具有二进制和调试符号。如果我能找到任何文档,我会提供对文档的引用...

For ELF, the elfutils package contains a tool called eu-unstrip that does the job. In the context of your example:

eu-unstrip binary binary.dbg

binary.dbg now has both the binary and debug symbols. I'd include a reference to documentation if I could find any...

又爬满兰若 2024-09-02 13:25:41

您可以使用 eu-unstrip 实用程序将调试符号与可执行文件合并。

eu-unstrip -f <executablefilename> <symbolefilename.debug> -o <newoutputfilename>

You can use eu-unstrip utility which merges debug symbols with executables.

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