1

I analyze with "ldd -v" the same shared library (copied it on NFS) from two different build hosts. Both are Ubuntu 16.04 and have as it seems the same version of ldd.

I am expecting of course to see the same output, however it differs not just a little bit. On the first build host GLIBC_2.18 is not shown in the output, but on the second one it is.

Build host #1.

$ uname -a
Linux build-nodejs01 4.4.0-174-generic #204-Ubuntu SMP Wed Jan 29 06:41:01 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

$ ldd --version
ldd (Ubuntu GLIBC 2.23-0ubuntu11) 2.23
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

$ strings /media/nfs/libtesseract.so | grep -e '^GLIBC_'
GLIBC_2.2.5
GLIBC_2.7
GLIBC_2.14
GLIBC_2.3

$ ldd -v /media/nfs/libtesseract.so | grep libc.so.
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff784308000)
        libc.so.6 (GLIBC_2.7) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libc.so.6:
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6

Build host #2.

$ uname -a
Linux build-linux64-viewer04 4.4.0-143-generic #169-Ubuntu SMP Thu Feb 7 07:56:38 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

$ ldd --version
ldd (Ubuntu GLIBC 2.23-0ubuntu10) 2.23
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

$ strings /media/nfs/libtesseract.so | grep -e '^GLIBC_'
GLIBC_2.2.5
GLIBC_2.7
GLIBC_2.14
GLIBC_2.3

$ ldd -v /media/nfs/libtesseract.so | grep libc.so.
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdb02ddd000)
        libc.so.6 (GLIBC_2.7) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.18) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.17) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libc.so.6:
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6

The binary /usr/bin/ldd differs in md5sum on both hosts, but it should not be the cause. I have proven it this way. I copied /usr/bin/ldd from each host on NFS as /media/nfs/ldd_1, /media/nfs/ldd_2 and run both ldds from both hosts. Both ldds don't show GLIBC_2.18 on the first host, but show it on another host.

The strings output looks more reliable(host-independent) as we can see from my examples and I will use only strings from now. But I still would like to know what is the reason ldd shows different output? Is it correct?

Alexander Samoylov
  • 2,358
  • 2
  • 25
  • 28

1 Answers1

0

I am expecting of course to see the same output,

You shouldn't: you have different versions of GLIBC installed: GLIBC 2.23-0ubuntu10 vs. GLIBC 2.23-0ubuntu11.

To understand the version output better, read this and/or this answer.

But how do you explain that ...

If you check the ldd you are invoking, you'll discover that it's a shell script, which sets LD_TRACE_LOADED_OBJECTS environment variable and invokes dynamic loader /lib64/ld-linux-x86-64.so.2 to do the actual work. The dynamic loader is part of GLIBC.

Different GLIBC versions installed on the two machines -> different dynamic loaders load different versions of libc-so.6 (and other parts of GLIBC) -> different output. There is nothing surprising here.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • But how do you explain that both /media/nfs/ldd_1 and /media/nfs/ldd_2 don't show GLIBC_2.18 on the first host, but show it on another host when I call them from NFS (I wrote about this at the end in my question)?. It seems that the reason is not in the ldd binary itself. Probably ldd loads other /lib/XXX.so which are different on each host and this gives the different functionality? – Alexander Samoylov Mar 05 '20 at 11:05