| ||
|
| |
+ | ||
v | v | |
>libB.so |
For
The loader uses the following algorithm in
if the library has not been visited then mark the library as visited.
if the library has a dependency list then traverse the list in reverse order.
Place the library at the head of the load list.
1.mark P, traverse Q
2.mark Q, traverse B
3.mark B, load B
4.load Q
5.traverse D
6.mark D, traverse B
7.B is already marked, so skip B, traverse Q
8.Q is already marked, so skip Q
9.load D
10.mark A, load A
11.load P
The resulting load graph is:
The dynamic loader uses the following algorithm in
if the library has not been visited then mark the library as visited;
append the library at the end of the list. if the library has a dependency list then traverse the list in order.
1.mark P, load P
2.traverse P
3.mark A, load A
4.mark D, load D
5.mark Q, load Q
6.traverse D
7.Q is already marked, so skip Q
8.mark B, load B
9.traverse Q
10.B is already marked, so skip B
The resulting load graph is:
Placing Loaded Libraries in the Search List
The libraries must be added to the shared library search list once a load graph is formed, thus binding their symbols to the program. If the initial library is an implicitly loaded library (that is, a library that is automatically loaded when the program begins execution), the libraries in the load graph are appended to the library search list. For example, if libP is implicitly loaded, the library search list is:
Creating Shared Libraries 101