有时候我们需要知道一个*.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