0

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
4

1 回答 1

1

听起来像 binutils 中的错误。

您使用的是 10 年前的版本,不是官方版本,而是随机拍摄的快照。

我会首先尝试当前版本的 binutils(2.28 版)——你遇到的任何错误都有可能已经被修复。如果没有,您可以在 binutils bugzilla中报告。

于 2017-06-02T14:02:45.227 回答