1645c4be3SJohn Polstra.\" This source code is a product of Sun Microsystems, Inc. and is provided 2645c4be3SJohn Polstra.\" for unrestricted use provided that this legend is included on all tape 3645c4be3SJohn Polstra.\" media and as a part of the software program in whole or part. Users 4645c4be3SJohn Polstra.\" may copy or modify this source code without charge, but are not authorized 5645c4be3SJohn Polstra.\" to license or distribute it to anyone else except as part of a product or 6645c4be3SJohn Polstra.\" program developed by the user. 7645c4be3SJohn Polstra.\" 8645c4be3SJohn Polstra.\" THIS PROGRAM CONTAINS SOURCE CODE COPYRIGHTED BY SUN MICROSYSTEMS, INC. 9645c4be3SJohn Polstra.\" SUN MICROSYSTEMS, INC., MAKES NO REPRESENTATIONS ABOUT THE SUITABLITY 10645c4be3SJohn Polstra.\" OF SUCH SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" WITHOUT 11645c4be3SJohn Polstra.\" EXPRESS OR IMPLIED WARRANTY OF ANY KIND. SUN MICROSYSTEMS, INC. DISCLAIMS 12645c4be3SJohn Polstra.\" ALL WARRANTIES WITH REGARD TO SUCH SOURCE CODE, INCLUDING ALL IMPLIED 13645c4be3SJohn Polstra.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN 14645c4be3SJohn Polstra.\" NO EVENT SHALL SUN MICROSYSTEMS, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT, 15645c4be3SJohn Polstra.\" INCIDENTAL, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 16645c4be3SJohn Polstra.\" FROM USE OF SUCH SOURCE CODE, REGARDLESS OF THE THEORY OF LIABILITY. 17645c4be3SJohn Polstra.\" 18645c4be3SJohn Polstra.\" This source code is provided with no support and without any obligation on 19645c4be3SJohn Polstra.\" the part of Sun Microsystems, Inc. to assist in its use, correction, 20645c4be3SJohn Polstra.\" modification or enhancement. 21645c4be3SJohn Polstra.\" 22645c4be3SJohn Polstra.\" SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 23645c4be3SJohn Polstra.\" INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS 24645c4be3SJohn Polstra.\" SOURCE CODE OR ANY PART THEREOF. 25645c4be3SJohn Polstra.\" 26645c4be3SJohn Polstra.\" Sun Microsystems, Inc. 27645c4be3SJohn Polstra.\" 2550 Garcia Avenue 28645c4be3SJohn Polstra.\" Mountain View, California 94043 29645c4be3SJohn Polstra.\" 30645c4be3SJohn Polstra.\" Copyright (c) 1991 Sun Microsystems, Inc. 31645c4be3SJohn Polstra.\" 32645c4be3SJohn Polstra.\" @(#) dlopen.3 1.6 90/01/31 SMI 337f3dea24SPeter Wemm.\" $FreeBSD$ 34fbc400a6SNik Clayton.\" 35*2f1a2bdfSRomain Tartière.Dd January 2, 2019 36645c4be3SJohn Polstra.Dt DLOPEN 3 37aa12cea2SUlrich Spörlein.Os 38645c4be3SJohn Polstra.Sh NAME 397ec37597SAlexey Zelkin.Nm dlopen , 405d8aec9cSKonstantin Belousov.Nm fdlopen , 417ec37597SAlexey Zelkin.Nm dlsym , 42*2f1a2bdfSRomain Tartière.Nm dlvsym , 437ec37597SAlexey Zelkin.Nm dlfunc , 447ec37597SAlexey Zelkin.Nm dlerror , 457ec37597SAlexey Zelkin.Nm dlclose 46645c4be3SJohn Polstra.Nd programmatic interface to the dynamic linker 4725bb73e0SAlexey Zelkin.Sh LIBRARY 4825bb73e0SAlexey Zelkin.Lb libc 49645c4be3SJohn Polstra.Sh SYNOPSIS 5032eef9aeSRuslan Ermilov.In dlfcn.h 51645c4be3SJohn Polstra.Ft void * 52645c4be3SJohn Polstra.Fn dlopen "const char *path" "int mode" 53645c4be3SJohn Polstra.Ft void * 545d8aec9cSKonstantin Belousov.Fn fdlopen "int fd" "int mode" 555d8aec9cSKonstantin Belousov.Ft void * 56a4a96c81SMike Barcroft.Fn dlsym "void * restrict handle" "const char * restrict symbol" 57*2f1a2bdfSRomain Tartière.Ft void * 58*2f1a2bdfSRomain Tartière.Fn dlvsym "void * restrict handle" "const char * restrict symbol" "const char * restrict version" 59fda23019SGarrett Wollman.Ft dlfunc_t 60a4a96c81SMike Barcroft.Fn dlfunc "void * restrict handle" "const char * restrict symbol" 61071ab531SPietro Cerutti.Ft char * 62645c4be3SJohn Polstra.Fn dlerror "void" 63645c4be3SJohn Polstra.Ft int 64645c4be3SJohn Polstra.Fn dlclose "void *handle" 65645c4be3SJohn Polstra.Sh DESCRIPTION 66645c4be3SJohn PolstraThese functions provide a simple programmatic interface to the services of the 67645c4be3SJohn Polstradynamic linker. 68645c4be3SJohn PolstraOperations are provided to add new shared objects to a 69645c4be3SJohn Polstraprogram's address space, to obtain the address bindings of symbols 70645c4be3SJohn Polstradefined by such 71645c4be3SJohn Polstraobjects, and to remove such objects when their use is no longer required. 72645c4be3SJohn Polstra.Pp 7395f4226bSRuslan ErmilovThe 74645c4be3SJohn Polstra.Fn dlopen 7595f4226bSRuslan Ermilovfunction 76645c4be3SJohn Polstraprovides access to the shared object in 77645c4be3SJohn Polstra.Fa path , 78645c4be3SJohn Polstrareturning a descriptor that can be used for later 79645c4be3SJohn Polstrareferences to the object in calls to 80*2f1a2bdfSRomain Tartière.Fn dlsym , 81*2f1a2bdfSRomain Tartière.Fn dlvsym 82645c4be3SJohn Polstraand 83645c4be3SJohn Polstra.Fn dlclose . 84645c4be3SJohn PolstraIf 85645c4be3SJohn Polstra.Fa path 86645c4be3SJohn Polstrawas not in the address space prior to the call to 87645c4be3SJohn Polstra.Fn dlopen , 88645c4be3SJohn Polstrait is placed in the address space. 89645c4be3SJohn PolstraWhen an object is first loaded into the address space in this way, its 90645c4be3SJohn Polstrafunction 91645c4be3SJohn Polstra.Fn _init , 92645c4be3SJohn Polstraif any, is called by the dynamic linker. 93645c4be3SJohn PolstraIf 94645c4be3SJohn Polstra.Fa path 95645c4be3SJohn Polstrahas already been placed in the address space in a previous call to 96645c4be3SJohn Polstra.Fn dlopen , 97645c4be3SJohn Polstrait is not added a second time, although a reference count of 98645c4be3SJohn Polstra.Fn dlopen 99645c4be3SJohn Polstraoperations on 100645c4be3SJohn Polstra.Fa path 101645c4be3SJohn Polstrais maintained. 102645c4be3SJohn PolstraA null pointer supplied for 103645c4be3SJohn Polstra.Fa path 104645c4be3SJohn Polstrais interpreted as a reference to the main 105645c4be3SJohn Polstraexecutable of the process. 1062efeeba5SRuslan ErmilovThe 107645c4be3SJohn Polstra.Fa mode 1082efeeba5SRuslan Ermilovargument 109645c4be3SJohn Polstracontrols the way in which external function references from the 110645c4be3SJohn Polstraloaded object are bound to their referents. 11107f643a5SJohn PolstraIt must contain one of the following values, possibly ORed with 11207f643a5SJohn Polstraadditional flags which will be described subsequently: 113645c4be3SJohn Polstra.Bl -tag -width RTLD_LAZYX 114645c4be3SJohn Polstra.It Dv RTLD_LAZY 115645c4be3SJohn PolstraEach external function reference is resolved when the function is first 116645c4be3SJohn Polstracalled. 117645c4be3SJohn Polstra.It Dv RTLD_NOW 118645c4be3SJohn PolstraAll external function references are bound immediately by 119645c4be3SJohn Polstra.Fn dlopen . 120645c4be3SJohn Polstra.El 121645c4be3SJohn Polstra.Pp 122645c4be3SJohn Polstra.Dv RTLD_LAZY 123645c4be3SJohn Polstrais normally preferred, for reasons of efficiency. 124645c4be3SJohn PolstraHowever, 125645c4be3SJohn Polstra.Dv RTLD_NOW 126645c4be3SJohn Polstrais useful to ensure that any undefined symbols are discovered during the 127645c4be3SJohn Polstracall to 128645c4be3SJohn Polstra.Fn dlopen . 12907f643a5SJohn Polstra.Pp 13007f643a5SJohn PolstraOne of the following flags may be ORed into the 13107f643a5SJohn Polstra.Fa mode 13207f643a5SJohn Polstraargument: 133b2e4ce45SKonstantin Belousov.Bl -tag -width RTLD_NODELETE 13407f643a5SJohn Polstra.It Dv RTLD_GLOBAL 13507f643a5SJohn PolstraSymbols from this shared object and its directed acyclic graph (DAG) 13607f643a5SJohn Polstraof needed objects will be available for resolving undefined references 13707f643a5SJohn Polstrafrom all other shared objects. 13807f643a5SJohn Polstra.It Dv RTLD_LOCAL 13907f643a5SJohn PolstraSymbols in this shared object and its DAG of needed objects will be 14007f643a5SJohn Polstraavailable for resolving undefined references only from other objects 141760d9686SRuslan Ermilovin the same DAG. 142760d9686SRuslan ErmilovThis is the default, but it may be specified 14307f643a5SJohn Polstraexplicitly with this flag. 144c6de4ce7SMaxim Sobolev.It Dv RTLD_TRACE 145c6de4ce7SMaxim SobolevWhen set, causes dynamic linker to exit after loading all objects 146c6de4ce7SMaxim Sobolevneeded by this shared object and printing a summary which includes 147c6de4ce7SMaxim Sobolevthe absolute pathnames of all objects, to standard output. 148c6de4ce7SMaxim SobolevWith this flag 149c6de4ce7SMaxim Sobolev.Fn dlopen 150c6de4ce7SMaxim Sobolevwill return to the caller only in the case of error. 151b2e4ce45SKonstantin Belousov.It Dv RTLD_NODELETE 152b2e4ce45SKonstantin BelousovPrevents unload of the loaded object on 153b2e4ce45SKonstantin Belousov.Fn dlclose . 154b2e4ce45SKonstantin BelousovThe same behaviour may be requested by 155b2e4ce45SKonstantin Belousov.Fl "z nodelete" 156b2e4ce45SKonstantin Belousovoption of the static linker 157b2e4ce45SKonstantin Belousov.Xr ld 1 . 15849e8c06bSKonstantin Belousov.It Dv RTLD_NOLOAD 159c2025a76SJoel DahlOnly return valid handle for the object if it is already loaded in 16049e8c06bSKonstantin Belousovthe process address space, otherwise 16149e8c06bSKonstantin Belousov.Dv NULL 16249e8c06bSKonstantin Belousovis returned. 16349e8c06bSKonstantin BelousovOther mode flags may be specified, which will be applied for promotion 16449e8c06bSKonstantin Belousovfor the found object. 16507f643a5SJohn Polstra.El 16607f643a5SJohn Polstra.Pp 167645c4be3SJohn PolstraIf 168645c4be3SJohn Polstra.Fn dlopen 169645c4be3SJohn Polstrafails, it returns a null pointer, and sets an error condition which may 170645c4be3SJohn Polstrabe interrogated with 171645c4be3SJohn Polstra.Fn dlerror . 172645c4be3SJohn Polstra.Pp 17395f4226bSRuslan ErmilovThe 1745d8aec9cSKonstantin Belousov.Fn fdlopen 1755d8aec9cSKonstantin Belousovfunction is similar to 1765d8aec9cSKonstantin Belousov.Fn dlopen , 1775d8aec9cSKonstantin Belousovbut it takes the file descriptor argument 1785d8aec9cSKonstantin Belousov.Fa fd , 1795d8aec9cSKonstantin Belousovwhich is used for the file operations needed to load an object 1805d8aec9cSKonstantin Belousovinto the address space. 1815d8aec9cSKonstantin BelousovThe file descriptor 1825d8aec9cSKonstantin Belousov.Fa fd 1835d8aec9cSKonstantin Belousovis not closed by the function regardless a result of execution, 1845d8aec9cSKonstantin Belousovbut a duplicate of the file descriptor is. 1855d8aec9cSKonstantin BelousovThis may be important if a 1865d8aec9cSKonstantin Belousov.Xr lockf 3 1875d8aec9cSKonstantin Belousovlock is held on the passed descriptor. 1885d8aec9cSKonstantin BelousovThe 1895d8aec9cSKonstantin Belousov.Fa fd 1905d8aec9cSKonstantin Belousovargument -1 is interpreted as a reference to the main 1915d8aec9cSKonstantin Belousovexecutable of the process, similar to 1925d8aec9cSKonstantin Belousov.Va NULL 1935d8aec9cSKonstantin Belousovvalue for the 1945d8aec9cSKonstantin Belousov.Fa name 1955d8aec9cSKonstantin Belousovargument to 1965d8aec9cSKonstantin Belousov.Fn dlopen . 1975d8aec9cSKonstantin BelousovThe 1985d8aec9cSKonstantin Belousov.Fn fdlopen 1995d8aec9cSKonstantin Belousovfunction can be used by the code that needs to perform 2005d8aec9cSKonstantin Belousovadditional checks on the loaded objects, to prevent races with 2015d8aec9cSKonstantin Belousovsymlinking or renames. 2025d8aec9cSKonstantin Belousov.Pp 2035d8aec9cSKonstantin BelousovThe 204645c4be3SJohn Polstra.Fn dlsym 20595f4226bSRuslan Ermilovfunction 206645c4be3SJohn Polstrareturns the address binding of the symbol described in the null-terminated 207645c4be3SJohn Polstracharacter string 208645c4be3SJohn Polstra.Fa symbol , 209645c4be3SJohn Polstraas it occurs in the shared object identified by 210645c4be3SJohn Polstra.Fa handle . 211645c4be3SJohn PolstraThe symbols exported by objects added to the address space by 212645c4be3SJohn Polstra.Fn dlopen 213645c4be3SJohn Polstracan be accessed only through calls to 214645c4be3SJohn Polstra.Fn dlsym . 215645c4be3SJohn PolstraSuch symbols do not supersede any definition of those symbols already present 216645c4be3SJohn Polstrain the address space when the object is loaded, nor are they available to 217645c4be3SJohn Polstrasatisfy normal dynamic linking references. 2187f244df8SJohn Polstra.Pp 2197f244df8SJohn PolstraIf 2207f244df8SJohn Polstra.Fn dlsym 2217f244df8SJohn Polstrais called with the special 222645c4be3SJohn Polstra.Fa handle 2237f244df8SJohn Polstra.Dv NULL , 2247f244df8SJohn Polstrait is interpreted as a reference to the executable or shared object 2257f244df8SJohn Polstrafrom which the call 226760d9686SRuslan Ermilovis being made. 227760d9686SRuslan ErmilovThus a shared object can reference its own symbols. 2287f244df8SJohn Polstra.Pp 2297f244df8SJohn PolstraIf 230645c4be3SJohn Polstra.Fn dlsym 2317f244df8SJohn Polstrais called with the special 2327f244df8SJohn Polstra.Fa handle 2337f244df8SJohn Polstra.Dv RTLD_DEFAULT , 2347f244df8SJohn Polstrathe search for the symbol follows the algorithm used for resolving 235760d9686SRuslan Ermilovundefined symbols when objects are loaded. 236760d9686SRuslan ErmilovThe objects searched are 2377f244df8SJohn Polstraas follows, in the given order: 2387f244df8SJohn Polstra.Bl -enum 2397f244df8SJohn Polstra.It 2407f244df8SJohn PolstraThe referencing object itself (or the object from which the call to 2417f244df8SJohn Polstra.Fn dlsym 2427f244df8SJohn Polstrais made), if that object was linked using the 243dac0a538STijl Coosemans.Fl Bsymbolic 2447f244df8SJohn Polstraoption to 2457f244df8SJohn Polstra.Xr ld 1 . 2467f244df8SJohn Polstra.It 2477f244df8SJohn PolstraAll objects loaded at program start-up. 2487f244df8SJohn Polstra.It 2497f244df8SJohn PolstraAll objects loaded via 2507f244df8SJohn Polstra.Fn dlopen 2517f244df8SJohn Polstrawith the 2527f244df8SJohn Polstra.Dv RTLD_GLOBAL 2537f244df8SJohn Polstraflag set in the 2547f244df8SJohn Polstra.Fa mode 2557f244df8SJohn Polstraargument. 256c56864a7SPeter Pentchev.It 257c56864a7SPeter PentchevAll objects loaded via 258c56864a7SPeter Pentchev.Fn dlopen 259c56864a7SPeter Pentchevwhich are in needed-object DAGs that also contain the referencing object. 2607f244df8SJohn Polstra.El 261645c4be3SJohn Polstra.Pp 262645c4be3SJohn PolstraIf 263645c4be3SJohn Polstra.Fn dlsym 264645c4be3SJohn Polstrais called with the special 265645c4be3SJohn Polstra.Fa handle 266645c4be3SJohn Polstra.Dv RTLD_NEXT , 267645c4be3SJohn Polstrathen the search for the symbol is limited to the shared objects 268645c4be3SJohn Polstrawhich were loaded after the one issuing the call to 269645c4be3SJohn Polstra.Fn dlsym . 270645c4be3SJohn PolstraThus, if the function is called from the main program, all 271645c4be3SJohn Polstrathe shared libraries are searched. 272645c4be3SJohn PolstraIf it is called from a shared library, all subsequent shared 273645c4be3SJohn Polstralibraries are searched. 274645c4be3SJohn Polstra.Dv RTLD_NEXT 275645c4be3SJohn Polstrais useful for implementing wrappers around library functions. 276645c4be3SJohn PolstraFor example, a wrapper function 277645c4be3SJohn Polstra.Fn getpid 278645c4be3SJohn Polstracould access the 279645c4be3SJohn Polstra.Dq real 280645c4be3SJohn Polstra.Fn getpid 281645c4be3SJohn Polstrawith 282c786c636SJoerg Wunsch.Li dlsym(RTLD_NEXT, \&"getpid\&") . 283dc12134aSGarrett Wollman(Actually, the 284dc12134aSGarrett Wollman.Fn dlfunc 285dc12134aSGarrett Wollmaninterface, below, should be used, since 286dc12134aSGarrett Wollman.Fn getpid 287dc12134aSGarrett Wollmanis a function and not a data object.) 288645c4be3SJohn Polstra.Pp 2897ec37597SAlexey ZelkinIf 2907ec37597SAlexey Zelkin.Fn dlsym 2917ec37597SAlexey Zelkinis called with the special 2927ec37597SAlexey Zelkin.Fa handle 2937ec37597SAlexey Zelkin.Dv RTLD_SELF , 2947ec37597SAlexey Zelkinthen the search for the symbol is limited to the shared object 2957ec37597SAlexey Zelkinissuing the call to 2967ec37597SAlexey Zelkin.Fn dlsym 2977ec37597SAlexey Zelkinand those shared objects which were loaded after it. 2987ec37597SAlexey Zelkin.Pp 29995f4226bSRuslan ErmilovThe 3007f244df8SJohn Polstra.Fn dlsym 30195f4226bSRuslan Ermilovfunction 3027f244df8SJohn Polstrareturns a null pointer if the symbol cannot be found, and sets an error 3037f244df8SJohn Polstracondition which may be queried with 3047f244df8SJohn Polstra.Fn dlerror . 3057f244df8SJohn Polstra.Pp 30695f4226bSRuslan ErmilovThe 307*2f1a2bdfSRomain Tartière.Fn dlvsym 308*2f1a2bdfSRomain Tartièrefunction behaves like 309*2f1a2bdfSRomain Tartière.Fn dlsym , 310*2f1a2bdfSRomain Tartièrebut takes an extra argument 311*2f1a2bdfSRomain Tartière.Fa version : 312*2f1a2bdfSRomain Tartièrea null-terminated character string which is used to request a specific version 313*2f1a2bdfSRomain Tartièreof 314*2f1a2bdfSRomain Tartière.Fa symbol . 315*2f1a2bdfSRomain Tartière.Pp 316*2f1a2bdfSRomain TartièreThe 317dc12134aSGarrett Wollman.Fn dlfunc 31895f4226bSRuslan Ermilovfunction 319dc12134aSGarrett Wollmanimplements all of the behavior of 320dc12134aSGarrett Wollman.Fn dlsym , 321dc12134aSGarrett Wollmanbut has a return type which can be cast to a function pointer without 322dc12134aSGarrett Wollmantriggering compiler diagnostics. 32395f4226bSRuslan Ermilov(The 32495f4226bSRuslan Ermilov.Fn dlsym 32595f4226bSRuslan Ermilovfunction 326dc12134aSGarrett Wollmanreturns a data pointer; in the C standard, conversions between 327760d9686SRuslan Ermilovdata and function pointer types are undefined. 328760d9686SRuslan ErmilovSome compilers and 329dc12134aSGarrett Wollman.Xr lint 1 330760d9686SRuslan Ermilovutilities warn about such casts.) 331dc12134aSGarrett WollmanThe precise return type of 332dc12134aSGarrett Wollman.Fn dlfunc 333dc12134aSGarrett Wollmanis unspecified; applications must cast it to an appropriate function pointer 334dc12134aSGarrett Wollmantype. 335dc12134aSGarrett Wollman.Pp 33695f4226bSRuslan ErmilovThe 337645c4be3SJohn Polstra.Fn dlerror 33895f4226bSRuslan Ermilovfunction 339645c4be3SJohn Polstrareturns a null-terminated character string describing the last error that 340645c4be3SJohn Polstraoccurred during a call to 341645c4be3SJohn Polstra.Fn dlopen , 342e8598335SAlexey Zelkin.Fn dladdr , 343e8598335SAlexey Zelkin.Fn dlinfo , 344645c4be3SJohn Polstra.Fn dlsym , 345*2f1a2bdfSRomain Tartière.Fn dlvsym , 346dc12134aSGarrett Wollman.Fn dlfunc , 347645c4be3SJohn Polstraor 348645c4be3SJohn Polstra.Fn dlclose . 349645c4be3SJohn PolstraIf no such error has occurred, 350645c4be3SJohn Polstra.Fn dlerror 351645c4be3SJohn Polstrareturns a null pointer. 352645c4be3SJohn PolstraAt each call to 353645c4be3SJohn Polstra.Fn dlerror , 354760d9686SRuslan Ermilovthe error indication is reset. 355760d9686SRuslan ErmilovThus in the case of two calls 356645c4be3SJohn Polstrato 357645c4be3SJohn Polstra.Fn dlerror , 358645c4be3SJohn Polstrawhere the second call follows the first immediately, the second call 359645c4be3SJohn Polstrawill always return a null pointer. 360645c4be3SJohn Polstra.Pp 36195f4226bSRuslan ErmilovThe 362645c4be3SJohn Polstra.Fn dlclose 36395f4226bSRuslan Ermilovfunction 364645c4be3SJohn Polstradeletes a reference to the shared object referenced by 365645c4be3SJohn Polstra.Fa handle . 366645c4be3SJohn PolstraIf the reference count drops to 0, the object is removed from the 367645c4be3SJohn Polstraaddress space, and 368645c4be3SJohn Polstra.Fa handle 369645c4be3SJohn Polstrais rendered invalid. 370645c4be3SJohn PolstraJust before removing a shared object in this way, the dynamic linker 371645c4be3SJohn Polstracalls the object's 372645c4be3SJohn Polstra.Fn _fini 373645c4be3SJohn Polstrafunction, if such a function is defined by the object. 374645c4be3SJohn PolstraIf 375645c4be3SJohn Polstra.Fn dlclose 376645c4be3SJohn Polstrais successful, it returns a value of 0. 377645c4be3SJohn PolstraOtherwise it returns -1, and sets an error condition that can be 378645c4be3SJohn Polstrainterrogated with 379645c4be3SJohn Polstra.Fn dlerror . 380645c4be3SJohn Polstra.Pp 381645c4be3SJohn PolstraThe object-intrinsic functions 382645c4be3SJohn Polstra.Fn _init 383645c4be3SJohn Polstraand 384645c4be3SJohn Polstra.Fn _fini 385645c4be3SJohn Polstraare called with no arguments, and are not expected to return values. 386f28529d7SJoseph Koshy.Sh NOTES 387f28529d7SJoseph KoshyELF executables need to be linked 388f28529d7SJoseph Koshyusing the 389f28529d7SJoseph Koshy.Fl export-dynamic 390f28529d7SJoseph Koshyoption to 391f28529d7SJoseph Koshy.Xr ld 1 392f28529d7SJoseph Koshyfor symbols defined in the executable to become visible to 393*2f1a2bdfSRomain Tartière.Fn dlsym , 394*2f1a2bdfSRomain Tartière.Fn dlvsym 395*2f1a2bdfSRomain Tartièreor 396*2f1a2bdfSRomain Tartière.Fn dlfunc 397c786c636SJoerg Wunsch.Pp 39899ac8154SKonstantin BelousovOther ELF platforms require linking with 39999ac8154SKonstantin Belousov.Lb libdl 40099ac8154SKonstantin Belousovto provide 40199ac8154SKonstantin Belousov.Fn dlopen 40299ac8154SKonstantin Belousovand other functions. 40399ac8154SKonstantin Belousov.Fx 40499ac8154SKonstantin Belousovdoes not require linking with the library, but supports it for compatibility. 40599ac8154SKonstantin Belousov.Pp 406c786c636SJoerg WunschIn previous implementations, it was necessary to prepend an underscore 407c786c636SJoerg Wunschto all external symbols in order to gain symbol 408760d9686SRuslan Ermilovcompatibility with object code compiled from the C language. 409760d9686SRuslan ErmilovThis is 410c786c636SJoerg Wunschstill the case when using the (obsolete) 411c786c636SJoerg Wunsch.Fl aout 412c786c636SJoerg Wunschoption to the C language compiler. 413645c4be3SJohn Polstra.Sh ERRORS 41495f4226bSRuslan ErmilovThe 415dc12134aSGarrett Wollman.Fn dlopen , 4165d8aec9cSKonstantin Belousov.Fn fdlopen , 417dc12134aSGarrett Wollman.Fn dlsym , 418*2f1a2bdfSRomain Tartière.Fn dlvsym , 419645c4be3SJohn Polstraand 420dc12134aSGarrett Wollman.Fn dlfunc 42195f4226bSRuslan Ermilovfunctions 422dc12134aSGarrett Wollmanreturn a null pointer in the event of errors. 42395f4226bSRuslan ErmilovThe 424645c4be3SJohn Polstra.Fn dlclose 42595f4226bSRuslan Ermilovfunction 426645c4be3SJohn Polstrareturns 0 on success, or -1 if an error occurred. 427645c4be3SJohn PolstraWhenever an error has been detected, a message detailing it can be 428645c4be3SJohn Polstraretrieved via a call to 429645c4be3SJohn Polstra.Fn dlerror . 430645c4be3SJohn Polstra.Sh SEE ALSO 431645c4be3SJohn Polstra.Xr ld 1 , 432645c4be3SJohn Polstra.Xr rtld 1 , 4334088069cSDima Dorfman.Xr dladdr 3 , 4347ec37597SAlexey Zelkin.Xr dlinfo 3 , 435645c4be3SJohn Polstra.Xr link 5 436