1
votes

Let's say we have a shared library libA that depends on another shared library libB. We build libA this way:

$ g++ -I/header/files/of/libB -lB libA.cpp -o libA.so

Symbols exported by libB are stored in the symbol table of the libA. But where is library name "libB.so" stored? Is it stored in the symbol table also? Can I see a respective library name for each undefined symbol of libA (for example using nm tool)?

If libA depends on libB, libC, libD I'd like to see something like this:

undefined_symbol_1 - libB.so
undefined_symbol_2 - libC.so
undefined_symbol_3 - libD.so

etc

1

1 Answers

2
votes

In ELF executables, it's stored in a symbol table in the executable, yes (though not the same symbol table where your function names live! That's what nm would give you).

There is sufficient information in the executable to tell the runtime linker what dynamic libraries are required, and what symbols are expected to be found in dynamic libraries.

readelf will tell you more.

There will/must be equivalents for other executable formats but I couldn't tell you details about them.