如何查找外部函数定义
我正在编译一个大项目。该项目使用共享库,尤其是 lapack 的。
我想确定,对于给定的函数,系统在哪个共享库中找到它。
这里是 nm 输出:
$ nm -DC ~/bin/app | grep potrf
U dpotrf_
正如预期的那样,dpotrf_ 是未定义的。
这是 objdump 的结果:
$ objdump -TR ~bin/app | grep potrf
0000000000925428 R_X86_64_JUMP_SLOT dpotrf_
所以 objdump 找到了一些东西!是否有任何选项可以显示它在哪个共享库中找到它?或者另一个程序可以做到这一点?
I am compiling a big project. This project is using shared libraries, especially lapack ones.
I would want to be sure, for a given function, in which shared library the system finds it.
Here the nm output:
$ nm -DC ~/bin/app | grep potrf
U dpotrf_
As expected, dpotrf_ is undifined.
Here the result with objdump:
$ objdump -TR ~bin/app | grep potrf
0000000000925428 R_X86_64_JUMP_SLOT dpotrf_
So objdump find something! Is there any option to show in which shared lib it finds it? Or another program to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ldd 绝对是寻找候选库的起点。这是我在 .bashrc 中用于此类目的的内容(不美观,但符合我的目的)。
基本上,我对子目录中的所有库(.a、.so)执行 nm 操作。如果 nm 生成搜索符号的输出,我会打印 nm 中的库名称和相关行。然后,您的最后一步是搜索以“T”开头的行,因为这些行是将符号定义为程序代码(文本)的行。
ldd is definitely a starting point to find the candidate libraries. Here's what I have in my .bashrc for such purposes (not beautiful, but serves my purposes).
Basically, I do nm on all libraries (.a, .so) in a subdirectory. If nm produces an output for the searched symbol, I print the library name and the relevant lines from nm. Your last step would then be to search for lines starting with "T" as these are the ones defining your symbol as program code (text).