有什么理由为什么不从可执行文件中删除符号? [英] Is there any reason why not to strip symbols from executable?

查看:119
本文介绍了有什么理由为什么不从可执行文件中删除符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几年前,我问了一个问题如何减小可执行文件的大小。使用MinGW编译器,剥离符号( -s 选项)有助于减小大小的50%以上。

A couple of years ago I asked a question how to reduce size of executables. Using MinGW compiler, stripping symbols (-s option) helped to reduce 50%+ of the size.

为什么剥离不是默认设置-那么在某些情况下为什么不剥离符号有充分的理由吗?我想更深入地了解它:今天,我只是隐约知道链接库中包含符号。

Why the stripping is not default - is there any good reason why NOT to strip the symbols in some scenarios then? I'd like to understand it more deeply: today, I just vaguely know that symbols are involved in linking library. Are they needed in executable and do they affect executing speed?

推荐答案

MinGW是 Windows的极简GNU的缩写。这样,编译器套件就是GCC ... GNU编译器集合。自然,此编译器套件将倾向于遵守GNU编码标准,该标准要求每个构建应为调试构建 ...即,它应同时包含调试符号和链接所需的符号。 (这是合乎逻辑的,因为与所谓的发布版本相比,调试版本对应用程序开发人员有用的数量级更大)。此外,与仅关注调试构建的系统相比,区分调试构建和发布构建模式的构建系统要复杂得多,可能要复杂得多。

MinGW is an acronym for "Minimalist GNU for Windows"; as such, the compiler suite is GCC ... the GNU Compiler Collection. Naturally, this compiler suite will tend to comply with the GNU Coding Standards, which demand that every build shall be a "debug build" ... i.e. it shall include both debugging symbols, and those required for linking. (This is logical, since a "debug build" is orders of magnitude more useful to the application developer, than is a so-called "release build"). Furthermore, a build system which discriminates between "debug build" and "release build" modes is more complex -- possibly significantly more so -- than one which concerns itself with only a "debug build".

在GNU构建模型中,无论如何都不需要发布构建。在构建时不会创建发行版。它是在安装时创建的-通常是分阶段安装,从中创建发行版 package 。 GNU工具链包括一个 strip 命令和一个 install 命令,它们可以删除调试版本。在创建用于打包发布的分阶段安装时(或在需要时就地安装),在运行过程中,因此确实没有必要用发布版本细节来使构建系统混乱。只需先创建一个调试版本,然后在事件发生后剥离它,以便在需要时将其转换为有效的发布版本。

In the GNU build model, there is no need for a "release build" anyway. A "release" is not created at build time; it is created at installation time -- usually as a "staged" installation, from which a release package is created. The GNU tool-chain includes both a strip command, and an install command, which can strip a "debug build" on the fly, when creating a staged installation for packaging as a release, (or in place, if you wish), so there really is no need to clutter the build system with "release build" specifics; just create a "debug build" up -front, then strip it after the event, so converting this to an effective "release build", when you require it.

您的MinGW工具链从根本上讲是GNU工具链,它完全支持此GNU构建模型。

Since your MinGW tool-chain is fundamentally a GNU tool-chain, it fully supports this GNU build model.

这篇关于有什么理由为什么不从可执行文件中删除符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆