Why does the compiler version appear in my ELF executable?

后端 未结 6 780
说谎
说谎 2021-01-04 04:43

I\'ve recently compiled a simple hello world C program under Debian Linux using gcc:

gcc -mtune=native -march=native -m32 -s -Wunused -O2 -o hello hello.c
         


        
6条回答
  •  囚心锁ツ
    2021-01-04 05:03

    I had the same issue myself, but using MinGW's GCC implementation - stripping the executable and passing the -Qn option did nothing, and I couldn't remove the ".comment" section as there wasn't one.

    In order to stop the compiler including this information, regardless of which sections are in your executable, you can pass the -fno-ident parameter to the compiler and linker:

    Without the parameter (strings -a [filename]):

    !This program cannot be run in DOS mode.
    .text
    0`.rdata
    0@.idata
    GCC: (tdm64-2) 4.8.1
    

    With the parameter:

    !This program cannot be run in DOS mode.
    .text
    0`.idata
    

提交回复
热议问题