I need to find out what libraries a unix process has loaded and might use throughout it's lifetime. Is this possible and how. Or better yet, i have a library name and i need to find out what processes are using it, is this possible.
On the same note, is it possible to get notified some how when a unix process is launched and when it is quit. They would not be child processes of my process, i just need to know globally.
Update:
I think I didn't give enough information. The unix i was talking about was MacOS X ( even though some say its not really completely unix ), and I was looking for a way to find the loaded libraries a process has and i need to do it in C/C++.
By default, libraries are located in /usr/local/lib, /usr/local/lib64, /usr/lib and /usr/lib64; system startup libraries are in /lib and /lib64. Programmers can, however, install libraries in custom locations. The library path can be defined in /etc/ld.
Use objdump -p libABCD.so | grep NEEDED to view dependencies on individual library files. Then follow on the output libraries. Show activity on this post. Instead of giving the boost libraries as -l on the linker command line, you can also give them with their full path and file name.
If the program is already running, we can also get the list of loaded shared libraries by reading the file /proc/<PID>/maps. In this file, each row describes a region of contiguous virtual memory in a process or thread. If the process has loaded a shared library, the library will show up in this file.
Solaris has pldd
. For Linux you can call ldd
on the executable or pmap
on a running process or look into /proc/PID/maps
for mapped libraries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With