4

There is an executable that is dynamically linked to number of shared objects. How can I determine, to which of them some symbol (imported into executable) belongs ?

If there are more than one possibility, could I silmulate ld and see from where it is being taken ?

Dmitry Khalatov
  • 4,313
  • 3
  • 33
  • 39
  • See this question: http://stackoverflow.com/questions/290799/how-can-i-find-out-which-library-is-home-to-a-given-object. – Robert Gamble Dec 01 '08 at 18:09

4 Answers4

5

Have a look at nm(1), objdump(1) and elfdump(1).

Charlie Martin
  • 110,348
  • 25
  • 193
  • 263
5

As well as the ones Charlie mentioned, "ldd" might do some of what you're looking for.

Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
3

If you can relink the executable, the simplest way to find out where references and definitions come from is using ld -y flag. For example:

$ cat t.c
int main() { printf("Hello\n"); return 0; } 

$ gcc t.c -Wl,-yprintf 
/lib/libc.so.6: definition of printf

If you can not relink the executable, then run ldd on it, and then run 'nm -D' on all the libraries listed in order, and grep for the symbol you are interested in.

1
$LD_DEBUG=bindings my_program

That would print all the symbol bindings on the console.