Search code examples
linuxglibclibc

Circular reference between libc.so.6 and liblsp.so?


▶ldd /lib/x86_64-linux-gnu/libc.so.6
        linux-vdso.so.1 (0x00007fff2b856000)
        /lib/$LIB/liblsp.so => /lib/lib/x86_64-linux-gnu/liblsp.so (0x00007f472effc000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f472f3f5000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f472efd5000)

▶ldd /lib/lib/x86_64-linux-gnu/liblsp.so
        linux-vdso.so.1 (0x00007ffe305ee000)
        /lib/$LIB/liblsp.so => /lib/lib/x86_64-linux-gnu/liblsp.so (0x00007f28eea81000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f28eea5a000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f28ee868000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f28eee8d000)

We can find a circular reference between libc.so.6 and liblsp.so. How does it works?


Solution

  • How does it works?

    1. libc.so.6 doesn't really depend on liblsp.so. You can verify this with readelf -d /lib/x86_64-linux-gnu/libc.so.6 | grep NEEDED.
      The reason ldd shows it is that it's listed in your /etc/ld.so.preload.
    2. As Nate Eldredge commented, this "cycle" doesn't matter -- the loader needs to load dependent libraries which aren't already loaded. If a library is already loaded, the loader simply increments its reference count.