Linker and Libraries Guide

Dependency Ordering

When dynamic executables and shared objects have dependencies on the same common shared objects, the order in which the objects are processed can become less predictable.

For example, assume a shared object developer generates with the following dependencies.

$ ldd =>     ./ =>     ./ =>     ./

If you create a dynamic executable prog, using this shared object, and define an explicit dependency on, the resulting shared object order will be as follows.

$ cc -o prog main.c -R. -L. -lC -lfoo
$ ldd prog =>     ./ =>   ./ =>     ./ =>     ./

Any requirement on the order of processing the shared object dependencies would be compromised by the construction of the dynamic executable prog.

Developers who place special emphasis on symbol interposition and .init section processing should be aware of this potential change in shared object processing order.