User's Manual
perror("shl_load: error loading library"), exit(1);
return lib_handle;
}
BIND_NONFATAL Modifier
If you load a shared library with the BIND_IMMEDIATE flag and the library contains unresolved
symbols, the load fails and sets errno to ENOSYM. ORing BIND_NONFATAL with
BIND_IMMEDIATE causes shl_load to allow the binding of unresolved symbols to be deferred
if their later use can be detected - for example:
shl_t libH;
. . .
libH = shl_load("libxyz.so", BIND_IMMEDIATE | BIND_NONFATAL, 0);
However, data symbol binding cannot be deferred, so using the BIND_NONFATAL modifier does
not allow the binding of unresolved data symbols.
BIND_VERBOSE Modifier
If BIND_VERBOSE is ORed with the flags parameter, the dynamic loader displays messages for
all unresolved symbols. This option is useful to see exactly which symbols cannot be bound.
Typically, you may use this with BIND_IMMEDIATE to debug unresolved symbols. For example,
shl_t libH;
. . .
libH = shl_load("libpdq.so", BIND_DEFERRED | BIND_FIRST, 0);
BIND_FIRST is typically used when you want to make the symbols in a particular library more
visible than the symbols of the same name in other libraries. Compare this with the default behavior,
which is to append loaded libraries to the link order.
BIND_FIRST Modifier
BIND_FIRST is ORed with the flags parameter, the loaded library is inserted before all other
loaded shared libraries in the symbol resolution search order. This has the same effect as placing
the library first in the link order - that is, the library is searched before other libraries when resolving
symbols. This is used with either BIND_IMMEDIATE or BIND_DEFERRED. For example
shl_t libH;
. . .
libH = shl_load("libpdq.so", BIND_DEFERRED | BIND_FIRST, 0);
BIND_FIRST is typically used when you want to make the symbols in a particular library more
visible than the symbols of the same name in other libraries. Compare this with the default behavior,
which is to append loaded libraries to the link order.
DYNAMIC_PATH Modifier
The flag DYNAMIC_PATH can also be alternated with the flags parameter, causing the dynamic
loader to search for the library using a path list specified by the +b option at link time or the
SHLIB_PATH environment variable at run time.
BIND_NOSTART Modifier
The flag BIND_NOSTART inhibits execution of initializers for the library.
BIND_RESTRICTED Modifier
This flag is most useful with the BIND_DEFERRED flag; it has no effect with BIND_IMMEDIATE.
It is also useful with the BIND_NONFATAL flag.
When used with only the BIND_DEFERRED flag, it exhibits the following behavior: When a symbol
is referenced and needs to be bound, this flag causes the search for the symbol definition to be
restricted to those symbols that were visible when the library was loaded. If a symbol definition
cannot be found within this restricted set, it results in a run-time symbol-binding error.
The shl_load Shared Library Management Routines 171