next up previous contents
Next: strip-symbol Up: strip 工具 Previous: strip-unneeded   Contents

keep-symbol

  1. 重新編譯程式。
    [dywang@dyH gcc]$ gcc -g -o stripex1 stripex1.c
    [dywang@dyH gcc]$ ll stripex1
    -rwxrwxr-x. 1 dywang dywang 8195 Sep  1 08:58 stripex1
    
  2. 移除符號項目時指定保留某些符號資訊
    [dywang@dyH gcc]$ strip -s -Kstripex1.c stripex1
    
  3. 修整後的執行檔,符號項目從 75 項變成 28 項,注意項目符號第二項名字為 stripex1.c,就是保留下來的項目。
    Symbol table '.dynsym' contains 4 entries:
       Num:    Value          Size Type    Bind   Vis      Ndx Name
         0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
         1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND printf@GLIBC_2.2.5 (2)
         2: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
         3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.2.5 (2)
    
    Symbol table '.symtab' contains 28 entries:
       Num:    Value          Size Type    Bind   Vis      Ndx Name
         0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
         1: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS stripex1.c
         2: 0000000000400200     0 SECTION LOCAL  DEFAULT    1 
         3: 000000000040021c     0 SECTION LOCAL  DEFAULT    2 
         4: 000000000040023c     0 SECTION LOCAL  DEFAULT    3 
         5: 0000000000400260     0 SECTION LOCAL  DEFAULT    4 
         6: 0000000000400280     0 SECTION LOCAL  DEFAULT    5 
         7: 00000000004002e0     0 SECTION LOCAL  DEFAULT    6 
         8: 0000000000400320     0 SECTION LOCAL  DEFAULT    7 
         9: 0000000000400328     0 SECTION LOCAL  DEFAULT    8 
        10: 0000000000400348     0 SECTION LOCAL  DEFAULT    9 
        11: 0000000000400360     0 SECTION LOCAL  DEFAULT   10 
        12: 0000000000400390     0 SECTION LOCAL  DEFAULT   11 
        13: 00000000004003a8     0 SECTION LOCAL  DEFAULT   12 
        14: 00000000004003e0     0 SECTION LOCAL  DEFAULT   13 
        15: 0000000000400608     0 SECTION LOCAL  DEFAULT   14 
        16: 0000000000400618     0 SECTION LOCAL  DEFAULT   15 
        17: 0000000000400634     0 SECTION LOCAL  DEFAULT   16 
        18: 0000000000400660     0 SECTION LOCAL  DEFAULT   17 
        19: 0000000000600700     0 SECTION LOCAL  DEFAULT   18 
        20: 0000000000600710     0 SECTION LOCAL  DEFAULT   19 
        21: 0000000000600720     0 SECTION LOCAL  DEFAULT   20 
        22: 0000000000600728     0 SECTION LOCAL  DEFAULT   21 
        23: 00000000006008b8     0 SECTION LOCAL  DEFAULT   22 
        24: 00000000006008c0     0 SECTION LOCAL  DEFAULT   23 
        25: 00000000006008e8     0 SECTION LOCAL  DEFAULT   24 
        26: 00000000006008f8     0 SECTION LOCAL  DEFAULT   25 
        27: 0000000000000000     0 SECTION LOCAL  DEFAULT   26 
    
  4. 查看檔案大小,從 8195 bytes 降至 5196 bytes。
    [dywang@dyH gcc]$ ll stripex1
    -rwxrwxr-x. 1 dywang dywang 5196 Sep  1 09:03 stripex1
    



2015-01-16