Load – Is ld.so an Executable?

linkerload

$ file /lib/ld-linux.so.2
/lib/ld-linux.so.2: symbolic link to i386-linux-gnu/ld-2.27.so
$ readlink -f /lib/ld-linux.so.2
/lib/i386-linux-gnu/ld-2.27.so
$ file /lib/i386-linux-gnu/ld-2.27.so
/lib/i386-linux-gnu/ld-2.27.so: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a59ed1836f27b66ffd391d656da6435055f02f8, stripped

So is ld-2.27.so a shared library?

It is said to be a dynamic linker/loader and mentioned in section 8 of man. So is it an executable?

If yes, why is it named like a shared library as *.so?

If no, how shall I understand it is like an executable, for being a dynamic linker/loader and mentioned in section 8 of man?

Thanks.

Best Answer

It is both, which is perfectly valid.

The ld.so-style naming scheme is largely historical; the first dynamic linker in this style was SunOS 4’s, which was named ld.so (I have its history somewhere, I’ll clarify this once I’ve found it). But there are valid reasons for it to be named like a shared library rather than an executable, including:

  • it exists to serve executables, like shared libraries (it has no purpose without executables to run);
  • it is a shared ELF object, but it doesn’t require an interpreter (it has no .interp entry); this is typical of libraries (shared, or rather dynamically-linked, executables always require an interpreter; otherwise they’re statically-linked).

The distinction between executables and libraries is somewhat fluid in ELF; any ELF object with an entry point and/or an interpreter can be an executable, regardless of its other properties.

Related Question