0
0

[Linux]オブジェクトに含まれるシンボルの一覧表示

Posted at

ライブラリや実行ファイルに含まれるシンボル(関数など)の一覧を表示する

nm <ライブラリ名>

主に、dlopen/dlsym関数を用いた動的ロードを行う場合に、dlsym関数で指定のシンボル(関数)が見つからない場合にnmコマンドで内容を確認する目的で使う。

nm <ライブラリ名> | grep <シンボル名> など。

例えば、ある実行ファイルに対してnmを実行すると以下の実行結果となる。

# nm main
                 U A
                 U B
0000000000600e08 d _DYNAMIC
0000000000601000 d _GLOBAL_OFFSET_TABLE_
0000000000400740 R _IO_stdin_used
0000000000400888 r __FRAME_END__
0000000000400760 r __GNU_EH_FRAME_HDR
0000000000600e00 d __JCR_END__
0000000000600e00 d __JCR_LIST__
0000000000601048 D __TMC_END__
0000000000601044 B __bss_start
0000000000601040 D __data_start
0000000000400640 t __do_global_dtors_aux
0000000000600df8 t __do_global_dtors_aux_fini_array_entry
0000000000400748 R __dso_handle
0000000000600df0 t __frame_dummy_init_array_entry
                 w __gmon_start__
0000000000600df8 t __init_array_end
0000000000600df0 t __init_array_start
0000000000400730 T __libc_csu_fini
00000000004006c0 T __libc_csu_init
                 U __libc_start_main@@GLIBC_2.2.5
0000000000601044 D _edata
0000000000601048 B _end
0000000000400734 T _fini
0000000000400518 T _init
00000000004005a0 T _start
0000000000601044 b completed.6355
0000000000601040 W data_start
00000000004005d0 t deregister_tm_clones
0000000000400660 t frame_dummy
000000000040068d T main
                 U puts@@GLIBC_2.2.5
0000000000400600 t register_tm_clones
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0