ldd和objdump有什么区别? [英] What is the difference between ldd and objdump?

查看:297
本文介绍了ldd和objdump有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行这两个命令,并且得到不同的输出:

I am running these two commands, and I'm getting different output:

$ ldd `which ls`
    linux-gate.so.1 =>  (0x00db3000)
    libselinux.so.1 => /lib/i386-linux-gnu/libselinux.so.1 (0x00ba2000)
    librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0x007bf000)
    libacl.so.1 => /lib/i386-linux-gnu/libacl.so.1 (0x004ce000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00110000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x00398000)
    /lib/ld-linux.so.2 (0x00dea000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x00a83000)
    libattr.so.1 => /lib/i386-linux-gnu/libattr.so.1 (0x00d3d000)

然后

objdump -x `which ls` | grep NEEDED
  NEEDED               libselinux.so.1
  NEEDED               librt.so.1
  NEEDED               libacl.so.1
  NEEDED               libc.so.6

这是怎么回事?我以为他们都给了图书馆依赖?我关心的原因是我怀疑ldd是正确的,但是我正在ARM上的linux上工作,在这里我听不出什么错话...

What's up with that? I thought they both gave the library dependencies? The reason I care is that I suspect ldd is the correct one, but I'm working on linux on ARM, where there is no ldd from what I can tell...

推荐答案

您可以看到输出的差异.

You can see the difference in the output.

objdump只是将对象本身列出的内容转储为包含未解析符号的库.

objdump is simply dumping what the object itself lists as libraries containing unresolved symbols.

ldd列出了ld.so将实际加载的库.并且它向后跟随该图,因此您可以看到那些库将加载的内容.尽管不在objdump输出中,但libpthread.so.0如何在ldd输出中结束.

ldd is listing which libraries ld.so would actually load. And it follows the graph backward, so that you can see what would be loaded by those libraries. Which is how libpthread.so.0 winds up in the ldd output, despite not being in the objdump output.

因此,ldd会给出运行时真正需要提供的功能的更好得多的画面.但是,在解决编译/链接时问题时,objdump非常有用.

So ldd is going to give a much, much better picture of what really needs to be available at runtime. But, when resolving compile/link-time problems, objdump is pretty helpful.

这篇关于ldd和objdump有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆