Linux 中的依赖解析

发布于 2024-07-26 09:00:05 字数 182 浏览 2 评论 0原文

在 Windows 下,我使用了一个名为 Dependency Walker 的程序来检查应用程序使用的库。 我想知道如何在 Linux 上实现标准二进制文件:

ELF 32 位 LSB 可执行文件、Intel 80386、版本 1 (SYSV)、动态链接(使用共享库)、GNU/Linux 2.6.0、剥离

谢谢。

Under Windows, I have used a program called Dependency Walker to examine the libraries the application uses. I was wondering how I can achieve this on Linux for a standard binary:

ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.0, stripped

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

缱倦旧时光 2024-08-02 09:00:05

尝试:

ldd executable

例如:

[me@somebox ~]$ ldd /bin/ls
        linux-gate.so.1 =>  (0xb7f57000)
        librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7f4c000)
        libselinux.so.1 => /lib/libselinux.so.1 (0xb7f32000)
        libacl.so.1 => /lib/libacl.so.1 (0xb7f2b000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ddc000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7dc4000)
        /lib/ld-linux.so.2 (0xb7f58000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7dc0000)
        libattr.so.1 => /lib/libattr.so.1 (0xb7dbb000)
[me@somebox ~]$ 

请注意,这只会报告共享库。 如果您需要找出在编译时链接了哪些静态库,那就有点棘手了,特别是当您的可执行文件被“剥离”(没有调试符号)时。

Try:

ldd executable

For example:

[me@somebox ~]$ ldd /bin/ls
        linux-gate.so.1 =>  (0xb7f57000)
        librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7f4c000)
        libselinux.so.1 => /lib/libselinux.so.1 (0xb7f32000)
        libacl.so.1 => /lib/libacl.so.1 (0xb7f2b000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7ddc000)
        libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7dc4000)
        /lib/ld-linux.so.2 (0xb7f58000)
        libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7dc0000)
        libattr.so.1 => /lib/libattr.so.1 (0xb7dbb000)
[me@somebox ~]$ 

Note that this will only report shared libraries. If you need to find out what static libraries were linked in at compile time, that's a bit trickier, especially seeing as your executable is 'stripped' (no debugging symbols).

西瑶 2024-08-02 09:00:05

使用ldd

ldd /bin/sh

Use ldd

ldd /bin/sh
挥剑断情 2024-08-02 09:00:05

如果您想要比迭代调用 ldd 更原始的东西,并且更像 MSVC 依赖,您应该尝试 Visual-ldd 。 它已经 4 年没有更新了,但考虑到 ELF 格式没有改变,它应该仍然可以工作。 它仍然不会向您显示这些库中的各个符号 - 为此您需要类似 nm 的东西,不幸的是,我不知道有任何 GUI 包装器。

If you want something a little less raw than iteratively calling ldd and somewhat more like MSVC depends, you should try Visual-ldd. It hasn't been updated in 4 years, but it should still work given that the ELF format hasn't changed. It still won't show you individual symbols inside those libraries - for that you'll need something like nm, and I don't know of any GUI wrapper for that, unfortunately.

昔日梦未散 2024-08-02 09:00:05

使用 ldd。 它将显示二进制文件所需的动态库。

请注意,库本身可能又需要更多库。 要获得这些,您可以在通过对二进制文件运行 ldd 获得的库上运行 ldd。

Use ldd. It will show the dynamic libraries the binary needs.

Note that the libraries themselves may in turn need more libraries. To get these, you can run ldd on the libraries you got from running ldd on the binary.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文