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
arm-linux-strip
就像 arm-linux-gcc 是 gcc 的arm嵌入式對應版一樣,
arm-linux-strip也是strip指令的對應版本。
另外:
strip操作是單向的,檔案一單strip過就不能恢複原樣了;
如果檔案大小沒有減小, 那就是已經strip過了;
cc編譯時加上"-s"參數,具有同樣的作用。