os/ossrv/genericopenlibs/openenvcore/include/dlfcn.dosc
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/** @file ../include/dlfcn.h
sl@0
     2
@internalComponent
sl@0
     3
*/
sl@0
     4
sl@0
     5
/** @fn  dlopen(const char *filename, int flag)
sl@0
     6
@param filename
sl@0
     7
@param flag
sl@0
     8
Note: This description also covers the following functions -
sl@0
     9
 dlsym()  dlerror()  dlclose() 
sl@0
    10
sl@0
    11
@code
sl@0
    12
 RTLD_LAZY In the current implementation this flag causes the external function names to be resolved
sl@0
    13
 prior to returning from dlopen.
sl@0
    14
 RTLD_NOW In the current implementation this flag causes the external function names to be resolved
sl@0
    15
 prior to returning from dlopen.
sl@0
    16
sl@0
    17
@endcode
sl@0
    18
@code
sl@0
    19
 RTLD_GLOBAL Symbols exported from this shared library object will not be available
sl@0
    20
 for the processing of relocation addresses of any other shared library object.
sl@0
    21
 RTLD_LOCAL Symbols exported from this shared library object will not be available
sl@0
    22
 for the processing of relocation of addresses in any other shared library object.
sl@0
    23
sl@0
    24
@endcode
sl@0
    25
  These functions provide interfaces to the services of the Symbian Loader 
sl@0
    26
Server. Operations are provided to load dynamic link libraries (DLLs) into the 
sl@0
    27
current process's address space, to obtain the address bindings of symbols 
sl@0
    28
exported by the DLLs, and to remove the DLLs from the process's address space 
sl@0
    29
when they are no longer required.
sl@0
    30
sl@0
    31
 The dlopen function loads the DLL specified in the filename argument and returns a descriptor if successful. The descriptor 
sl@0
    32
  returned can be used for later references to the DLL within the calls to dlsym and dlclose. The user side code should not attempt to modify or interpret 
sl@0
    33
  the value of the descriptor returned by dlopen.
sl@0
    34
sl@0
    35
 If the DLL specified by the filename argument is not in the address space prior to the call to dlopen, it is loaded into the address space. When the DLL is first 
sl@0
    36
  loaded into the address space constructors of the DLL's global objects 
sl@0
    37
  are invoked. If the DLL specified by the filename argument has already been placed in the process's address 
sl@0
    38
  space in a previous call to dlopen, invoking dlopen on the same DLL does not add it a second time, instead the 
sl@0
    39
  reference count of dlopen operations on that DLL is incremented. Invoking dlclose on the DLL handle decrements the reference count associated 
sl@0
    40
  with the DLL. When this reference count reaches zero, the DLL is unloaded from 
sl@0
    41
  the process address space. dlopen returns NULL if path argument is NULL.
sl@0
    42
sl@0
    43
 The mode parameter determines the type of operation performed by dlopen with respect to the symbol address relocations and the visibility 
sl@0
    44
  of the symbols to other shared libraries loaded by the process. The mode argument has the same effect regardless of its value: It is to 
sl@0
    45
  resolve all the external function references immediately within dlopen. This is because the external function references are bound 
sl@0
    46
  immediately by dlopen. For all practical purposes, therefore, the mode parameter's value is assumed to be RTLD_NOW ORed with RTLD_LOCAL. 
sl@0
    47
  Once a DLL is loaded into the address space, all the symbols exported by it 
sl@0
    48
  can only be accessed by specifying the handle associated with the DLL. The behaviour 
sl@0
    49
  is outlined below.
sl@0
    50
sl@0
    51
 mode must contain one of the following values, possibly ORed with additional 
sl@0
    52
  flags described below: RTLD_LAZY In the current implementation this flag causes the external function names to be resolved
sl@0
    53
prior to returning from dlopen. RTLD_NOW In the current implementation this flag causes the external function names to be resolved
sl@0
    54
prior to returning from dlopen.
sl@0
    55
sl@0
    56
 One of the following flags may be ORed into the mode argument: RTLD_GLOBAL Symbols exported from this shared library object will not be available
sl@0
    57
for the processing of relocation addresses of any other shared library object. RTLD_LOCAL Symbols exported from this shared library object will not be available
sl@0
    58
for the processing of relocation of addresses in any other shared library object.
sl@0
    59
sl@0
    60
 If path argument contains a slash character the entire argument is used 
sl@0
    61
  as the pathname for the file. C: is considered to be the root and C:\\ is prefixed 
sl@0
    62
  to the path argument to locate the shared library object. If path contains just the name of the shared library to be loaded, the 
sl@0
    63
  default location is sys\\bin. The string in the path argument is limited to a maximum of 256 characters.
sl@0
    64
sl@0
    65
 dlopen returns the handle for the dynamic library loaded into the address space
sl@0
    66
of the current process.
sl@0
    67
sl@0
    68
 dlsym function returns the address binding of the symbol associated 
sl@0
    69
  with the ordinal number. The NULL-terminated character string symbol contains the ordinal number (address lookup is based on ordinal 
sl@0
    70
  number). The symbols exported by shared DLLs added to the address space by dlopen can be accessed only through calls to dlsym.
sl@0
    71
sl@0
    72
 Symbol names per se are not searched. Instead dlsym locates the ordinal number corresponding to a symbol name and 
sl@0
    73
  returns the address of the memory location where the symbol is loaded. Ordinal 
sl@0
    74
  numbers therefore form the basis of the name lookup. Since all handles have 
sl@0
    75
  to be identified explicitly (that is, as returned by dlopen ), dlsym returns NULL when presented with special handles such as RTLD_NEXT, 
sl@0
    76
  RTLD_SELF and RTLD_DEFAULT. The implementation treats a NULL handle passed to dlsym as an error and returns NULL.
sl@0
    77
sl@0
    78
 The dlsym function returns a null pointer if the symbol (ordinal) cannot 
sl@0
    79
  be found and sets an error condition which may be queried with dlerror.
sl@0
    80
sl@0
    81
 The dlerror function
sl@0
    82
returns a null-terminated character string describing the last error that
sl@0
    83
occurred during a call to dlopen, dlsym,
sl@0
    84
or dlclose.
sl@0
    85
If no such error has occurred, dlerror returns a null pointer.
sl@0
    86
At each call to dlerror,
sl@0
    87
the error indication is reset.
sl@0
    88
Thus in the case of two calls
sl@0
    89
to dlerror,
sl@0
    90
where the second call follows the first immediately, the second call
sl@0
    91
will always return a null pointer.
sl@0
    92
sl@0
    93
 The dlclose function deletes a reference to the DLL referenced by handle. If the reference count drops to 0, the DLL is removed from the 
sl@0
    94
  address space and handle is rendered invalid. Just before removing the DLL from the current 
sl@0
    95
  process's address space the destructors of the DLL's global objects 
sl@0
    96
  are invoked. If dlclose is successful it returns 0. Otherwise it returns -1 and sets 
sl@0
    97
  an error condition that can be interrogated with dlerror.
sl@0
    98
sl@0
    99
sl@0
   100
sl@0
   101
Notes:
sl@0
   102
sl@0
   103
 The ordinal numbers associated with the functions in a DLL are in the DLL's 
sl@0
   104
.def file.
sl@0
   105
sl@0
   106
sl@0
   107
 
sl@0
   108
sl@0
   109
@publishedAll
sl@0
   110
@externallyDefinedApi
sl@0
   111
*/
sl@0
   112
sl@0
   113
/** @fn  dlsym(void *  handle, const char *  symbol)
sl@0
   114
@param handle
sl@0
   115
@param symbol
sl@0
   116
Refer to  dlopen() for the documentation
sl@0
   117
sl@0
   118
sl@0
   119
 
sl@0
   120
sl@0
   121
@publishedAll
sl@0
   122
@externallyDefinedApi
sl@0
   123
*/
sl@0
   124
sl@0
   125
sl@0
   126
/** @fn  dlerror(void)
sl@0
   127
sl@0
   128
Refer to  dlopen() for the documentation
sl@0
   129
sl@0
   130
sl@0
   131
 
sl@0
   132
sl@0
   133
@publishedAll
sl@0
   134
@externallyDefinedApi
sl@0
   135
*/
sl@0
   136
sl@0
   137
/** @fn  dlclose(void *handle)
sl@0
   138
@param handle
sl@0
   139
Refer to  dlopen() for the documentation
sl@0
   140
sl@0
   141
sl@0
   142
 
sl@0
   143
sl@0
   144
@publishedAll
sl@0
   145
@externallyDefinedApi
sl@0
   146
*/
sl@0
   147
sl@0
   148
sl@0
   149
sl@0
   150
/** @def RTLD_LAZY
sl@0
   151
sl@0
   152
Modes and flags for dlopen(). Bind function calls lazily. 
sl@0
   153
sl@0
   154
@publishedAll
sl@0
   155
@externallyDefinedApi
sl@0
   156
*/
sl@0
   157
sl@0
   158
sl@0
   159
/** @def RTLD_NOW
sl@0
   160
sl@0
   161
Modes and flags for dlopen(). Bind function calls immediately. 
sl@0
   162
sl@0
   163
@publishedAll
sl@0
   164
@externallyDefinedApi
sl@0
   165
*/
sl@0
   166
sl@0
   167
sl@0
   168
/** @def RTLD_GLOBAL
sl@0
   169
sl@0
   170
Modes and flags for dlopen(). Make symbols globally available.
sl@0
   171
sl@0
   172
@publishedAll
sl@0
   173
@externallyDefinedApi
sl@0
   174
*/
sl@0
   175
sl@0
   176
sl@0
   177
/** @def RTLD_LOCAL	
sl@0
   178
sl@0
   179
Modes and flags for dlopen(). Opposite of RTLD_GLOBAL, and the default. 
sl@0
   180
sl@0
   181
@publishedAll
sl@0
   182
@externallyDefinedApi
sl@0
   183
*/
sl@0
   184
sl@0
   185
sl@0
   186
/** @def RTLD_NEXT	
sl@0
   187
sl@0
   188
Special handle arguments for dlsym()/dlinfo(). Search subsequent objects.
sl@0
   189
sl@0
   190
@publishedAll
sl@0
   191
@released
sl@0
   192
*/
sl@0
   193
sl@0
   194
sl@0
   195
/** @def RTLD_DEFAULT	
sl@0
   196
sl@0
   197
Special handle arguments for dlsym()/dlinfo(). Use default search algorithm.
sl@0
   198
sl@0
   199
@publishedAll
sl@0
   200
@released
sl@0
   201
*/
sl@0
   202
sl@0
   203
sl@0
   204
/** @def RTLD_SELF	
sl@0
   205
sl@0
   206
Special handle arguments for dlsym()/dlinfo(). Search the caller itself.
sl@0
   207
sl@0
   208
@publishedAll
sl@0
   209
@released
sl@0
   210
*/
sl@0
   211
sl@0
   212