On Linux, I have a C++ application that is using dlopen() to load some shared libraries, but I'm suspicious that the version of the shared library being loaded is not the one I expect because my debugging trace code does not appear to be executed.
Is there a way to check a running process to query all the shared libraries it currently has open and the path to each of those libraries? In other words, something akin to ldd
but that works on a running executable and lists runtime loaded libraries as well.
If you want to know the library files a program have opened, you can try pmap. For example, if we want to know the libraries that bash process 3860 have opened, the result could be:
3860: bash
08048000 880K r-x-- /bin/bash
08124000 4K r---- /bin/bash
08125000 20K rw--- /bin/bash
0812a000 20K rw--- [ anon ]
099ae000 348K rw--- [ anon ]
b715c000 44K r-x-- /lib/i386-linux-gnu/libnss_files-2.15.so
b7167000 4K r---- /lib/i386-linux-gnu/libnss_files-2.15.so
b7168000 4K rw--- /lib/i386-linux-gnu/libnss_files-2.15.so
b7169000 88K r-x-- /lib/i386-linux-gnu/libnsl-2.15.so
b717f000 4K r---- /lib/i386-linux-gnu/libnsl-2.15.so
b7180000 4K rw--- /lib/i386-linux-gnu/libnsl-2.15.so
b7181000 8K rw--- [ anon ]
b7183000 28K r-x-- /lib/i386-linux-gnu/libnss_compat-2.15.so
b718a000 4K r---- /lib/i386-linux-gnu/libnss_compat-2.15.so
b718b000 4K rw--- /lib/i386-linux-gnu/libnss_compat-2.15.so
b71a1000 4K r---- /usr/lib/locale/locale-archive
b71a2000 1428K r---- /usr/lib/locale/locale-archive
b7307000 2048K r---- /usr/lib/locale/locale-archive
b7507000 4K rw--- [ anon ]
b7508000 1676K r-x-- /lib/i386-linux-gnu/libc-2.15.so
b76ab000 8K r---- /lib/i386-linux-gnu/libc-2.15.so
b76ad000 4K rw--- /lib/i386-linux-gnu/libc-2.15.so
b76ae000 16K rw--- [ anon ]
b76b2000 12K r-x-- /lib/i386-linux-gnu/libdl-2.15.so
b76b5000 4K r---- /lib/i386-linux-gnu/libdl-2.15.so
b76b6000 4K rw--- /lib/i386-linux-gnu/libdl-2.15.so
b76b7000 112K r-x-- /lib/i386-linux-gnu/libtinfo.so.5.9
b76d3000 8K r---- /lib/i386-linux-gnu/libtinfo.so.5.9
b76d5000 4K rw--- /lib/i386-linux-gnu/libtinfo.so.5.9
b76d8000 28K r--s- /usr/lib/i386-linux-gnu/gconv/gconv-modules.cache
b76df000 40K r-x-- /lib/i386-linux-gnu/libnss_nis-2.15.so
b76e9000 4K r---- /lib/i386-linux-gnu/libnss_nis-2.15.so
b76ea000 4K rw--- /lib/i386-linux-gnu/libnss_nis-2.15.so
b76eb000 8K rw--- [ anon ]
b76ed000 4K r-x-- [ anon ]
b76ee000 128K r-x-- /lib/i386-linux-gnu/ld-2.15.so
b770e000 4K r---- /lib/i386-linux-gnu/ld-2.15.so
b770f000 4K rw--- /lib/i386-linux-gnu/ld-2.15.so
bfbbf000 132K rw--- [ stack ]
total 7152K
Wish it would be of help for you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.