C语言 命令行查看内容 Shared Object Module(lib*.so)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3656077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 06:23:44  来源:igfitidea点击:

Command Line to see the contents Shared Object Module(lib*.so)

clinuxshared-objectsdll

提问by Pavitar

What is the command line to see the contents of a Shared Object module (lib*.so)?

查看共享对象模块 (lib*.so) 内容的命令行是什么?

Like how we use:

就像我们如何使用:

ar -t lib*.a

for archives(lib*.a) and it displays all the object files in the library.

for archives(lib*.a) 并显示库中的所有目标文件。

EDIT1

编辑1

Example

例子

ar -t lib*.a

gives me a display:

给我一个显示:

asset.o

资产.o

sldep.o

sldep.o

回答by shodanex

use nm -D --defined-only libname.soto get the symbol names from your dynamic library.
The --defined-onlyswitch shows you only the symbol that are defined in these files, and not references to external functions.

用于nm -D --defined-only libname.so从动态库中获取符号名称。
--defined-only开关仅显示这些文件中定义的符号,而不显示对外部函数的引用。

An alternative is to use objdump, and catch only the symbols in the text section :

另一种方法是使用 objdump,并仅捕获文本部分中的符号:

objdump -T /usr/lib/libjpeg.so | grep text
...
0001b5c0 g    DF .text  00000016  Base        jdiv_round_up
00003730 g    DF .text  00000417  Base        jpeg_set_colorspace
0000cda0 g    DF .text  000002de  Base        jpeg_consume_input
00002b30 g    DF .text  00000023  Base        jpeg_abort_compress
00003b50 g    DF .text  000000b6  Base        jpeg_default_colorspace
00002810 g    DF .text  00000067  Base        jpeg_suppress_tables
00004110 g    DF .text  00000130  Base        jpeg_add_quant_table
000100c0 g    DF .text  0000011f  Base        jpeg_save_markers
...

回答by Hyman Kelly

I think nm -Dis what you're looking for.

我想nm -D这就是你要找的。

$ nm -D /usr/lib/libpng.so
...
00000000000058f0 T png_reset_zstream
000000000000d420 T png_save_int_32
000000000000d450 T png_save_uint_16
000000000000d3f0 T png_save_uint_32
0000000000007810 T png_set_IHDR
0000000000007500 T png_set_PLTE
000000000000ce20 T png_set_add_alpha
0000000000006670 T png_set_asm_flags
0000000000006970 T png_set_bKGD
000000000001a740 T png_set_background
...

回答by herzrasen

The nm -Dcommand lists the dynamic symbols of your shared library, which seems to be exactly what you want.

nm -D命令列出了您共享库的动态符号,这似乎正是您想要的。