Is there an automated way to determine the dependencies of shared objects?

Short: I'm looking for something that will list all unresolved dependencies in SO, given the SOs that are in it dependencies.

Long

I am converting a lot of static compiled code into Shared Objects on Linux - is there an easy way to determine which other SOs that my recently compiled SO depends on, besides trial and error while trying to load it?

I am sure there is a better way, but I have not been able to find it yet.

I found "ldd", but it only lists what SO is talking about. I also used "nm" to find out how SO does not load, to check what else contains SO.

+3
source share
2 answers

I don't have code for you, but I can specify pointers:

This is just a graph problem. You must use objdump -Tto dump a dynamic symbol table for a given binary or shared object. You will see many lines of output, and flags may be a little confusing, but the important part is if these characters are either *UND*, or they will have the name of the segment ( .textetc.).

Whenever you see *UND*, this means that it is an undefined character that must be allowed. Certain characters are permission objects.

With this and a little Python you can find what you need.

+2
source

"ldd -r foo.so" , foo.so, .

, foo.so :

  gcc -shared -o foo.so foo.o bar.o -ldep1 -ldep2 -Wl,--no-undefined

( ), foo.o bar.o -, libdep1 libdep2 libc.

+2

Source: https://habr.com/ru/post/1715336/


All Articles