1

I have a linux app I'm building from source. When I run ldd against the binary, I understand most of the libraries...but not all.

Is there a way to add a flag to ld or gcc/g++ or anything I can do to determine why the linker chose to link against specific libraries?


Edit:

To explore the route @shloim set up, I tried the following:

> nm -u /lib/x86_64-linux-gnu/libcrypto.so.1.0.0
nm: /lib/x86_64-linux-gnu/libcrypto.so.1.0.0: no symbols

> file /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 
/lib/x86_64-linux-gnu/libcrypto.so.1.0.0: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=230ebe6145b6681d0cb7e4c9021f0d899c02e0c4, stripped

Is there an obvious reason why nm would not work on libcrypto?

Stéphane
  • 19,459
  • 24
  • 95
  • 136
  • `ldd` is recursive: it lists libraries that the executable is linked against, the libraries these libraries are linked against, the libraries *those* libraries are linked against, and so on. `ld` choses nothing by itself, it links what it's told to. – n. m. could be an AI Aug 21 '14 at 11:09
  • See also [this related question](http://stackoverflow.com/questions/1488527/hierarchical-ldd1) and all the answers. – n. m. could be an AI Aug 21 '14 at 11:56
  • libcrypto has everything defined. You should run nm --defined-only .../libcrypto... and nm -u – Shloim Aug 21 '14 at 13:34
  • You can use `nm -D` if you want to see the symbols. I have no idea why you would want to. Symbols have nothing to do with the original question. Your executable is linked against exactly the libraries you have passed to the linker, no more, no less. – n. m. could be an AI Aug 21 '14 at 19:58
  • I'm using cmake, and while there are some libraries I'm explicitly passing, there are several that are being pulled in from some other reason. These are the ones I'm trying to figure out. – Stéphane Aug 21 '14 at 21:19
  • Again. Your executable is linked against libraries A, B and C. Library A is linked against D and E. Library E is linked against F and G. `ldd` will show all of those. – n. m. could be an AI Aug 22 '14 at 09:37

2 Answers2

1

This should show you all symbols used in the so file that are undefined within the so:

nm -u <your_so_file>

You can then compare it with

nm --defined-only <3rd_party_so_file>

And try to figure out the common symbols

Shloim
  • 5,281
  • 21
  • 36
1
Is there an obvious reason why nm would not work on libcrypto?

Generally nm is to list the symbols of object files. Here, nm is used for share object file. So try like this nm -D libcrypto.so.

readelf or objdump can also be used to check the symbols present in shared objects.

readelf -Ws will show all the symbols

mahendiran.b
  • 1,315
  • 7
  • 13