Linux下查看.so和可执行文件是否debug编译的方法(必看)

2019-09-23 09:11:45刘景俊

而debug编译的则有38个段, 且所有比release编译多出来的段,都是以.debug_作为开始字符串来命名的:

There are 38 section headers, starting at offset 0xdacc00:
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .note.gnu.build-i NOTE 00000000000001c8 000001c8
0000000000000024 0000000000000000 A 0 0 4
[ 2] .gnu.hash GNU_HASH 00000000000001f0 000001f0
0000000000003620 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000003810 00003810
000000000000c000 0000000000000018 A 4 2 8
[ 4] .dynstr STRTAB 000000000000f810 0000f810
0000000000008ccb 0000000000000000 A 0 0 1
[ 5] .gnu.version VERSYM 00000000000184dc 000184dc
0000000000001000 0000000000000002 A 3 0 2
[ 6] .gnu.version_r VERNEED 00000000000194e0 000194e0
0000000000000070 0000000000000000 A 4 2 8
[ 7] .rela.dyn RELA 0000000000019550 00019550
0000000000009b40 0000000000000018 A 3 0 8
[ 8] .rela.plt RELA 0000000000023090 00023090
0000000000008388 0000000000000018 A 3 10 8
[ 9] .init PROGBITS 000000000002b418 0002b418
0000000000000018 0000000000000000 AX 0 0 4
[10] .plt PROGBITS 000000000002b430 0002b430
00000000000057c0 0000000000000010 AX 0 0 4
[11] .text PROGBITS 0000000000030bf0 00030bf0
00000000001d2428 0000000000000000 AX 0 0 16
[12] .fini PROGBITS 0000000000203018 00203018
000000000000000e 0000000000000000 AX 0 0 4
[13] .rodata PROGBITS 0000000000203040 00203040
00000000000276b8 0000000000000000 A 0 0 32
[14] .eh_frame_hdr PROGBITS 000000000022a6f8 0022a6f8
00000000000059dc 0000000000000000 A 0 0 4
[15] .eh_frame PROGBITS 00000000002300d8 002300d8
000000000001715c 0000000000000000 A 0 0 8
[16] .ctors PROGBITS 0000000000448018 00248018
0000000000000010 0000000000000000 WA 0 0 8
[17] .dtors PROGBITS 0000000000448028 00248028
0000000000000010 0000000000000000 WA 0 0 8
[18] .jcr PROGBITS 0000000000448038 00248038
0000000000000008 0000000000000000 WA 0 0 8
[19] .data.rel.ro PROGBITS 0000000000448040 00248040
0000000000005b38 0000000000000000 WA 0 0 32
[20] .dynamic DYNAMIC 000000000044db78 0024db78
00000000000001a0 0000000000000010 WA 4 0 8
[21] .got PROGBITS 000000000044dd18 0024dd18
00000000000012d0 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 000000000044efe8 0024efe8
0000000000002bf0 0000000000000008 WA 0 0 8
[23] .data PROGBITS 0000000000451be0 00251be0
0000000000000160 0000000000000000 WA 0 0 32
[24] .bss NOBITS 0000000000451d40 00251d40
0000000000000040 0000000000000000 WA 0 0 16
[25] .comment PROGBITS 0000000000000000 00251d40
0000000000000054 0000000000000001 MS 0 0 1
[26] .debug_aranges PROGBITS 0000000000000000 00251d94
00000000000030c0 0000000000000000 0 0 1
[27] .debug_pubnames PROGBITS 0000000000000000 00254e54
000000000000b8cb 0000000000000000 0 0 1
[28] .debug_info PROGBITS 0000000000000000 0026071f
000000000097f69b 0000000000000000 0 0 1
[29] .debug_abbrev PROGBITS 0000000000000000 00bdfdba
0000000000028211 0000000000000000 0 0 1
[30] .debug_line PROGBITS 0000000000000000 00c07fcb
0000000000075fbf 0000000000000000 0 0 1
[31] .debug_str PROGBITS 0000000000000000 00c7df8a
0000000000019789 0000000000000001 MS 0 0 1
[32] .debug_loc PROGBITS 0000000000000000 00c97713
0000000000043528 0000000000000000 0 0 1
[33] .debug_pubtypes PROGBITS 0000000000000000 00cdac3b
00000000000d1c97 0000000000000000 0 0 1
[34] .debug_ranges PROGBITS 0000000000000000 00dac8d2
00000000000001c0 0000000000000000 0 0 1
[35] .shstrtab STRTAB 0000000000000000 00daca92
000000000000016e 0000000000000000 0 0 1
[36] .symtab SYMTAB 0000000000000000 00dad580
0000000000014688 0000000000000018 37 1437 8
[37] .strtab STRTAB 0000000000000000 00dc1c08
000000000000e5a1 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)