码迷,mamicode.com
首页 > 其他好文 > 详细

裁剪可执行程序的体积strip

时间:2014-07-15 10:54:43      阅读:477      评论:0      收藏:0      [点我收藏+]

标签:command   removes   number   执行文件   

strip删除-g生成的程序调试连接表的信息
对于可执行文件,使用命令strip之后,
体积只有原来的九分之一
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工具调试:
-bash-3.00$ gdb
GNU gdb 6.2.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
(gdb) file ISMG_LogServer_SOL10_GCC34_V500_090320
Reading symbols from /export/home1/ismg/ISMG5/bin/ISMG_LogServer_SOL10_GCC34_V500_090320...done.
(gdb)

执行strip命令:
strip ISMG_LogServer_SOL10_GCC34_V500_090320

string后,用gdb工具调试:
-bash-3.00$ gdb
GNU gdb 6.2.1
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "sparc-sun-solaris2.10".
(gdb) file ISMG_LogServer_SOL10_GCC34_V500_090320
Reading symbols from /export/home1/ismg/ISMG5/bin/ISMG_LogServer_SOL10_GCC34_V500_090320...(no debugging symbols found)...done.
(gdb)

二、下面是对可执行文件ISMG_LogServer_SOL10_GCC34_V500_090320执行strip命令前后,文件大小的变化:
strip前,文件的大小:
-bash-3.00$ ls -lt | grep LogServer
-rwxr-xr-x  1 ismg  dba  436944  3月 20日 10:39 ISMG_LogServer_SOL10_GCC34_V500_090320

执行strip命令:
strip ISMG_LogServer_SOL10_GCC34_V500_090320

strip后,文件的大小:
-bash-3.00$ ls -lt | grep LogServer
-rwxr-xr-x  1 ismg  dba  71116  3月 20日 10:40 ISMG_LogServer_SOL10_GCC34_V500_090320

裁剪可执行程序的体积strip,布布扣,bubuko.com

裁剪可执行程序的体积strip

标签:command   removes   number   执行文件   

原文地址:http://5228690.blog.51cto.com/5218690/1438111

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!