How to list REALLY "unresolved symbols" in shared libraries?

I am looking for a way to list REALLY “unresolved symbols” in shared libraries.
Let’s take an example: ldd ${ROOTSYS}/lib/libMinuit2.so
It will list all shared libraries which this library needs.
Now try: nm -C -u ${ROOTSYS}/lib/libMinuit2.so
One gets a full list of “undefined symbols”, including symbols that are actually provided by shared libraries listed in the output of “ldd”.
So, I am looking for a way to get the list of REALLY “unresolved symbols”.

There is the linker flag -Wl,--no-undefined which is not quite what you are looking for but close.
When creating a shared library it will require that every thing it needs is provided but (seemingly) won’t do that recursively. Still for a given library you “could” extract the .o files and relink it …

Cheers,
Philippe.

Hi @Wile_E_Coyote,

The GNU dynamic linker, i.e. ld.so, is influenced by some environment variables. Concretely, to gain insight into relocation, LD_DEBUG and LD_WARN are especially useful. The former can take several values (I would first try all), while the latter can be set to any value to warn of unresolved symbols during relocation. Please, refer to the documentation for more information $ man ld.so.

Note, however, that for ELF files with an entry point it will relocate symbols and jump to the entry point, which can be insecure for untrusted binaries. For instance, this will run firefox (and makes ld.so quite verbose):

$ LD_DEBUG=all /usr/bin/firefox

The above works for binaries with an entry point. However, you can manually run the dynamic linker on a .so file. This will obviously segfault after symbol relocation, as these files typically have no entry point. In any case, you already got what you were looking for. See below for an example (you will probably need to adjust the path to ld-linux.so).

LD_WARN=1 /lib64/ld-linux-x86-64.so.2 /usr/lib/libcurl.so

Cheers,
J.