【发布时间】:2017-06-02 10:29:10
【问题描述】:
我使用objcopy 提取/替换某些部分是 Windows 系统上的 ELF 文件。
>objcopy.exe -V
GNU objcopy 2.17.50 20060824
Copyright 2005 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
这通常有效。
但我的 elf 文件包含调试信息,我需要在交付前删除这些信息以减小文件大小。
我发现 -g 或 --strip-debug 选项应该可以满足我的需求:
>"objcopy.exe" --strip-debug -I elf32-big -O elf32-big with-debug.elf without-debug.elf
但是失败得很惨。而不是使文件更小,它在失败之前将文件大小从〜20MB扩大到3GB:
objcopy.exe: without-debug.elf: File truncated
objcopy.exe: without-debug.elf: No space left on device
如何使用 objcopy 从 ELF 中正确删除调试信息?
不知道这是否重要,但 objcopy 对 ELF 中的大多数部分发出一些警告,如下所示:
BFD: without-debug.elf: warning: allocated section `.sdata' not in segment
【问题讨论】: