Question

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 ?

Was it helpful?

Solution

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

OTHER TIPS

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

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.

$LD_DEBUG=bindings my_program

That would print all the symbol bindings on the console.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top