next up previous contents
Next: preserve-dates Up: strip 工具 Previous: keep-symbol   Contents

strip-symbol

  1. 重新編譯程式。
    [dywang@dyH gcc]$ gcc -g -o stripex1 stripex1.c
    [dywang@dyH gcc]$ ll stripex1
    -rwxrwxr-x. 1 dywang dywang 8195 Sep  1 09:08 stripex1
    
  2. 移除符號項目時只保留某些符號資訊
    [dywang@dyH gcc]$ strip -Nstripex1.c stripex1
    
  3. 修整後的執行檔,符號項目從 75 項變成 74 項,已經不包含名字為 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 74 entries:
       Num:    Value          Size Type    Bind   Vis      Ndx Name
         0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
         1: 0000000000400200     0 SECTION LOCAL  DEFAULT    1 
         2: 000000000040021c     0 SECTION LOCAL  DEFAULT    2 
         3: 000000000040023c     0 SECTION LOCAL  DEFAULT    3 
         4: 0000000000400260     0 SECTION LOCAL  DEFAULT    4 
         5: 0000000000400280     0 SECTION LOCAL  DEFAULT    5 
         6: 00000000004002e0     0 SECTION LOCAL  DEFAULT    6 
         7: 0000000000400320     0 SECTION LOCAL  DEFAULT    7 
         8: 0000000000400328     0 SECTION LOCAL  DEFAULT    8 
         9: 0000000000400348     0 SECTION LOCAL  DEFAULT    9 
        10: 0000000000400360     0 SECTION LOCAL  DEFAULT   10 
        11: 0000000000400390     0 SECTION LOCAL  DEFAULT   11 
        12: 00000000004003a8     0 SECTION LOCAL  DEFAULT   12 
        13: 00000000004003e0     0 SECTION LOCAL  DEFAULT   13 
        14: 0000000000400608     0 SECTION LOCAL  DEFAULT   14 
        15: 0000000000400618     0 SECTION LOCAL  DEFAULT   15 
        16: 0000000000400634     0 SECTION LOCAL  DEFAULT   16 
        17: 0000000000400660     0 SECTION LOCAL  DEFAULT   17 
        18: 0000000000600700     0 SECTION LOCAL  DEFAULT   18 
        19: 0000000000600710     0 SECTION LOCAL  DEFAULT   19 
        20: 0000000000600720     0 SECTION LOCAL  DEFAULT   20 
        21: 0000000000600728     0 SECTION LOCAL  DEFAULT   21 
        22: 00000000006008b8     0 SECTION LOCAL  DEFAULT   22 
        23: 00000000006008c0     0 SECTION LOCAL  DEFAULT   23 
        24: 00000000006008e8     0 SECTION LOCAL  DEFAULT   24 
        25: 00000000006008f8     0 SECTION LOCAL  DEFAULT   25 
        26: 0000000000000000     0 SECTION LOCAL  DEFAULT   26 
        27: 0000000000000000     0 SECTION LOCAL  DEFAULT   27 
        28: 0000000000000000     0 SECTION LOCAL  DEFAULT   28 
        29: 0000000000000000     0 SECTION LOCAL  DEFAULT   29 
        30: 0000000000000000     0 SECTION LOCAL  DEFAULT   30 
        31: 0000000000000000     0 SECTION LOCAL  DEFAULT   31 
        32: 0000000000000000     0 SECTION LOCAL  DEFAULT   32 
        33: 0000000000000000     0 SECTION LOCAL  DEFAULT   33 
        34: 000000000040040c     0 FUNC    LOCAL  DEFAULT   13 call_gmon_start
        35: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
        36: 0000000000600700     0 OBJECT  LOCAL  DEFAULT   18 __CTOR_LIST__
        37: 0000000000600710     0 OBJECT  LOCAL  DEFAULT   19 __DTOR_LIST__
        38: 0000000000600720     0 OBJECT  LOCAL  DEFAULT   20 __JCR_LIST__
        39: 0000000000400430     0 FUNC    LOCAL  DEFAULT   13 __do_global_dtors_aux
        40: 00000000006008f8     1 OBJECT  LOCAL  DEFAULT   25 completed.6349
        41: 0000000000600900     8 OBJECT  LOCAL  DEFAULT   25 dtor_idx.6351
        42: 00000000004004a0     0 FUNC    LOCAL  DEFAULT   13 frame_dummy
        43: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
        44: 0000000000600708     0 OBJECT  LOCAL  DEFAULT   18 __CTOR_END__
        45: 00000000004006f8     0 OBJECT  LOCAL  DEFAULT   17 __FRAME_END__
        46: 0000000000600720     0 OBJECT  LOCAL  DEFAULT   20 __JCR_END__
        47: 00000000004005d0     0 FUNC    LOCAL  DEFAULT   13 __do_global_ctors_aux
        48: 00000000006008ec     4 OBJECT  LOCAL  DEFAULT   24 i
        49: 0000000000600908     4 OBJECT  LOCAL  DEFAULT   25 local.2052
        50: 00000000006008c0     0 OBJECT  LOCAL  DEFAULT   23 _GLOBAL_OFFSET_TABLE_
        51: 00000000006006fc     0 NOTYPE  LOCAL  DEFAULT   18 __init_array_end
        52: 00000000006006fc     0 NOTYPE  LOCAL  DEFAULT   18 __init_array_start
        53: 0000000000600728     0 OBJECT  LOCAL  DEFAULT   21 _DYNAMIC
        54: 00000000006008e8     0 NOTYPE  WEAK   DEFAULT   24 data_start
        55: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND printf@@GLIBC_2.2.5
        56: 0000000000400530     2 FUNC    GLOBAL DEFAULT   13 __libc_csu_fini
        57: 00000000004003e0     0 FUNC    GLOBAL DEFAULT   13 _start
        58: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
        59: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
        60: 0000000000400608     0 FUNC    GLOBAL DEFAULT   14 _fini
        61: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@@GLIBC_
        62: 00000000006008f0     4 OBJECT  GLOBAL DEFAULT   24 global
        63: 0000000000400618     4 OBJECT  GLOBAL DEFAULT   15 _IO_stdin_used
        64: 00000000006008e8     0 NOTYPE  GLOBAL DEFAULT   24 __data_start
        65: 0000000000400620     0 OBJECT  GLOBAL HIDDEN    15 __dso_handle
        66: 0000000000600718     0 OBJECT  GLOBAL HIDDEN    19 __DTOR_END__
        67: 0000000000400540   137 FUNC    GLOBAL DEFAULT   13 __libc_csu_init
        68: 00000000006008f4     0 NOTYPE  GLOBAL DEFAULT  ABS __bss_start
        69: 0000000000600910     0 NOTYPE  GLOBAL DEFAULT  ABS _end
        70: 00000000006008f4     0 NOTYPE  GLOBAL DEFAULT  ABS _edata
        71: 00000000004004c4    27 FUNC    GLOBAL DEFAULT   13 inc_func
        72: 00000000004004df    67 FUNC    GLOBAL DEFAULT   13 main
        73: 0000000000400390     0 FUNC    GLOBAL DEFAULT   11 _init
    
  4. 查看檔案大小,從 8195 bytes 降至 8160 bytes。
    [dywang@dyH gcc]$ ll stripex1
    -rwxrwxr-x. 1 dywang dywang 8160 Sep  1 09:10 stripex1
    



2015-01-16