如何显示 *.so 文件的符号列表

nm libxyz.so | grep abc

objdump -t libxyz.so | grep abc


nm: list symbols: object files, archive library and shared library

The command "nm" lists symbols contained in object files:

nm file.o

The command "nm" lists symbols contained in the archive library:

Object symbols in static archive libraries are categorized using the source and object file hierachy of the library:
nm /usr/lib/x86_64-linux-gnu/libjpeg.a
jlibinit.o:
0000000000000000 B auxv
                 U fclose
                 U fopen
                 U fread
                 U getpagesize
0000000000000000 T libjpeg_general_init
                 U malloc
                 U perror

jcapimin.o:
                 U jinit_marker_writer
                 U jinit_memory_mgr
0000000000000000 T jpeg_CreateCompress
                 U jpeg_abort
0000000000000240 T jpeg_abort_compress
                 U jpeg_destroy
0000000000000230 T jpeg_destroy_compress
00000000000002a0 T jpeg_finish_compress
                 U jpeg_natural_order
...
...
      

The command "nm" lists symbols contained in the object file or shared library.

Use the command nm -D libctest.so.1.0
(or nm --dynamic libctest.so.1.0)

0000000000100988 A __bss_start
000000000000068c T ctest1
00000000000006a0 T ctest2
                 w __cxa_finalize
00000000001007b0 A _DYNAMIC
0000000000100988 A _edata
0000000000100990 A _end
00000000000006f8 T _fini
0000000000100958 A _GLOBAL_OFFSET_TABLE_
                 w __gmon_start__
00000000000005b0 T _init
                 w _Jv_RegisterClasses
      
Also see: Man page for nm
Symbol Type Description
A The symbol's value is absolute, and will not be changed by further linking.
B Un-initialized data section
D Initialized data section
T Normal code section
U Undefined symbol used but not defined. Dependency on another library.
W Doubly defined symbol. If found, allow definition in another library to resolve dependency.

Also see: objdump man page

参考资料:

http://www.yolinux.com/TUTORIALS/LibraryArchives-StaticAndDynamic.html

你可能感兴趣的:(GNU/Linux)