如何跟踪应用程序正在动态加载哪些库?
我有一个应用程序(我没有源代码)。
我知道它的设计目的是根据命令行参数动态加载共享库。
我知道它应该加载哪个库,并且我已将 LD_LIBRARY_PATH 设置到适当的目录。
该应用程序在一台服务器上运行没有任何问题,但在另一台服务器上则无法运行。
我试图找出原因,如果我可以确认脚本正在寻找我认为是的库,并且如果我可以跟踪它正在寻找的位置,那将会很有帮助。
有什么工具可以帮助我吗?我一直在谷歌搜索,但我找到的大部分信息都是关于 ldd 的,它实际上只告诉您有关静态链接库的信息。
这是在 Linux 环境中,应用程序和库都是用 C 编写的,
谢谢
I have an application (for which I do not have the source code).
I know that it is designed to dynamically load a shared library, depending on the command line parameters.
I know which library it should be loading and I've set up LD_LIBRARY_PATH to the appropriate directory.
The application works on one server without any problems, but does not work on another.
I'm trying to figure out why and it would be helpful if I could confirm that the script is looking for the library that I think it is and if I could track where it is looking.
Are there any tools that could help me? I've been googling, but most of the information I'm finding is about ldd
which really only tells you about statically linked libraries.
This is in a Linux environment and the application and library are both written in C
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
strace
。您将看到正在搜索的库等,这将帮助您弄清楚发生了什么。Use
strace
. You will see the libraries being searched etc., which will help you figure out what is happening.由于每个共享库都内存映射到进程的地址空间,因此您还可以检查 /proc/[PID]/maps 文件。
As every shared library is memory-mapped into the process's address space, you can also inspect the /proc/[PID]/maps file.