Home > Software engineering >  Is there a way to make an executable explicitly show how it searches shared libraries?
Is there a way to make an executable explicitly show how it searches shared libraries?

Time:02-01

As the question states, I need to see how my program looks for shared libraries. I have a custom libc which is not located in /lib and I want my program to use this version. First, I used LD_LIBRARY_PATH to point to my custom libraries directory and all of other dependencies were found successfully except libc, which was required by libsystemd. As the error message states, it looks for libc in /lib despite LD_LIBRARY_PATH being set:

./test: /lib/libc.so.6: version `GLIBC_2.30' not found (required by /mnt/SDCARD/lib/custom/libsystemd.so.0)

I even tried adding a new RUNPATH into libsystemd which hasn't been set before, but that didn't work:

Dynamic section at offset 0x7a000 contains 37 entries:
  Tag        Type                         Name/Value
 0x0000001d (RUNPATH)                    Library runpath: [/mnt/SDCARD/lib/custom/]
 0x00000001 (NEEDED)                     Shared library: [librt.so.1]
 0x00000001 (NEEDED)                     Shared library: [liblzma.so.5]
 0x00000001 (NEEDED)                     Shared library: [libzstd.so.1]
 0x00000001 (NEEDED)                     Shared library: [liblz4.so.1]
 0x00000001 (NEEDED)                     Shared library: [libgcrypt.so.20]
 0x00000001 (NEEDED)                     Shared library: [libpthread.so.0]
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x00000001 (NEEDED)                     Shared library: [ld-linux-armhf.so.3]
 0x0000000e (SONAME)                     Library soname: [libsystemd.so.0]

libsystemd ignores both hardcoded RUNPATH and LD_LIBRARY_PATH. Is there a way to see how my program searches shared libraries? What can cause this problem?

CodePudding user response:

LD_DEBUG env variable allows to see where shared libraries are searched

  • Related