Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In what order does ld-linux.so search shared libraries?

When ld-linux resolves a symbol it searches through the shared libraries in a particular order and stops when it finds a shared library with a matching symbol.

What determines the order it searches through the libraries? Does it make a difference if the unresolved symbol is in the main program or in another shared library?

How could I determine the search order programatically without calling external programs like ldd?

like image 437
atomice Avatar asked Sep 01 '10 09:09

atomice


1 Answers

From http://www.muppetlabs.com/~breadbox/software/ELF.txt (as mentioned by sarnold):

When resolving symbolic references, the dynamic linker examines the symbol tables with a breadth-first search. That is, it first looks at the symbol table of the executable program itself, then at the symbol tables of the DT_NEEDED entries (in order), then at the second level DT_NEEDED entries, and so on.

like image 92
Mark Avatar answered Oct 11 '22 08:10

Mark