Why does the compiler version appear in my ELF executable?

后端 未结 6 782
说谎
说谎 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:12

    That's in a comment section in the ELF binary. You can strip it out:

    $ gcc -m32 -O2 -s -o t t.c
    $ ls -l t
    -rwxr-xr-x 1 me users 5488 Jun  7 11:58 t
    $ readelf -p .comment t
    
    String dump of section '.comment':
      [     0]  GCC: (Gentoo 4.5.1-r1 p1.4, pie-0.4.5) 4.5.1
      [    2d]  GCC: (Gentoo 4.5.2 p1.1, pie-0.4.5) 4.5.2
    
    
    $ strip -R .comment t
    
    
    $ readelf -p .comment t
    readelf: Warning: Section '.comment' was not dumped because it does not exist!
    $ ls -l t
    -rwxr-xr-x 1 me users 5352 Jun  7 11:58 t
    

    The gains are tiny though, not sure it's worth it.

提交回复
热议问题