【问题标题】:How to determine which library a symbol is defined in (linux)如何确定符号在哪个库中定义(linux)
【发布时间】:2019-07-14 15:22:25
【问题描述】:

我有一个小型开源程序,它编译为 apache 的共享模块,但是当 apache 尝试加载它时,它拒绝加载,抱怨:“未定义的符号:ap_log_rerror”。 在共享库上运行ldd 会生成一个包含大约十几个依赖项的列表,所以这些是我知道未定义函数的那些。我该如何寻找提供此功能的库? 我的问题不是如何列出符号——我知道如何用 nm 做到这一点。我的问题是在哪里可以找到包含我想要的符号的文件?是否有任何有效、简单的方法来识别正确的文件?

更新:我通过重新编译我的程序来解决这个问题。所以它现在加载,尽管我的核心问题仍未得到解答。

【问题讨论】:

标签: linux compilation shared-libraries


【解决方案1】:

我可能知道你的意思。在 Windows 上,我们可以使用“dumpbin /ALL [executable]”来获取所有可用信息(参见 dumpbin),其中包括定义可执行文件符号的位置的信息(参见下文),但我没有找到它Linux 中的等效项。

ksh-3.2$ dumpbin /ALL test.exe > all.sym
ksh-3.2$ sed -n "3155,3172p" all.sym
    api-ms-win-crt-heap-l1-1-0.dll
             14000E1D8 Import Address Table
             14000E730 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                           8 _callnewh
                          19 malloc
                          18 free
                          16 _set_new_mode

    api-ms-win-crt-math-l1-1-0.dll
             14000E2B0 Import Address Table
             14000E808 Import Name Table
                     0 time date stamp
                     0 Index of first forwarder reference

                           9 __setusermatherr

【讨论】:

    猜你喜欢
    • 2017-12-17
    • 2019-07-29
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多