【问题标题】:Can I only strip debug information for local symbols only from ELF?我只能从 ELF 中剥离本地符号的调试信息吗?
【发布时间】:2015-08-19 05:00:19
【问题描述】:

我们的构建系统会生成非常大的可执行文件。 许多大小的可执行文件是调试信息。所以 strip 可以显着减少可执行文件的大小。但是如果去掉所有的调试信息,调试就会很困难。

所以,我想知道,有没有办法只去除本地调试信息?比如局部变量,函数参数。我需要保持函数名和文件行之间的关系,以启用 gdb 回溯和 up/down 命令工作。

非常感谢。

【问题讨论】:

    标签: local elf strip debug-symbols


    【解决方案1】:

    我需要保持函数名和文件行之间的关系,以启用 gdb 回溯和 up/down 命令工作。

    你错了:backtraceup/down 工作正常没有任何调试信息。如果backtrace 是您所需要的全部,那么只需在没有任何调试标志的情况下进行构建,就可以了。

    如果您确实需要文件信息,并且如果您正在使用最近的gcc(或g++)进行编译并使用DWARF,那么您可能需要:

          -gsplit-dwarf
           Separate as much dwarf debugging information as possible into a
           separate output file with the extension .dwo.  This option
           allows the build system to avoid linking files with debug
           information.  To be useful, this option requires a debugger
           capable of reading .dwo files.
    

    注意:这仍将文件/行信息保留在主二进制文件中,但将其他所有内容保留在 .dwo 文件中。

    【讨论】:

      【解决方案2】:

      试试 剥离 --strip-debug

      也试试

         -g
         -S
         -d
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-02-07
        • 2015-12-27
        • 1970-01-01
        • 2016-09-01
        • 2016-03-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多