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.o
callsfoo()
fromlibfoo.so
, and is linked like this:The amount of work
ld
has to do: discover thatfoo
is being called, find that it is defined inlibfoo.so
, done. Not very much work.Now suppose that
libfoo.so
itself has been linked againstlibbar.so
, and calls 10000000 different symbols from it.What does
ldd -r
have to do? It will first look ina.out
for 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
ld
will take significantly less time thanldd -r
.