views:

618

answers:

5

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 ?

+4  A: 

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

Charlie Martin
Thanks for elfdump, wasn't aware of it.
Dmitry Khalatov
+4  A: 

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

Paul Tomblin
A: 

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.

A: 

$LD_DEBUG=bindings my_program

That would print all the symbol bindings on the console.