Linux下查看.so和可执行文件是否debug编译
如何判断一个.so是否是debug编译的?
如果用此方法:用file来查看一个.so, 根据是否包含”not stripped”来判断该.so是否是debug编译的。然而stripped/not stripped并不是debug/release编译的判断标准. 对debug和release的.so运行file后可得出几乎相同的输出, 都是not stripped。所以此方法是不准确的。
debug/release的区别更多的表现在.so和可执行程序所拥有的段上。debug编译出来的.so和可执行程序拥有很多附加的段来包含哪些debug的信息。所以查看段信息是一种判断的方式。
对同一个开源软件进行debug和release编译, 并且查看某个.so的段(readelf -S)
> readelf -S 文件名
- 1
发现release编译的只有29个段:
There are 29 section headers, starting at offset 0x1b7d78:
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
0000000000003430 0000000000000000 A 3 0 8
[ 3] .dynsym DYNSYM 0000000000003620 00003620
000000000000b400 0000000000000018 A 4 2 8
[ 4] .dynstr STRTAB 000000000000ea20 0000ea20
00000000000083e2 0000000000000000 A 0 0 1
[ 5] .gnu.version VERSYM 0000000000016e02 00016e02
0000000000000f00 0000000000000002 A 3 0 2
[ 6] .gnu.version_r VERNEED 0000000000017d08 00017d08
0000000000000080 0000000000000000 A 4 2 8
[ 7] .rela.dyn RELA 0000000000017d88 00017d88
0000000000009570 0000000000000018 A 3 0 8
[ 8] .rela.plt RELA 00000000000212f8 000212f8
00000000000080d0 0000000000000018 A 3 10 8
[ 9] .init PROGBITS 00000000000293c8 000293c8
0000000000000018 0000000000000000 AX 0 0 4
[10] .plt PROGBITS 00000000000293e0 000293e0
00000000000055f0 0000000000000010 AX 0 0 4
[11] .text PROGBITS 000000000002e9d0 0002e9d0
0000000000144658 0000000000000000 AX 0 0 16
[12] .fini PROGBITS 0000000000173028 00173028
000000000000000e 0000000000000000 AX 0 0 4
[13] .rodata PROGBITS 0000000000173040 00173040
000000000001e9a0 0000000000000000 A 0 0 32
[14] .eh_frame_hdr PROGBITS 00000000001919e0 001919e0
000000000000427c 0000000000000000 A 0 0 4
[15] .eh_frame PROGBITS 0000000000195c60 00195c60
0000000000017d7c 0000000000000000 A 0 0 8
[16] .ctors PROGBITS 00000000003ae1e8 001ae1e8
0000000000000010 0000000000000000 WA 0 0 8
[17] .dtors PROGBITS 00000000003ae1f8 001ae1f8
0000000000000010 0000000000000000 WA 0 0 8
[18] .jcr PROGBITS 00000000003ae208 001ae208
0000000000000008 0000000000000000 WA 0 0 8
[19] .data.rel.ro PROGBITS 00000000003ae220 001ae220
0000000000005b38 0000000000000000 WA 0 0 32
[20] .dynamic DYNAMIC 00000000003b3d58 001b3d58
00000000000001a0 0000000000000010 WA 4 0 8
[21] .got PROGBITS 00000000003b3ef8 001b3ef8
00000000000010e8 0000000000000008 WA 0 0 8
[22] .got.plt PROGBITS 00000000003b4fe8 001b4fe8
0000000000002b08 0000000000000008 WA 0 0 8
[23] .data PROGBITS 00000000003b7b00 001b7b00
0000000000000158 0000000000000000 WA 0 0 32
[24] .bss NOBITS 00000000003b7c58 001b7c58
0000000000000010 0000000000000000 WA 0 0 8
[25] .comment PROGBITS 0000000000000000 001b7c58
000000000000002a 0000000000000001 MS 0 0 1
[26] .shstrtab STRTAB 0000000000000000 001b7c82
00000000000000f5 0000000000000000 0 0 1
[27] .symtab SYMTAB 0000000000000000 001b84b8
000000000000fdb0 0000000000000018 28 788 8
[28] .strtab STRTAB 0000000000000000 001c8268
000000000000b8b0 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)
而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)
对于可执行文件也有类似的区别.
所以这应当是判断debug/release的一个比较正确的方法了.
Linux下查看.so和可执行文件是否debug编译的更多相关文章
- inux下查看.so和可执行文件是否debug编译的方法
命令 readelf -S libxxx.so |grep debug 如果有打印信息就是debug,否则是release.
- (转)Linux下查看文件和文件夹大小 删除日志
场景:在sts中执行自动部署时候maven提示No space left on device错误,后来经检查发现是磁盘空间满了,用下面的方法分析发现tomcat下面的logs目录占用了很大的空间,删除 ...
- Linux下查看磁盘挂载的三种方法
Linux下查看磁盘挂载的三种方法 2009-06-05 23:17 好久没有更新日志了,呵呵.不是没有要写的东东.实在抽不出时间来写,要准备公司的考试呢,C++考试.已经有七个月没有写C++代码了, ...
- Linux下查看文件和文件夹大小 删除日志
场景:在sts中执行自动部署时候maven提示No space left on device错误,后来经检查发现是磁盘空间满了,用下面的方法分析发现tomcat下面的logs目录占用了很大的空间,删除 ...
- linux下查看和添加PATH环境变量
linux下查看和添加PATH环境变量 $PATH:决定了shell将到哪些目录中寻找命令或程序,PATH的值是一系列目录,当您运行一个程序时,Linux在这些目录下进行搜寻编译链接. 编辑你的 PA ...
- [转载] linux 下查看机器cpu是几核的
linux 下查看机器cpu是几核的 本文转自”映月的博客“:http://wurhuangfeng.blog.163.com/blog/static/35178241201111235829116/ ...
- linux下查看tomcat和jdk版本号
linux下查看tomcat和jdk版本号的命令: 这个需要进入到bin目录下面 ,执行"./version.sh"命令 [root@hncsweb bin]# ./version ...
- linux下查看进程占用端口和端口占用进程命令
Linux下查看进程占用端口: 查看程序对应进程号:ps –ef|grep 进程名 REDHAT :查看进程号所占用的端口号:netstat –nltp|grep 进程号 ubuntu:查看进程占用端 ...
- Linux下查看某一进程所占用内存的方法
Linux下查看某一个进程所占用的内存,首先可以通过ps命令找到进程id,比如 ps -ef | grep kafka 可以看到kafka这个程序的进程id 可以看到是2913,现在可以使用如下命令查 ...
随机推荐
- javascript getElementsByClassName扩展函数
代码: function getElementsByClassName(){ if(!arguments[0]){return []};//未指定任何参数,直接返回 var args=argument ...
- this(this的4种指向和改变this指向的方式)
this是Javascript语言的一个关键字. 随着函数使用场合的不同,this的值会发生变化.但是有一个总的原则,那就是this指的是,调用函数的那个对象. 1.this指向的形式4种 a.如果是 ...
- 面试题:android用户注册代码 密码需要加密传输吗
答案是肯定的,至少比明文好 客户端注册和登录的时候:一个可行的方法是,客户端提交 md5(password) 密码(如上所述,此方法只是简单保护了密码,是可能被查表获取密码的). 注册的时候:服务端数 ...
- Spark GraphX图计算简单案例【代码实现,源码分析】
一.简介 参考:https://www.cnblogs.com/yszd/p/10186556.html 二.代码实现 package big.data.analyse.graphx import o ...
- 201871010107-公海瑜《面向对象程序设计(Java)》第四周学习总结
201871010107-公海瑜<面向对象程序设计(Java)>第四周学习总结 项目 ...
- VIJOS-P1199 核弹危机
JDOJ 1347: VIJOS-P1199 核弹危机 题目传送门 Description shibowen和ganggang正在玩红警,可不料shibowen造出了核弹正要发射......(gang ...
- 2016 ACM/ICPC亚洲区沈阳站
A B C D E F G H I J K L M O O O $\varnothing$ $\varnothing$ $\varnothing$ $\varnothing$ $\varnothi ...
- celery异步任务、定时任务
阅读目录 一 什么是Celery? 二 Celery的使用场景 三 Celery的安装配置 四 Celery异步任务 五Celery定时任务 六在Django中使用Celery 一 什么是Cele ...
- [Algorithm] 118. Pascal's Triangle
Given a non-negative integer numRows, generate the first numRows of Pascal's triangle. In Pascal's t ...
- Python错误“ImportError: No module named MySQLdb”解决方法
这个错误可能是因为没有安装MySQL模块,这种情况下执行如下语句安装: pip install MySQLdb 如果安装时遇到错误“_mysql.c:29:20: 致命错误:Python.h:没有那个 ...