Flag

Definition

 

 

BIND_TOGETHER

Causes the library being loaded and all its dependent libraries to be bound together

 

rather than each independently. Use this when you have interdependent libraries and

 

you are using BIND_FIRST.

 

 

BIND_BREADTH_FIRST

Causes the dependent libraries to be loaded breadth first. By default, shl_load loads

 

dependent libraries depth-first.

 

 

These flags are discussed in detail in the “shl_load Example” (page 170) .

address Specifies the virtual address at which to attach the library. Set this parameter to 0 (zero) to tell the system to choose the best location. This argument is currently ignored; mapping a library at a user-defined address is not currently supported.

Return Value

If successful, shl_load returns a shared library handle of type shl_t. This address can be used in subsequent calls to shl_close, shl_findsym, shl_gethandle, and shl_gethandle_r. Otherwise, shl_load returns a shared library handle of NULL and sets errno to one of these error codes (from <errno.h>):

Error Code

Definition

ENOEXEC

The specified path is not a shared library, or a format error was detected in this or another

 

library.

 

 

ENOSYM

A symbol needed by this library or another library which this library depends on could not

 

be found.

 

 

ENOMEM

There is insufficient room in the address space to load the shared library.

 

 

EINVAL

The requested shared library address was invalid.

 

 

ENOENT

The specified path does not exist.

 

 

EACCESS

Read or execute permission is denied for the specified path.

 

 

Description

A program needs to explicitly load a library only if the library was not linked with the program. This typically occurs only when the library cannot be known at link time - for example, when writing programs that must support future graphics devices.

However, programs are not restricted to using shared libraries only in that situation. For example, rather than linking with any required libraries, a program can explicitly load libraries as they are needed. One possible reason for doing this is to minimize virtual memory overhead. To keep virtual memory resource usage to a minimum, a program can load libraries with shl_load and unload with shl_unload when the library is no longer needed. However, it is normally not necessary to incur the programming overhead of loading and unloading libraries yourself for the sole reason of managing system resources.

Note that if shared library initializers have been declared for an explicitly loaded library, they are called after the library is loaded. For details, see “Initializers for Shared Libraries” (page 138).

To explicitly load a shared library, use the shl_load routine. This ensures that constructors of nonlocal static objects are executed when the library is loaded.

The shl_load routine lets you load a compatibility or standard mode shared libraries. The BIND_BREADTH_FIRST flag overrides the default depth-first loading mechanism.

The shl_load Shared Library Management Routines 169