Linux下查看*.so和可执行程序是Debug版本方法

本文介绍了如何确定Linux系统中的*.so动态链接库和可执行文件是否为Debug版本。通过使用readelf -S命令并结合grep过滤,可以检查文件中是否存在调试信息。readelf作为不依赖BFD库的独立工具,能提供更详细的信息,特别是在验证BFD库正确性方面。当遇到BFD库无法处理的CPU类型时,readelf仍能显示文件内容。
摘要由CSDN通过智能技术生成

    有时候我们需要知道一个*.so文件或者可执行文件是debug版本的还是release版本的,这时我们有哪些方法呢?

    1.readelf -S filename |grep debug

    比如:

 g++ thread.cpp -o thread_test_nodebug -lpthread

readelf -S thread_test_nodebug
 yanyang@ubuntu:~/MyGit/thread$ readelf -S thread_test_nodebug
 There are 30 section headers, starting at offset 0x11e0:

Section Headers:
  [Nr] Name              Type             Address           Offset
       Size              EntSize          Flags  Link  Info  Align
  [ 0]                   NULL             0000000000000000  00000000
       0000000000000000  0000000000000000           0     0     0
  [ 1] .interp           PROGBITS         0000000000400238  00000238
       000000000000001c  0000000000000000   A       0     0     1
  [ 2] .note.ABI-tag     NOTE             0000000000400254  00000254
       0000000000000020  0000000000000000   A       0     0     4
  [ 3] .note.gnu.build-i NOTE             0000000000400274  00000274
       0000000000000024  0000000000000000   A       0     0     4
  [ 4] .gnu.hash         GNU_HASH         0000000000400298  00000298
       0000000000000030  0000000000000000   A       5     0     8
  [ 5] .dynsym           DYNSYM           00000000004002c8  000002c8
       0000000000000198  0000000000000018   A       6     1     8
  [ 6] .dynstr           STRTAB           0000000000400460  00000460
       00000000000001a8  0000000000000000   A       0     0     1
  [ 7] .gnu.version      VERSYM           0000000000400608  00000608
       0000000000000022  0000000000000002   A       5     0     2
  [ 8] .gnu.version_r    VERNEED          0000000000400630  00000630
       0000000000000060  0000000000000000   A       6     3     8
  [ 9] .rela.dyn         RELA             0000000000400690  00000690
       0000000000000030  0000000000000018   A       5     0     8
  [10] .rela.plt         RELA             00000000004006c0  000006c0
       0000000000000120  0000000000000018   A       5    12     8
  [11] .init             PROGBITS         00000000004007e0  000007e0
       000000000000001a  0000000000000000  AX       0     0     4
  [12] .plt              PROGBITS         0000000000400800  00000800
       00000000000000d0  0000000000000010  AX       0     0     16
  [13] .text             PROGBITS         00000000004008d0  000008d0
       00000000000002f2  0000000000000000  AX       0     0     16
  [14] .fini             PROGBITS         0000000000400bc4  00000bc4
       0000000000000009  0000000000000000  AX       0     0     4
  [15] .rodata           PROGBITS         0000000000400bd0  00000bd0
       0000000000000054  0000000000000000   A       0     0     8
  [16] .eh_frame_hdr     PROGBITS         0000000000400c24  00000c24
       000000000000004c  0000000000000000   A       0     0     4
  [17] .eh_frame         PROGBITS         0000000000400c70  00000c70
       000000000000015c  0000000000000000   A       0     0     8
  [18] .init_array       INIT_ARRAY       0000000000600de8  00000de8
       0000000000000010  0000000000000000  WA       0     0     8
  [19] .fini_array       FINI_ARRAY       0000000000600df8  00000df8
       0000000000000008  00
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值