如何检查什么共享库在运行时加载? [英] How to check what shared library is loaded at run time?

查看:115
本文介绍了如何检查什么共享库在运行时加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来检查哪些库使用正在运行的进程?

Is there a way to check which libraries is a running process using?

要更具体,如果程序使用的dlopen 加载某些共享库,然后readelf或LDD不要证明这一点。
是否有可能在所有从一个正在运行的进程的信息?如果是的话,怎么样?

To be more specific, if a program loads some shared libraries using dlopen, then readelf or ldd is not going to show it. Is it possible at all to get that information from a running process? If yes, how?

推荐答案

其他人都在正确的轨道上。这里有几个方面。

Other people are on the right track. Here are a couple ways.

cat /proc/NNNN/maps | awk '{print $6}' | grep '\.so' | sort | uniq

或者,用strace的:

Or, with strace:

strace CMD.... 2>&1 | grep '^open(".*\.so"'

这两个假设共享库拥有。所以在其路径的地方,但你可以修改。第一个给出了相当pretty输出只是一个库列表,每行一个。第二个将继续,因为他们拉开上市库,所以这是很好的。

Both of these assume that shared libraries have ".so" somewhere in their paths, but you can modify that. The first one gives fairly pretty output as just a list of libraries, one per line. The second one will keep on listing libraries as they are opened, so that's nice.

编辑:当然, lsof的 ...

lsof -p NNNN | awk '{print $9}' | grep '\.so'

这篇关于如何检查什么共享库在运行时加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆