1DLOPEN(3P)                 POSIX Programmer's Manual                DLOPEN(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       dlopen — open a symbol table handle
14

SYNOPSIS

16       #include <dlfcn.h>
17
18       void *dlopen(const char *file, int mode);
19

DESCRIPTION

21       The dlopen() function shall make the symbols (function identifiers  and
22       data  object  identifiers)  in  the executable object file specified by
23       file available to the calling program.
24
25       The class of executable object files eligible for  this  operation  and
26       the  manner  of  their  construction are implementation-defined, though
27       typically such files are shared libraries or programs.
28
29       Implementations may permit the construction of embedded dependencies in
30       executable object files. In such cases, a dlopen() operation shall load
31       those dependencies in addition to the executable object file  specified
32       by  file.   Implementations may also impose specific constraints on the
33       construction of programs that can employ dlopen() and its related  ser‐
34       vices.
35
36       A  successful  dlopen()  shall  return  a symbol table handle which the
37       caller may use on subsequent calls to dlsym() and dlclose().
38
39       The value of this symbol table handle should not be interpreted in  any
40       way by the caller.
41
42       The  file  argument  is  used to construct a pathname to the executable
43       object file. If file contains a <slash> character, the file argument is
44       used as the pathname for the file. Otherwise, file is used in an imple‐
45       mentation-defined manner to yield a pathname.
46
47       If file is a null pointer, dlopen() shall return a global symbol  table
48       handle  for the currently running process image. This symbol table han‐
49       dle shall provide access to the symbols from an  ordered  set  of  exe‐
50       cutable object files consisting of the original program image file, any
51       executable object files loaded at program start-up as specified by that
52       process file (for example, shared libraries), and the set of executable
53       object files loaded using  dlopen()  operations  with  the  RTLD_GLOBAL
54       flag.  As  the  latter set of executable object files can change during
55       execution, the set of symbols made available by this symbol table  han‐
56       dle can also change dynamically.
57
58       Only  a  single copy of an executable object file shall be brought into
59       the address space, even if dlopen() is invoked multiple times in refer‐
60       ence to the executable object file, and even if different pathnames are
61       used to reference the executable object file.
62
63       The mode parameter describes how dlopen() shall operate upon file  with
64       respect to the processing of relocations and the scope of visibility of
65       the symbols provided within file.  When an executable  object  file  is
66       brought  into the address space of a process, it may contain references
67       to symbols whose addresses are not known until  the  executable  object
68       file is loaded.
69
70       These references shall be relocated before the symbols can be accessed.
71       The mode parameter governs when these relocations take  place  and  may
72       have the following values:
73
74       RTLD_LAZY   Relocations shall be performed at an implementation-defined
75                   time, ranging from the time of the dlopen() call until  the
76                   first  reference  to  a  given  symbol  occurs.  Specifying
77                   RTLD_LAZY should  improve  performance  on  implementations
78                   supporting dynamic symbol binding since a process might not
79                   reference all of the symbols in an executable object  file.
80                   And,  for  systems supporting dynamic symbol resolution for
81                   normal process execution, this behavior mimics  the  normal
82                   handling of process execution.
83
84       RTLD_NOW    All  necessary relocations shall be performed when the exe‐
85                   cutable object file is first loaded. This  may  waste  some
86                   processing  if  relocations  are performed for symbols that
87                   are never referenced.  This  behavior  may  be  useful  for
88                   applications  that need to know that all symbols referenced
89                   during execution will be available before dlopen() returns.
90
91       Any executable object file loaded by dlopen() that requires relocations
92       against  global  symbols  can  reference  the  symbols  in the original
93       process image file, any  executable  object  files  loaded  at  program
94       start-up,  from  the  initial process image itself, from any other exe‐
95       cutable object file included in the same dlopen() invocation,  and  any
96       executable object files that were loaded in any dlopen() invocation and
97       which specified the RTLD_GLOBAL flag. To determine the scope  of  visi‐
98       bility  for  the  symbols  loaded  with a dlopen() invocation, the mode
99       parameter should be a bitwise-inclusive OR with one  of  the  following
100       values:
101
102       RTLD_GLOBAL The  executable  object file's symbols shall be made avail‐
103                   able for relocation  processing  of  any  other  executable
104                   object    file.    In   addition,   symbol   lookup   using
105                   dlopen(NULL,mode) and an  associated  dlsym()  allows  exe‐
106                   cutable object files loaded with this mode to be searched.
107
108       RTLD_LOCAL  The  executable  object  file's  symbols  shall not be made
109                   available for relocation processing of any other executable
110                   object file.
111
112       If  neither RTLD_GLOBAL nor RTLD_LOCAL is specified, the default behav‐
113       ior is unspecified.
114
115       If an executable object file is specified in multiple dlopen()  invoca‐
116       tions, mode is interpreted at each invocation.
117
118       If  RTLD_NOW  has  been specified, all relocations shall have been com‐
119       pleted rendering further RTLD_NOW operations redundant and any  further
120       RTLD_LAZY operations irrelevant.
121
122       If  RTLD_GLOBAL  has  been  specified, the executable object file shall
123       maintain the RTLD_GLOBAL status regardless of any  previous  or  future
124       specification  of  RTLD_LOCAL,  as  long  as the executable object file
125       remains in the address space (see dlclose()).
126
127       Symbols introduced into the process image through calls to dlopen() may
128       be  used  in relocation activities. Symbols so introduced may duplicate
129       symbols already defined by the program or previous dlopen() operations.
130       To  resolve the ambiguities such a situation might present, the resolu‐
131       tion of a symbol reference to symbol definition is based  on  a  symbol
132       resolution  order.  Two  such resolution orders are defined: load order
133       and dependency order. Load order establishes an ordering  among  symbol
134       definitions,  such  that the first definition loaded (including defini‐
135       tions from the process image file and any dependent  executable  object
136       files  loaded  with it) has priority over executable object files added
137       later (by dlopen()).  Load ordering is used in  relocation  processing.
138       Dependency  ordering  uses  a breadth-first order starting with a given
139       executable object file, then all of its dependencies, then  any  depen‐
140       dents  of  those,  iterating until all dependencies are satisfied. With
141       the exception of the global symbol table handle obtained via a dlopen()
142       operation with a null pointer as the file argument, dependency ordering
143       is used by the dlsym() function. Load ordering is used in dlsym() oper‐
144       ations upon the global symbol table handle.
145
146       When  an  executable object file is first made accessible via dlopen(),
147       it and its dependent executable object files are  added  in  dependency
148       order.  Once all the executable object files are added, relocations are
149       performed using load order. Note that if an executable object  file  or
150       its  dependencies  had  been previously loaded, the load and dependency
151       orders may yield different resolutions.
152
153       The symbols introduced by dlopen()  operations  and  available  through
154       dlsym()  are  at  a  minimum those which are exported as identifiers of
155       global scope by the executable object file. Typically, such identifiers
156       shall  be  those  that were specified in (for example) C source code as
157       having extern linkage. The precise manner in  which  an  implementation
158       constructs the set of exported symbols for an executable object file is
159       implementation-defined.
160

RETURN VALUE

162       Upon successful completion, dlopen() shall return a symbol  table  han‐
163       dle.  If  file cannot be found, cannot be opened for reading, is not of
164       an  appropriate  executable  object  file  format  for  processing   by
165       dlopen(),  or  if an error occurs during the process of loading file or
166       relocating its  symbolic  references,  dlopen()  shall  return  a  null
167       pointer.  More  detailed  diagnostic  information  shall  be  available
168       through dlerror().
169

ERRORS

171       No errors are defined.
172
173       The following sections are informative.
174

EXAMPLES

176       Refer to dlsym().
177

APPLICATION USAGE

179       None.
180

RATIONALE

182       None.
183

FUTURE DIRECTIONS

185       None.
186

SEE ALSO

188       dlclose(), dlerror(), dlsym()
189
190       The Base Definitions volume of POSIX.1‐2008, <dlfcn.h>
191
193       Portions of this text are reprinted and reproduced in  electronic  form
194       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
195       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
196       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
197       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
198       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
199       event of any discrepancy between this version and the original IEEE and
200       The  Open Group Standard, the original IEEE and The Open Group Standard
201       is the referee document. The original Standard can be  obtained  online
202       at http://www.unix.org/online.html .
203
204       Any  typographical  or  formatting  errors that appear in this page are
205       most likely to have been introduced during the conversion of the source
206       files  to  man page format. To report such errors, see https://www.ker
207       nel.org/doc/man-pages/reporting_bugs.html .
208
209
210
211IEEE/The Open Group                  2013                           DLOPEN(3P)
Impressum