I have an executable and I would like to find out which shared libraries were actually used during a specific run. I know ldd would list all the shared library dependencies of that executable but I would like to find out the subset of those that were actually used during a specific run*. Is this possible?
*what I mean with specific run is running the executable with certain input parameters that would cause only a small part of the code to be run.
Advertisement
Answer
You can use ltrace(1)
for this:
$ PROG='ls -l' # Collect call info $ ltrace -o calls.txt -l '*' $PROG &> /dev/null # Analyze collected data $ cat calls.txt | sed -ne '/->/{ s/^(.*)->.*/1/; p }' | sort -u libacl.so.1 libcap.so.2 libc.so.6 libselinux.so.1 ls # Compare with ldd $ ldd /bin/ls | wc -l 10