I have an exe in which none of the code changed, but I am afraid that it links to symbols that no longer exist on its shared objects. I found two ways to test that:
- Run
ldd -r - Relink the exe
In some cases it seems like relinking is faster than running ldd -r what is the reason for this?
Consider a simple case:
main.ocallsfoo()fromlibfoo.so, and is linked like this:The amount of work
ldhas to do: discover thatfoois being called, find that it is defined inlibfoo.so, done. Not very much work.Now suppose that
libfoo.soitself has been linked againstlibbar.so, and calls 10000000 different symbols from it.What does
ldd -rhave to do? It will first look ina.outfor any unresolved symbols (there is only one:foo), and find a definition for it inlibfoo.so(easy). Next it has to consider every undefined symbol inlibfoo.so, and find a definition for all of them as well (inlibbar.so). That is about 1000000 times harder. Repeat forlibbar.so, and every other library linked into it.It should not then be very surprising then that under above conditions
ldwill take significantly less time thanldd -r.