ldd输出不同。相同的二进制不同的发行版

时间:2012-10-03 18:03:11

标签: ubuntu centos shared-libraries ldd

当运行ldd实用程序来查找httpd的共享库时,我发现了以下无法解释的场景:


在我的Ubuntu框中:

leon@lwaldman-linux:~/Uol/Lxc/py_utils/Container_Builder/_builds/usr/sbin$ ldd  httpd 
    linux-gate.so.1 =>  (0xf77b2000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7712000)
    libpcre.so.0 => not found
    libselinux.so.1 => /lib/i386-linux-gnu/libselinux.so.1 (0xf76f2000)
    libaprutil-1.so.0 => not found
    libcrypt.so.1 => /lib/i386-linux-gnu/libcrypt.so.1 (0xf76c1000)
    libexpat.so.1 => /lib/i386-linux-gnu/libexpat.so.1 (0xf7697000)
    libdb-4.7.so => not found
    libapr-1.so.0 => not found
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xf767b000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf74d6000)
    /lib/ld-linux.so.2 (0xf77b3000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf74d1000)

CentOS框上:

[root@localhost sbin]# ldd httpd 
linux-gate.so.1 =>  (0x008b6000)
libm.so.6 => /lib/libm.so.6 (0x0036f000)
libpcre.so.0 => /lib/libpcre.so.0 (0x00835000)
libselinux.so.1 => /lib/libselinux.so.1 (0x0021f000)
libaprutil-1.so.0 => /usr/lib/libaprutil-1.so.0 (0x00dfa000)
libcrypt.so.1 => /lib/libcrypt.so.1 (0x003de000)
libexpat.so.1 => /lib/libexpat.so.1 (0x00695000)
libdb-4.7.so => /lib/libdb-4.7.so (0x0040e000)
libapr-1.so.0 => /usr/lib/libapr-1.so.0 (0x00110000)
libpthread.so.0 => /lib/libpthread.so.0 (0x00257000)
libc.so.6 => /lib/libc.so.6 (0x00e37000)
/lib/ld-linux.so.2 (0x00aae000)
libdl.so.2 => /lib/libdl.so.2 (0x0096d000)
libuuid.so.1 => /lib/libuuid.so.1 (0x007c8000)
libfreebl3.so => /lib/libfreebl3.so (0x00d94000)

为什么 libuuid libfreebl3 列在CentOS框中但未列在Ubuntu框中?

我知道httpd ELF没有将它们列为依赖项:

0x00000001 (NEEDED)                     Shared library: [libm.so.6]
0x00000001 (NEEDED)                     Shared library: [libpcre.so.0]
0x00000001 (NEEDED)                     Shared library: [libselinux.so.1]
0x00000001 (NEEDED)                     Shared library: [libaprutil-1.so.0]
0x00000001 (NEEDED)                     Shared library: [libcrypt.so.1]
0x00000001 (NEEDED)                     Shared library: [libexpat.so.1]
0x00000001 (NEEDED)                     Shared library: [libdb-4.7.so]
0x00000001 (NEEDED)                     Shared library: [libapr-1.so.0]
0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
0x00000001 (NEEDED)                     Shared library: [libc.so.6]

任何见解?

编辑:两个测试中使用的httpd二进制文件是相同的(我从CentOS RPM中解压缩)。

3 个答案:

答案 0 :(得分:3)

可以说Apache是​​在Fedora和Ubuntu上使用不同的选项构建(编译)的。

可能比较

的输出
httpd -V

会告诉你更多相关信息。

答案 1 :(得分:1)

man ldd(1)说:

在通常情况下,ldd调用标准动态链接器(请参阅ld.so(8)),并将LD_TRACE_LOADED_OBJECTS环境变量设置为        1,这会导致链接器显示库依赖项。但请注意,在某些情况下,某些版本的ldd        可以尝试通过直接执行程序来获得依赖性信息。因此,你不应该在不受信任的情况下使用ldd        可执行文件,因为这可能导致执行任意代码。处理不受信任的可执行文件时更安全的替代方法是:

$ objdump -p /path/to/program | grep NEEDED

根据我的经验,这可以产生比ldd更好的结果。

答案 2 :(得分:0)

libapr-1在ubuntu中称为libapr-1.0。至少,无论如何它在12.04。