有没有一种方法来检查哪些库使用正在运行的进程?
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'更多推荐
如何检查什么共享库在运行时加载?
发布评论