我使用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
答案 0 :(得分:1)
听起来像binutils中的一个错误。
您使用的是10岁版本,而不是正式版本,而是随机拍摄的快照。
我会首先尝试当前发布的binutils(版本2.28) - 有可能你遇到的任何错误都已修复。如果没有,您可以在binutils bugzilla中报告。