为什么file-command声明,该可执行文件包含"debug_info"

Pet*_*ter 4 c c++ linux gcc

我发现文件> = 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;
}
Run Code Online (Sandbox Code Playgroud)

编译:

$ g++ -o hello hello.cpp # notice, no option "-g"
Run Code Online (Sandbox Code Playgroud)

检查:

$ 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
Run Code Online (Sandbox Code Playgroud)

我对readelf并不熟悉.一个readelf -S你好| 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
Run Code Online (Sandbox Code Playgroud)

我假设在构建我的gcc版本时没有人使用隐藏的configure-flag ,总是包含某种调试信息.所以util 文件的行为可能已经改变了.文件对"调试信息"意味着什么?

信息:
我在X86_64上运行GNU/Linux(Archlinux),包都是最新的.

Pet*_*ter 6

这是一个错误,它是固定的.默认值为1(表示"true"),固定值将其更改为0(表示"false").