Linker and Libraries Guide

Testing for Functionality

The special handles RTLD_DEFAULT, and RTLD_PROBE enable an application to test for the existence of another symbol. The symbol search follows the same model as used to relocate the calling object. See Default Symbol Lookup Model. For example, the application prog can contain the following code fragment.

        if ((fptr = (int (*)())dlsym(RTLD_DEFAULT, "foo")) != NULL)

In this case, foo is searched for in prog, followed by /lib/ If this code fragment was contained in the file from the example that is shown in Figure 3–1, then the search for foo continues into and then

This mechanism provides a robust and flexible alternative to the use of undefined weak references, as discussed in Weak Symbols.