DLOPEN(3)                  POSIX Programmer's Manual                 DLOPEN(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.


NNAAMMEE
       dlopen -- open a symbol table handle

SSYYNNOOPPSSIISS
       #include <dlfcn.h>

       void *dlopen(const char *_f_i_l_e, int _m_o_d_e);

DDEESSCCRRIIPPTTIIOONN
       The _d_l_o_p_e_n() function shall make the symbols (function identifiers and
       data object identifiers) in the executable object file specified by
       _f_i_l_e available to the calling program.

       The class of executable object files eligible for this operation and
       the manner of their construction are implementation-defined, though
       typically such files are shared libraries or programs.

       Implementations may permit the construction of embedded dependencies in
       executable object files. In such cases, a _d_l_o_p_e_n() operation shall load
       those dependencies in addition to the executable object file specified
       by _f_i_l_e.  Implementations may also impose specific constraints on the
       construction of programs that can employ _d_l_o_p_e_n() and its related
       services.

       A successful _d_l_o_p_e_n() shall return a symbol table handle which the
       caller may use on subsequent calls to _d_l_s_y_m() and _d_l_c_l_o_s_e().

       The value of this symbol table handle should not be interpreted in any
       way by the caller.

       The _f_i_l_e argument is used to construct a pathname to the executable
       object file. If _f_i_l_e contains a <slash> character, the _f_i_l_e argument is
       used as the pathname for the file. Otherwise, _f_i_l_e is used in an
       implementation-defined manner to yield a pathname.

       If _f_i_l_e is a null pointer, _d_l_o_p_e_n() shall return a global symbol table
       handle for the currently running process image. This symbol table
       handle shall provide access to the symbols from an ordered set of
       executable object files consisting of the original program image file,
       any executable object files loaded at program start-up as specified by
       that process file (for example, shared libraries), and the set of
       executable object files loaded using _d_l_o_p_e_n() operations with the
       RTLD_GLOBAL flag. As the latter set of executable object files can
       change during execution, the set of symbols made available by this
       symbol table handle can also change dynamically.

       Only a single copy of an executable object file shall be brought into
       the address space, even if _d_l_o_p_e_n() is invoked multiple times in
       reference to the executable object file, and even if different
       pathnames are used to reference the executable object file.

       The _m_o_d_e parameter describes how _d_l_o_p_e_n() shall operate upon _f_i_l_e with
       respect to the processing of relocations and the scope of visibility of
       the symbols provided within _f_i_l_e.  When an executable object file is
       brought into the address space of a process, it may contain references
       to symbols whose addresses are not known until the executable object
       file is loaded.

       These references shall be relocated before the symbols can be accessed.
       The _m_o_d_e parameter governs when these relocations take place and may
       have the following values:

       RTLD_LAZY   Relocations shall be performed at an implementation-defined
                   time, ranging from the time of the _d_l_o_p_e_n() call until the
                   first reference to a given symbol occurs. Specifying
                   RTLD_LAZY should improve performance on implementations
                   supporting dynamic symbol binding since a process might not
                   reference all of the symbols in an executable object file.
                   And, for systems supporting dynamic symbol resolution for
                   normal process execution, this behavior mimics the normal
                   handling of process execution.

       RTLD_NOW    All necessary relocations shall be performed when the
                   executable object file is first loaded. This may waste some
                   processing if relocations are performed for symbols that
                   are never referenced. This behavior may be useful for
                   applications that need to know that all symbols referenced
                   during execution will be available before _d_l_o_p_e_n() returns.

       Any executable object file loaded by _d_l_o_p_e_n() that requires relocations
       against global symbols can reference the symbols in the original
       process image file, any executable object files loaded at program
       start-up, from the initial process image itself, from any other
       executable object file included in the same _d_l_o_p_e_n() invocation, and
       any executable object files that were loaded in any _d_l_o_p_e_n() invocation
       and which specified the RTLD_GLOBAL flag. To determine the scope of
       visibility for the symbols loaded with a _d_l_o_p_e_n() invocation, the _m_o_d_e
       parameter should be a bitwise-inclusive OR with one of the following
       values:

       RTLD_GLOBAL The executable object file's symbols shall be made
                   available for relocation processing of any other executable
                   object file. In addition, symbol lookup using
                   _d_l_o_p_e_n(NULL,_m_o_d_e) and an associated _d_l_s_y_m() allows
                   executable object files loaded with this mode to be
                   searched.

       RTLD_LOCAL  The executable object file's symbols shall not be made
                   available for relocation processing of any other executable
                   object file.

       If neither RTLD_GLOBAL nor RTLD_LOCAL is specified, the default
       behavior is unspecified.

       If an executable object file is specified in multiple _d_l_o_p_e_n()
       invocations, _m_o_d_e is interpreted at each invocation.

       If RTLD_NOW has been specified, all relocations shall have been
       completed rendering further RTLD_NOW operations redundant and any
       further RTLD_LAZY operations irrelevant.

       If RTLD_GLOBAL has been specified, the executable object file shall
       maintain the RTLD_GLOBAL status regardless of any previous or future
       specification of RTLD_LOCAL, as long as the executable object file
       remains in the address space (see _d_l_c_l_o_s_e()).

       Symbols introduced into the process image through calls to _d_l_o_p_e_n() may
       be used in relocation activities. Symbols so introduced may duplicate
       symbols already defined by the program or previous _d_l_o_p_e_n() operations.
       To resolve the ambiguities such a situation might present, the
       resolution of a symbol reference to symbol definition is based on a
       symbol resolution order. Two such resolution orders are defined: load
       order and dependency order. Load order establishes an ordering among
       symbol definitions, such that the first definition loaded (including
       definitions from the process image file and any dependent executable
       object files loaded with it) has priority over executable object files
       added later (by _d_l_o_p_e_n()).  Load ordering is used in relocation
       processing. Dependency ordering uses a breadth-first order starting
       with a given executable object file, then all of its dependencies, then
       any dependents of those, iterating until all dependencies are
       satisfied. With the exception of the global symbol table handle
       obtained via a _d_l_o_p_e_n() operation with a null pointer as the _f_i_l_e
       argument, dependency ordering is used by the _d_l_s_y_m() function. Load
       ordering is used in _d_l_s_y_m() operations upon the global symbol table
       handle.

       When an executable object file is first made accessible via _d_l_o_p_e_n(),
       it and its dependent executable object files are added in dependency
       order. Once all the executable object files are added, relocations are
       performed using load order. Note that if an executable object file or
       its dependencies had been previously loaded, the load and dependency
       orders may yield different resolutions.

       The symbols introduced by _d_l_o_p_e_n() operations and available through
       _d_l_s_y_m() are at a minimum those which are exported as identifiers of
       global scope by the executable object file. Typically, such identifiers
       shall be those that were specified in (for example) C source code as
       having eexxtteerrnn linkage. The precise manner in which an implementation
       constructs the set of exported symbols for an executable object file is
       implementation-defined.

RREETTUURRNN VVAALLUUEE
       Upon successful completion, _d_l_o_p_e_n() shall return a symbol table
       handle. If _f_i_l_e cannot be found, cannot be opened for reading, is not
       of an appropriate executable object file format for processing by
       _d_l_o_p_e_n(), or if an error occurs during the process of loading _f_i_l_e or
       relocating its symbolic references, _d_l_o_p_e_n() shall return a null
       pointer. More detailed diagnostic information shall be available
       through _d_l_e_r_r_o_r().

EERRRROORRSS
       No errors are defined.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       Refer to _d_l_s_y_m().

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       None.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _d_l_c_l_o_s_e(), _d_l_e_r_r_o_r(), _d_l_s_y_m()

       The Base Definitions volume of POSIX.1-2008, <<ddllffccnn..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                            DLOPEN(3)
