dpkg查看软件包和共享库信息

0x01 查看.so文件是由哪个软件包提供的

dpkg -S /usr/lib/libz.so

输出如下:

zlib1g-dev: /usr/lib/libz.so

0x02 查看软件包的详细信息

apt-cache show zlib1g-dev

输出如下:

Description: compression library - development zlib is a library implementing the deflate compression method found in gzip and PKZIP. This package includes the development support files.
Bugs: mailto:[email protected]
Origin: Ubuntu

0x03 查看软件包所安装文件的位置

dpkg -L zlib1g-dev

输出如下:

/usr
/usr/lib
/usr/lib/libz.a
/usr/include
/usr/include/zlib.h
/usr/include/zconf.h
/usr/share
/usr/share/doc
/usr/share/doc/zlib1g-dev
/usr/share/doc/zlib1g-dev/examples
/usr/share/doc/zlib1g-dev/examples/example.c.gz
/usr/share/doc/zlib1g-dev/examples/contrib.tar.gz
/usr/share/doc/zlib1g-dev/examples/minigzip.c.gz
/usr/share/doc/zlib1g-dev/changelog.gz
/usr/share/doc/zlib1g-dev/FAQ.gz
/usr/share/doc/zlib1g-dev/README.gz
/usr/share/doc/zlib1g-dev/copyright
/usr/share/doc/zlib1g-dev/changelog.Debian.gz
/usr/share/doc/zlib1g-dev/algorithm.txt.gz
/usr/share/man
/usr/share/man/man3
/usr/share/man/man3/zlib.3.gz
/usr/lib/libz.so

可以看出,zlib1g-dev软件包提供了库文件libz.a和libz.so,还提供了头文件zlib.h和zconf.h
另外还在/usr/share/doc/zlib1g-dev目录下提供关于此库文件使用方法的文档,甚至有例子在/usr/share/doc/zlib1g-dev/examples目录下,比如example.c.gz就是一个完整的gzip压缩/解压缩例子。

0x04 查看.so所提供的接口

nm -D /usr/lib/libz.so

输出如下:

00001810 T adler32
00001ad0 T adler32_combine
00013b30 A __bss_start
U clearerr
...

可以用命令过滤一下:nm -D /usr/lib/libz.so | grep gz
输出如下:

00002570 T gzclearerr
00002b50 T gzclose
00002550 T gzdirect
00003ba0 T gzdopen
00002520 T gzeof
000025b0 T gzerror
00002d40 T gzflush
000046c0 T gzgetc
00004640 T gzgets
00003c20 T gzopen
00002a10 T gzprintf
00002900 T gzputc
000028c0 T gzputs
00003c40 T gzread
00002950 T gzrewind
00004410 T gzseek
00002ab0 T gzsetparams
00004600 T gztell
000024d0 T gzungetc
000027d0 T gzwrite

你可能感兴趣的:(linux)