最終更新:2019-10-06 (日) 12:48:42 (11d)  

Linux/シンボル はてなブックマークを見る
Top / Linux / シンボル

strip

ld

  • ld -s? (--strip-all)Omit all symbol information from the output file.
    ld -S? (--strip-debug)Omit debugger symbol information (but not all symbols) from the output file.

nm

  • nm -A?,nm-o? : Print name of the input file before every symbol
  • nm -a? : Display debugger-only symbols
  • nm -D? : Display dynamic symbols instead of normal symbols
  • nm -C? : Decode low-level symbol names into user-level names
  • nm -g? : Display only external symbols

objdump

  • objdump -t : Display the contents of the symbol table(s)
  • objdump -T : Display the contents of the dynamic symbol table

readelf

  • readelf -s : Display the symbol table
    $ readelf -s a.out 
    
    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 puts@GLIBC_2.2.5 (2)
         2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.2.5 (2)
         3: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
    
    Symbol table '.symtab' contains 69 entries:
       Num:    Value          Size Type    Bind   Vis      Ndx Name
         0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
         1: 0000000000400238     0 SECTION LOCAL  DEFAULT    1 
         2: 0000000000400254     0 SECTION LOCAL  DEFAULT    2 
         3: 0000000000400274     0 SECTION LOCAL  DEFAULT    3 
         4: 0000000000400298     0 SECTION LOCAL  DEFAULT    4 
         5: 00000000004002b8     0 SECTION LOCAL  DEFAULT    5 
         6: 0000000000400318     0 SECTION LOCAL  DEFAULT    6 
         7: 0000000000400356     0 SECTION LOCAL  DEFAULT    7 
         8: 0000000000400360     0 SECTION LOCAL  DEFAULT    8 
         9: 0000000000400380     0 SECTION LOCAL  DEFAULT    9 
        10: 0000000000400398     0 SECTION LOCAL  DEFAULT   10 
        11: 00000000004003c8     0 SECTION LOCAL  DEFAULT   11 
        12: 00000000004003f0     0 SECTION LOCAL  DEFAULT   12 
        13: 0000000000400420     0 SECTION LOCAL  DEFAULT   13 
        14: 0000000000400430     0 SECTION LOCAL  DEFAULT   14 
        15: 00000000004005f4     0 SECTION LOCAL  DEFAULT   15 
        16: 0000000000400600     0 SECTION LOCAL  DEFAULT   16 
        17: 0000000000400630     0 SECTION LOCAL  DEFAULT   17 
        18: 0000000000400678     0 SECTION LOCAL  DEFAULT   18 
        19: 0000000000600e10     0 SECTION LOCAL  DEFAULT   19 
        20: 0000000000600e18     0 SECTION LOCAL  DEFAULT   20 
        21: 0000000000600e20     0 SECTION LOCAL  DEFAULT   21 
        22: 0000000000600e28     0 SECTION LOCAL  DEFAULT   22 
        23: 0000000000600ff8     0 SECTION LOCAL  DEFAULT   23 
        24: 0000000000601000     0 SECTION LOCAL  DEFAULT   24 
        25: 0000000000601028     0 SECTION LOCAL  DEFAULT   25 
        26: 0000000000601038     0 SECTION LOCAL  DEFAULT   26 
        27: 0000000000000000     0 SECTION LOCAL  DEFAULT   27 
        28: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
        29: 0000000000600e20     0 OBJECT  LOCAL  DEFAULT   21 __JCR_LIST__
        30: 0000000000400460     0 FUNC    LOCAL  DEFAULT   14 deregister_tm_clones
        31: 00000000004004a0     0 FUNC    LOCAL  DEFAULT   14 register_tm_clones
        32: 00000000004004e0     0 FUNC    LOCAL  DEFAULT   14 __do_global_dtors_aux
        33: 0000000000601038     1 OBJECT  LOCAL  DEFAULT   26 completed.7594
        34: 0000000000600e18     0 OBJECT  LOCAL  DEFAULT   20 __do_global_dtors_aux_fin
        35: 0000000000400500     0 FUNC    LOCAL  DEFAULT   14 frame_dummy
        36: 0000000000600e10     0 OBJECT  LOCAL  DEFAULT   19 __frame_dummy_init_array_
        37: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS hello.c
        38: 0000000000400537    17 FUNC    LOCAL  DEFAULT   14 statichoge
        39: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS crtstuff.c
        40: 00000000004007a8     0 OBJECT  LOCAL  DEFAULT   18 __FRAME_END__
        41: 0000000000600e20     0 OBJECT  LOCAL  DEFAULT   21 __JCR_END__
        42: 0000000000000000     0 FILE    LOCAL  DEFAULT  ABS 
        43: 0000000000600e18     0 NOTYPE  LOCAL  DEFAULT   19 __init_array_end
        44: 0000000000600e28     0 OBJECT  LOCAL  DEFAULT   22 _DYNAMIC
        45: 0000000000600e10     0 NOTYPE  LOCAL  DEFAULT   19 __init_array_start
        46: 0000000000400630     0 NOTYPE  LOCAL  DEFAULT   17 __GNU_EH_FRAME_HDR
        47: 0000000000601000     0 OBJECT  LOCAL  DEFAULT   24 _GLOBAL_OFFSET_TABLE_
        48: 00000000004005f0     2 FUNC    GLOBAL DEFAULT   14 __libc_csu_fini
        49: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_deregisterTMCloneTab
        50: 0000000000601028     0 NOTYPE  WEAK   DEFAULT   25 data_start
        51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND puts@@GLIBC_2.2.5
        52: 0000000000601038     0 NOTYPE  GLOBAL DEFAULT   25 _edata
        53: 00000000004005f4     0 FUNC    GLOBAL DEFAULT   15 _fini
        54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __libc_start_main@@GLIBC_
        55: 0000000000601028     0 NOTYPE  GLOBAL DEFAULT   25 __data_start
        56: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
        57: 0000000000601030     0 OBJECT  GLOBAL HIDDEN    25 __dso_handle
        58: 0000000000400600     4 OBJECT  GLOBAL DEFAULT   16 _IO_stdin_used
        59: 0000000000400580   101 FUNC    GLOBAL DEFAULT   14 __libc_csu_init
        60: 0000000000601040     0 NOTYPE  GLOBAL DEFAULT   26 _end
        61: 0000000000400430    42 FUNC    GLOBAL DEFAULT   14 _start
        62: 0000000000601038     0 NOTYPE  GLOBAL DEFAULT   26 __bss_start
        63: 0000000000400548    52 FUNC    GLOBAL DEFAULT   14 main
        64: 0000000000400526    17 FUNC    GLOBAL DEFAULT   14 hoge
        65: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _Jv_RegisterClasses
        66: 0000000000601038     0 OBJECT  GLOBAL HIDDEN    25 __TMC_END__
        67: 0000000000000000     0 NOTYPE  WEAK   DEFAULT  UND _ITM_registerTMCloneTable
        68: 00000000004003c8     0 FUNC    GLOBAL DEFAULT   11 _init