TOTAL SYMBOLS: 9

[/usr/lib/libc.1]

Imports:

_res_rmutexSTORAGE

errnoSTORAGE

_regrpc_rmutexSTORAGE

_yellowup_rmutexSTORAGE

_FPU_MODELSTORAGE

_environ_rmutexSTORAGE

_iop_rmutexSTORAGE

_rpcnls_rmutexSTORAGE

_switch_rmutexSTORAGE

_mem_rmutexSTORAGE

_dir_rmutexSTORAGE

The shl_unload Routine

The shl_unload routine unloads or frees up space for a shared library.

Syntax

int shl_unload(shl_t handle)

Parameters

handle The handle of the shared library you wish to unload. The handle value is obtained from a previous call to shl_load, shl_findsym, or shl_get.

Return Value

If successful, shl_unloadreturns 0. Otherwise, shl_unload returns -1 and sets errno to an appropriate value: EINVAL Indicates the specified handle is invalid. ETXTBSY Indicates the specified shared library is currently in use and hence cannot be unloaded. Read more information.ENOENT Indicates the specified handle cannot be found.

Description

To unload a shared library, use the shl_unload function. One reason to do this is to free up the private copy of shared library data and swap space allocated when the library was loaded with shl_load. (This is done automatically when a process exits.)

Another reason for doing this occurs if a program needs to replace a shared library. For example, suppose you implement some sort of shell or interpreter, and you want to load and execute user “"programs"” which are actually shared libraries. So you load one program, look up its entry point, and call it. Now you want to run a different program. If you do not unload the old one, its symbol definitions may get in the way of the new library. So you must unload it before loading the new library.

Note that if shared library initializers are declared for a shared library, they are called when the shared library is explicitly unloaded. For details, see “Initializers for Shared Libraries” (page 138).

If unloading a C++ library, use thecxxshl_unload routine. This ensures that destructors of nonlocal static objects are executed when the library is unloaded. The syntax of cxxshl_unload is the same as that of shl_unload.

Usage

When a library is unloaded, existing linkages to symbols in an unloaded library are not invalidated. Therefore, the programmer must ensure that the program does not reference symbols in an unloaded library as undefined behavior can result. In general, this routine is recommended only for experienced programmers.

182 Shared Library Management Routines