Consider the shared object dependencies of /bin/bash
, which includes /lib64/ld-linux-x86-64.so.2
(dynamic linker/loader):
ldd /bin/bash
linux-vdso.so.1 (0x00007fffd0887000)
libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f57a04e3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f57a04de000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f57a031d000)
/lib64/ld-linux-x86-64.so.2 (0x00007f57a0652000)
Inspecting /lib64/ld-linux-x86-64.so.2
shows that it is a symlink to /lib/x86_64-linux-gnu/ld-2.28.so
:
ls -la /lib64/ld-linux-x86-64.so.2
lrwxrwxrwx 1 root root 32 May 1 19:24 /lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.28.so
Furthermore, file
reports /lib/x86_64-linux-gnu/ld-2.28.so
to itself be dynamically linked:
file -L /lib64/ld-linux-x86-64.so.2
/lib64/ld-linux-x86-64.so.2: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=f25dfd7b95be4ba386fd71080accae8c0732b711, stripped
I'd like to know:
- How can the dynamically linker/loader (
/lib64/ld-linux-x86-64.so.2
) itself be dynamically linked? Does it link itself at runtime? /lib/x86_64-linux-gnu/ld-2.28.so
is documented to handle a.out binaries (man ld.so
), but/bin/bash
is an ELF executable?
The program ld.so handles a.out binaries, a format used long ago; ld-linux.so* (/lib/ld-linux.so.1 for libc5, /lib/ld-linux.so.2 for glibc2) han‐ dles ELF, which everybody has been using for years now.
/lib/x86_64-linux-gnu/ld-2.28.so
, debian 10 buster)file
’s erroneous comment about how it defines static binaries, and the reality ofld-2.28.so
... The differentiator isPT_DYNAMIC
.