There are a few ways to get at this. The easiest is probably to use a debugger.
Using GDB
With gdb
you can connect to a running program. Say for example I want to connect to a running vim
process. First I need to know it's PID
number:
$ pidof vim
15425
I can now connect to the process using gdb
:
$ gdb `which vim` 15425
At the prompt, I can now enquire about different symbols:
$ info symbol fprintf
fprintf in section .text of /lib/x86_64-linux-gnu/libc.so.6
$ info address fprintf
Symbol "fprintf" is at 0x7fc9b44314a0 in a file compiled without debugging.
Using /proc
Another way to get a dump of memory locations of libraries from /proc
.
Again, you need the PID
(see above) and you can dump out the libraries and their locations in the virtual memory of a process.
$ cat /proc/15425/maps
7fc9a9427000-7fc9a9432000 r-xp 00000000 fd:02 539295973 /lib/x86_64-linux-gnu/libnss_files-2.19.so
7fc9a9432000-7fc9a9631000 ---p 0000b000 fd:02 539295973 /lib/x86_64-linux-gnu/libnss_files-2.19.so
7fc9a9631000-7fc9a9632000 r--p 0000a000 fd:02 539295973 /lib/x86_64-linux-gnu/libnss_files-2.19.so
7fc9a9632000-7fc9a9633000 rw-p 0000b000 fd:02 539295973 /lib/x86_64-linux-gnu/libnss_files-2.19.so
Each library will have multiple sections and this will depend on how it was compiled/linked.