怎样查看自己linux适合的GCC,如何知道用于构建linux的gcc版本?

Dietrich Epp..

13

对于程序,.comment如果您的系统使用ELF ,它将出现在ELF可执行文件的部分中.

$ cat main.c

int main() { }

$ gcc main.c

$ objdump -s -j .comment a.out

a.out: file format elf64-x86-64

Contents of section .comment:

0000 00474343 3a202844 65626961 6e20342e .GCC: (Debian 4.

0010 372e322d 35292034 2e372e32 00474343 7.2-5) 4.7.2.GCC

0020 3a202844 65626961 6e20342e 342e372d : (Debian 4.4.7-

0030 33292034 2e342e37 00 3) 4.4.7.

用于编译内核的编译器可以从字符串中获得/proc/version,例如:

$ cat /proc/version

Linux version 3.8.5 (...) (gcc version 4.7.2 (Debian 4.7.2-5) ) ...

一个重要的警告

该.comment部分是可选的.当可执行文件捆绑到包中时,许多发行版将从可执行文件中删除它.该部分将放在一个单独的调试包中.

例如,在我的系统上:

$ objdump -s -j .comment /usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0

/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0: file format elf64-x86-64

objdump: section '.comment' mentioned in a -j option, but not found in any input

file

安装libcurl3-dbg软件包后,我们按照GNU调试链接获取带有剥离部分的图像:

$ objdump -s -j .comment \

/usr/lib/debug/.build-id/8c/4ae0ad17a4e76bab47c487047490061bd49de3.debug

/usr/lib/debug/.build-id/8c/4ae0ad17a4e76bab47c487047490061bd49de3.debug:

file format elf64-x86-64

Contents of section .comment:

0000 4743433a 20284465 6269616e 20342e37 GCC: (Debian 4.7

0010 2e322d35 2920342e 372e3200 .2-5) 4.7.2.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值