为什么file命令会显示可执行文件包含"debug_info"?

4
我发现file >=5.30gcc >=6.3已经改变了它的行为。当我编译一个基本程序,比如hello-world时,file的输出表明elf-executable包含某种形式的“debug_info”。
来源:
#include <iostream>
using namespace std;

int main(int argc, char* argv []) {
        cout << "Hello world.\n";
        return 0;
}

编译:

$ g++ -o hello hello.cpp # notice, no option "-g"

检查:

$ file hello # please scroll to the right hand-side, it is at the very end
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=d03b68ed8618fcb97094b18157054f7cc2030f3c, not stripped, with debug_info

我不熟悉readelf。使用readelf -S hello | grep -i debug,如果没有使用"-g"编译,则表示没有调试信息。 如果使用了选项“-g”进行编译,则会看到以下内容,这对我来说看起来很好:

  [27] .debug_aranges    PROGBITS         0000000000000000  0000107c
  [28] .debug_info       PROGBITS         0000000000000000  000010ac
  [29] .debug_abbrev     PROGBITS         0000000000000000  000038ce
  [30] .debug_line       PROGBITS         0000000000000000  00003e54
  [31] .debug_str        PROGBITS         0000000000000000  00004186

我假设在构建我的gcc版本时没有使用隐藏的配置标志,以始终包含某种调试信息。因此,file工具的行为可能已经发生了变化。"debug info"是什么意思?
信息:
我在X86_64上运行GNU/Linux(Archlinux),所有软件包都是最新的。

友情提示: "packages are all up-to-date." 并不意味着编译器是最新的,也不提供任何关于编译器版本的提示。我们可能不知道发行版是否停止更新 GCC 至 3.3.4。这可能有些极端,但更多的主要发行版似乎已经停留在 4.8 和 4.9。最好运行 g++ -v 并在必要时将版本添加到未来的问题中。 - user4581301
你说得没错,但我已经在问题的顶部添加了版本信息。结尾处的注释应该只提供上下文信息。 - Peter
1个回答

6
这是一个错误,已经经过修复。原先默认值为1(表示“真”),现在被更改为0(表示“假”)。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接