linker - Linux ELF - Why does normal linking run faster than 'ldd -r'? -
i have exe in none of code changed, afraid links symbols no longer exist on shared objects. found 2 ways test that:
- run
ldd -r
- relink exe
in cases seems relinking faster running ldd -r
reason this?
in cases seems relinking faster running ldd -r reason this?
consider simple case: main.o
calls foo()
libfoo.so
, , linked this:
gcc main.o -l. -lfoo
the amount of work ld
has do: discover foo
being called, find defined in libfoo.so
, done. not work.
now suppose libfoo.so
has been linked against libbar.so
, , calls 10000000 different symbols it.
what ldd -r
have do? first in a.out
unresolved symbols (there one: foo
), , find definition in libfoo.so
(easy). next has consider every undefined symbol in libfoo.so
, , find definition of them (in libbar.so
). 1000000 times harder. repeat libbar.so
, , every other library linked it.
it should not surprising under above conditions ld
take less time ldd -r
.
Comments
Post a Comment