I'd like to find all files a binary depends on (including libraries, configuration files, basically all files referenced in the binary).

I know, that you can find shared libraries with objdump, ldd, readelf, but what about dynamically loaded libraries (dlopen) and other files (/etc/some/config)?

So far, I have a half baked solution which searches the binary for strings (filenames) ($ strings /path/to/binary | grep lib), but I think the proper solution would be to search for system calls the binary makes (read, write, dlopen, etc).

Unfortunately I don't have any experience with disassemblers or an idea about other methods.

Also I cannot use solutions which depend on executing the binary (strace, and fiddling around, etc), because I need to do this for a large number of binaries in bulk.

A solution which finds about 90% of all files referenced by a binary would be sufficient.

The binaries to examine are standard (Arch) Linux (multilib) binaries. I assume most of them were compiled by gcc (-O2).


You could try:

strace -fe open cmd 2>&1 >/dev/null | grep -v '= -1' | cut -d\" -f2

To see what it opens at run time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.