ldd shows varied addresses on x86 Linux

2020-07-06 03:14发布

I am using ldd to show the dynamic library on Fedora/x86, and it shows different results each time it is used.

Is that expected? Or is there an explanation?

I remember it shows a fixed result on PPC/Linux.

`ldd /bin/ls
 linux-gate.so.1 =>  (0x00e5b000)
 librt.so.1 => /lib/librt.so.1 (0x00c0c000)
 libselinux.so.1 => /lib/libselinux.so.1 (0x0095d000)
 libcap.so.2 => /lib/libcap.so.2 (0x00110000)
 libacl.so.1 => /lib/libacl.so.1 (0x00331000)
 libc.so.6 => /lib/libc.so.6 (0x00115000)
 libpthread.so.0 => /lib/libpthread.so.0 (0x00bc9000)
 /lib/ld-linux.so.2 (0x009d2000)
 libdl.so.2 => /lib/libdl.so.2 (0x00680000)
 libattr.so.1 => /lib/libattr.so.1 (0x00447000)
ldd /bin/ls
 linux-gate.so.1 =>  (0x00f76000)
 librt.so.1 => /lib/librt.so.1 (0x00494000)
 libselinux.so.1 => /lib/libselinux.so.1 (0x0095d000)
 libcap.so.2 => /lib/libcap.so.2 (0x009e9000)
 libacl.so.1 => /lib/libacl.so.1 (0x00365000)
 libc.so.6 => /lib/libc.so.6 (0x00732000)
 libpthread.so.0 => /lib/libpthread.so.0 (0x00b61000)
 /lib/ld-linux.so.2 (0x002a7000)
 libdl.so.2 => /lib/libdl.so.2 (0x002f0000)
 libattr.so.1 => /lib/libattr.so.1 (0x00447000)`

1条回答
老娘就宠你
2楼-- · 2020-07-06 03:30

Fedora uses address space randomization as part of its various security measures. ldd works by actually loading the shared objects and showing where they end up. Putting the two together results in the given observations.

查看更多
登录 后发表回答