BЈовић BЈовић - 6 months ago 19
C Question

How to check what shared libraries are loaded at run time for a given process?

Is there a way to check which libraries is a running process using?

To be more specific, if a program loads some shared libraries using dlopen, then readelf or ldd is not going to show it.
Is it possible at all to get that information from a running process? If yes, how?

Answer Source

Other people are on the right track. Here are a couple ways.

cat /proc/NNNN/maps | awk '{print $6}' | grep '\.so' | sort | uniq

Or, with strace:

strace CMD.... 2>&1 | grep '^open(".*\.so"'

Both of these assume that shared libraries have ".so" somewhere in their paths, but you can modify that. The first one gives fairly pretty output as just a list of libraries, one per line. The second one will keep on listing libraries as they are opened, so that's nice.

Edit: And of course lsof...

lsof -p NNNN | awk '{print $9}' | grep '\.so'
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download