Dynamically load a module into the calling process.
void *dlopen (FilePath, Flags); const char *FilePath; int Flags;
The dlopen subroutine loads the module specified by FilePath into the executing process's address space. Dependents of the module are automatically loaded as well. If the module is already loaded, i t is not loaded again, but a new, unique value will be returned by the dlopen subroutine.
The value returned by dlopen may be used in subsequent calls to dlsym and dlclose. If an error occurs during the operation, dlopen returns NULL .
If the main application was linked with the -brtl option, then the runtime linker is invoked by dlopen. If the module being loaded was linked with runtime linking enabled, both intra-module and inter-module references are overridden by any symbols available in the main application. If runtime linking was enabled, but the module was not built enabled, then all inter-module references will be overridden, but some intra-module references will not be overridden.
If the module being opened with dlopen or any of its dependents is being loaded for the first time, initialization routines for these newly-loaded routines are called (after runtime linking, if applicable) before dlopen returns. Initialization routines are the functions specified with the -binitfini: linker option when the module was built. (Refer to the ld command for more information about this option.)
- The initialization functions need not have any special names, and multiple functions per module are allowed.
- If the module being loaded has read-other permission, the module is loaded into the global shared library segment. Modules loaded into the global shared library segment are not unloaded even if they are no longer being used. Use the slibclean command to remove unused modules from the global shared library segment.
Use the environment variable LIBPATH to specify a list of directories in which dlopen search es for the named module. The running application also contains a set of library search paths that were specified when the application was linked; these paths are searched after any paths found in LIBPATH. Also, the setenv subroutine
|FilePath|| Specifies the name of a file containing the loadable module. This parameter can be contain an absolute path, a relative path, or no path component.
contains a slash character,
is used directly, and no directories are searched.
If the FilePath parameter is /unix , dlopen returns a value that can be used to look up symbols in the current kernel image, including those symbols found in any kernel extension that was available at the time the process began execution.
If the value of FilePath is NULL , a value for the main application is returned. This allows dynamically loaded objects to look up symbols in the main executable, or for an application to examine symbols available within itself.
Specifies variations of the behavior of dlopen. Either RTLD_NOW or RTLD_LAZY must always be specified. Other flags may be OR'ed with RTLD_NOW or RTLD_LAZY.
|RTLD_NOW||Load all dependents of the module being loaded and resolve all symbols.|
|RTLD_LAZY||Specifies the same behavior as RTLD_NOW. In a future release of AIX, the behavior of the RTLD_LAZY may change so that loading of dependent modules is deferred of resolution of some symbols is deferred.|
|RTLD_GLOBAL||Allows symbols in the module being loaded to be visible when resolving symbols used by other dlopen calls. These symbols will also be visible when the main application is opened with dlopen(NULL, mode).|
|RTLD_LOCAL||Prevent symbols in the module being loaded from being used when resolving symbols used by other dlopen calls. Symbols in the module being loaded can only be accessed by calling dlsym subroutine. If neither RTLD_GLOBAL nor RTLD_LOCAL is specified, the default is RTLD_LOCAL. If both flags are specified, RTLD_LOCAL is ignored.|
|RTLD_MEMBER||The dlopen subroutine can be used to load a module that is a member of an archive. The L_LOADMEMBER flag is used when the load subroutine is called. The module name FilePath names the archive and archive member according to the rules outlined in the load subroutine.|
|RTLD_NOAUTODEFER|| Prevents deferred imports in the module being loaded from being automatically resolved by subsequent loads. The L_NOAUTODEFER flag
is used when the load subroutine is called.
Ordinarily, modules built for use by the dlopen and dlsym sub routines will not contain deferred imports. However, deferred imports can be still used. A module opened with dlopen may provide definitions for deferred imports in the main application, for modules loaded with the load subroutine (if the L_NOAUTODEFER flag was not used), and for other modules loaded with the dlopen subroutine (if the RTLD_NOAUTODEFER flag was not used).
Upon successful completion, dlopen returns a value that can be used in calls to the dlsym and dlclose subroutines. The value is not valid for use with the loadbind and unload subroutines.
If the dlopen call fails, NULL (a value of 0) is returned and the global variable errno is set. If errno contains the value ENOEXEC , further information is available via the dlerror function.
See the load subroutine for a list of possible errno values and their meanings.
This subroutine is part of Base Operating System (BOS) Runtime.
The dlclose subroutine, dlerror subroutine, dlsym subroutine, load subroutine, loadbind subroutine, loadquery subroutine, unload subroutine.
The ld command.
Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.