如何检查什么共享库在运行时加载?

编程入门 行业动态 更新时间:2024-10-10 10:29:55
本文介绍了如何检查什么共享库在运行时加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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'

更多推荐

如何检查什么共享库在运行时加载?

本文发布于:2023-11-30 21:41:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1651557.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!