Dynamic loader path on x86_64

Ilya Trukhanov lahvuun@gmail.com
Sun Jan 2 17:29:10 GMT 2022


Hello!

I'm building glibc-2.34 on x86_64 for a no-multilib prefix like so:

$ mkdir build && cd build
$ ../configure --prefix=/pfx
$ make -j16
$ make install

After looking at sysdeps/unix/sysv/linux/x86_64/ldconfig.h:

#define SYSDEP_KNOWN_INTERPRETER_NAMES \
  { "/lib/ld-linux.so.2", FLAG_ELF_LIBC6 }, \
  { "/libx32/ld-linux-x32.so.2", FLAG_ELF_LIBC6 }, \
  { "/lib64/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 },

I'd expect the loader to be installed to
/pfx/lib64/ld-linux-x86-64.so.2, but it is instead installed to
/pfx/lib/ld-linux-x86-64.so.2, breaking (at least) /pfx/bin/ldd, which
gives me "not a dynamic executable" for all files. Strace hints at the
problem:

...
faccessat2(AT_FDCWD, "/pfx/lib/ld-linux.so.2", X_OK, AT_EACCESS) = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/pfx/lib64/ld-linux-x86-64.so.2", X_OK, AT_EACCESS) = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/pfx/libx32/ld-linux-x32.so.2", X_OK, AT_EACCESS) = -1 ENOENT (No such file or directory)
...

Indeed, symlinking /pfx/lib64 to /pfx/lib makes it work.

Is this some sort of multilib quirk? Aarch64 and riscv ldconfig.h seem
to have theirs at /lib just fine.

Is the lib64->lib symlink the intended way to solve this?

Would things break if I simply patch ldconfig.h to add
{ "/lib/ld-linux-x86-64.so.2", FLAG_ELF_LIBC6 }?

Is there better way to do this that I'm not aware of, maybe?

Best,
Ilya Trukhanov.


More information about the Libc-help mailing list