欢迎光临散文网 会员登陆 & 注册

About linux的strip命令

2023-04-07 10:37 作者:有AI野心的电工和码农  | 我要投稿

strip命令

The strip command removes the symbol table SHT_SYMTAB and its associated string table, debugging information, and line number information from ELF object files.

That is, besides the symbol table and associated string table, the following sections are removed:

.line

.debug*

.stab*

该命令从可执行文件、动态链接库, 等等, 二进制文件的ELF对象文件中删除符号表SHT_SYMTAB, 行号信息, 调试信息, 字符串表;

命令一旦执行成功, 那么gdb就读不到这些文件的符号表了, 也就不能进行正常的调试了;

一、下面是对可执行文件ISMG_LogServer_SOL10_GCC34_V500_090320执行strip命令前后, gdb命令对它的调试信息的变化:

strip前,用gdb工具调试:

执行strip命令:

strip ISMG_LogServer_SOL10_GCC34_V500_090320

string后,用gdb工具调试:

二、下面是对可执行文件ISMG_LogServer_SOL10_GCC34_V500_090320执行strip命令前后,文件大小的变化:

strip前,文件的大小:

执行strip命令:

strip ISMG_LogServer_SOL10_GCC34_V500_090320

strip后,文件的大小:

arm-linux-strip

就像 arm-linux-gcc 是 gcc 的arm嵌入式对应版一样,

arm-linux-strip也是strip命令的对应版本。

另外:

strip操作是单向的,文件一单strip过就不能恢复原样了;

如果文件大小没有减小, 那就是已经strip过了;

cc编译时加上"-s"参数,具有同样的作用。


About linux的strip命令的评论 (共 条)

分享到微博请遵守国家法律