1*c1d0be48Stb /* $OpenBSD: dlfcn.h,v 1.16 2022/08/20 17:39:22 tb Exp $ */ 2df930be7Sderaadt /* $NetBSD: dlfcn.h,v 1.2 1995/06/05 19:38:00 pk Exp $ */ 3df930be7Sderaadt 4df930be7Sderaadt /* 5df930be7Sderaadt * Copyright (c) 1995 Paul Kranenburg 6df930be7Sderaadt * All rights reserved. 7df930be7Sderaadt * 8df930be7Sderaadt * Redistribution and use in source and binary forms, with or without 9df930be7Sderaadt * modification, are permitted provided that the following conditions 10df930be7Sderaadt * are met: 11df930be7Sderaadt * 1. Redistributions of source code must retain the above copyright 12df930be7Sderaadt * notice, this list of conditions and the following disclaimer. 13df930be7Sderaadt * 2. Redistributions in binary form must reproduce the above copyright 14df930be7Sderaadt * notice, this list of conditions and the following disclaimer in the 15df930be7Sderaadt * documentation and/or other materials provided with the distribution. 16df930be7Sderaadt * 3. All advertising materials mentioning features or use of this software 17df930be7Sderaadt * must display the following acknowledgement: 18df930be7Sderaadt * This product includes software developed by Paul Kranenburg. 19df930be7Sderaadt * 4. The name of the author may not be used to endorse or promote products 2047369814Sderaadt * derived from this software without specific prior written permission 21df930be7Sderaadt * 22df930be7Sderaadt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 23df930be7Sderaadt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24df930be7Sderaadt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25df930be7Sderaadt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 26df930be7Sderaadt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 27df930be7Sderaadt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28df930be7Sderaadt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29df930be7Sderaadt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30df930be7Sderaadt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 31df930be7Sderaadt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32df930be7Sderaadt */ 33df930be7Sderaadt 34df930be7Sderaadt #ifndef _DLFCN_H_ 35df930be7Sderaadt #define _DLFCN_H_ 36df930be7Sderaadt 37df930be7Sderaadt #include <sys/cdefs.h> 38df930be7Sderaadt 392c79e7ccSguenther /* Values for dlopen `mode'. */ 402c79e7ccSguenther #define RTLD_LAZY 1 412c79e7ccSguenther #define RTLD_NOW 2 422c79e7ccSguenther #define RTLD_GLOBAL 0x100 432c79e7ccSguenther #define RTLD_LOCAL 0x000 442c79e7ccSguenther #define RTLD_TRACE 0x200 45296fbf9fSsemarie #define RTLD_NODELETE 0x400 46*c1d0be48Stb #define RTLD_NOLOAD 0x800 472c79e7ccSguenther 482c79e7ccSguenther /* 492c79e7ccSguenther * Special handle arguments for dlsym(). 502c79e7ccSguenther */ 512c79e7ccSguenther #define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ 522c79e7ccSguenther #define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ 532c79e7ccSguenther #define RTLD_SELF ((void *) -3) /* Search the caller itself. */ 542c79e7ccSguenther 552c79e7ccSguenther #if __BSD_VISIBLE 562c79e7ccSguenther 57df930be7Sderaadt /* 587be38e1cSdrahn * Structure filled in by dladdr(). 597be38e1cSdrahn */ 607be38e1cSdrahn typedef struct dl_info { 617be38e1cSdrahn const char *dli_fname; /* Pathname of shared object. */ 627be38e1cSdrahn void *dli_fbase; /* Base address of shared object. */ 637be38e1cSdrahn const char *dli_sname; /* Name of nearest symbol. */ 647be38e1cSdrahn void *dli_saddr; /* Address of nearest symbol. */ 657be38e1cSdrahn } Dl_info; 667be38e1cSdrahn 677be38e1cSdrahn /* 68df930be7Sderaadt * dlctl() commands 69df930be7Sderaadt */ 70df930be7Sderaadt #define DL_GETERRNO 1 71df930be7Sderaadt #define DL_SETSRCHPATH x 72df930be7Sderaadt #define DL_GETLIST x 73df930be7Sderaadt #define DL_GETREFCNT x 74df930be7Sderaadt #define DL_GETLOADADDR x 75be7ded7eSmarc #define DL_SETTHREADLCK 2 761e440e15Sdrahn #define DL_SETBINDLCK 3 77a0d792cdSkettenis #define DL_REFERENCE 4 78df930be7Sderaadt 792c79e7ccSguenther #define DL_LAZY RTLD_LAZY /* Compat */ 802c79e7ccSguenther 812c79e7ccSguenther #endif /* __BSD_VISIBLE */ 822c79e7ccSguenther 832c79e7ccSguenther 842c79e7ccSguenther /* 852c79e7ccSguenther * User interface to the run-time linker. 862c79e7ccSguenther */ 872c79e7ccSguenther __BEGIN_DECLS 882c79e7ccSguenther void *dlopen(const char *, int); 892c79e7ccSguenther int dlclose(void *); 902c79e7ccSguenther void *dlsym(void *__restrict, const char *__restrict); 91ca229a5cSderaadt char *dlerror(void); 922c79e7ccSguenther 932c79e7ccSguenther #if __BSD_VISIBLE 942c79e7ccSguenther int dladdr(const void *, Dl_info *); 952c79e7ccSguenther int dlctl(void *, int, void *); 962c79e7ccSguenther #endif /* __BSD_VISIBLE */ 972c79e7ccSguenther 982c79e7ccSguenther __END_DECLS 992c79e7ccSguenther 100df930be7Sderaadt #endif /* _DLFCN_H_ */ 101