1*424f7ee9Snia /* $NetBSD: dlfcn.h,v 1.26 2024/11/02 20:53:58 nia Exp $ */ 287839200Spk 37ff8549eSpk /*- 47ff8549eSpk * Copyright (c) 1998 The NetBSD Foundation, Inc. 587839200Spk * All rights reserved. 687839200Spk * 77ff8549eSpk * This code is derived from software contributed to The NetBSD Foundation 87ff8549eSpk * by Paul Kranenburg. 97ff8549eSpk * 1087839200Spk * Redistribution and use in source and binary forms, with or without 1187839200Spk * modification, are permitted provided that the following conditions 1287839200Spk * are met: 1387839200Spk * 1. Redistributions of source code must retain the above copyright 1487839200Spk * notice, this list of conditions and the following disclaimer. 1587839200Spk * 2. Redistributions in binary form must reproduce the above copyright 1687839200Spk * notice, this list of conditions and the following disclaimer in the 1787839200Spk * documentation and/or other materials provided with the distribution. 1887839200Spk * 197ff8549eSpk * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 207ff8549eSpk * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 217ff8549eSpk * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 227ff8549eSpk * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 237ff8549eSpk * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 247ff8549eSpk * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 257ff8549eSpk * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 267ff8549eSpk * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 277ff8549eSpk * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 287ff8549eSpk * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 297ff8549eSpk * POSSIBILITY OF SUCH DAMAGE. 3087839200Spk */ 3187839200Spk 3287839200Spk #ifndef _DLFCN_H_ 3387839200Spk #define _DLFCN_H_ 3487839200Spk 354be7a2dcSbjh21 #include <sys/featuretest.h> 3687839200Spk #include <sys/cdefs.h> 37e5678be8Sjoerg #include <machine/ansi.h> 38e5678be8Sjoerg 39e5678be8Sjoerg #ifdef _BSD_SSIZE_T_ 40e5678be8Sjoerg typedef _BSD_SSIZE_T_ ssize_t; 41e5678be8Sjoerg #undef _BSD_SSIZE_T_ 42e5678be8Sjoerg #endif 4387839200Spk 444be7a2dcSbjh21 #if defined(_NETBSD_SOURCE) 45c68cbc90Spk typedef struct _dl_info { 46c68cbc90Spk const char *dli_fname; /* File defining the symbol */ 47c68cbc90Spk void *dli_fbase; /* Base address */ 48c68cbc90Spk const char *dli_sname; /* Symbol name */ 49e8050aefSthorpej const void *dli_saddr; /* Symbol address */ 50c68cbc90Spk } Dl_info; 514be7a2dcSbjh21 #endif /* defined(_NETBSD_SOURCE) */ 52c68cbc90Spk 5387839200Spk /* 5487839200Spk * User interface to the run-time linker. 5587839200Spk */ 564003f324Spk __BEGIN_DECLS 5752a4c27eSjoerg void *_dlauxinfo(void) __pure; 5852a4c27eSjoerg 5919b7469aSperry void *dlopen(const char *, int); 6019b7469aSperry int dlclose(void *); 61d5d85540Skleink void *dlsym(void * __restrict, const char * __restrict); 62*424f7ee9Snia #if (_POSIX_C_SOURCE - 0 >= 202405L) || defined(_NETBSD_SOURCE) 63d5d85540Skleink int dladdr(const void * __restrict, Dl_info * __restrict); 64*424f7ee9Snia #endif 65*424f7ee9Snia #if defined(_NETBSD_SOURCE) 6619b7469aSperry int dlctl(void *, int, void *); 674c1e54d8Spooka int dlinfo(void *, int, void *); 68c52f9a5dSnonaka void *dlvsym(void * __restrict, const char * __restrict, 69c52f9a5dSnonaka const char * __restrict); 70e5678be8Sjoerg void __dl_cxa_refcount(void *, ssize_t); 71a681a370Skleink #endif 7219b7469aSperry __aconst char *dlerror(void); 734003f324Spk __END_DECLS 7487839200Spk 7587839200Spk /* Values for dlopen `mode'. */ 76ee945410Spk #define RTLD_LAZY 1 77ee945410Spk #define RTLD_NOW 2 785cc521c0Spk #define RTLD_GLOBAL 0x100 /* Allow global searches in object */ 7977a275d7Stv #define RTLD_LOCAL 0x200 80f1d73a2cSskrll #define RTLD_NODELETE 0x01000 /* Do not remove members. */ 81f1d73a2cSskrll #define RTLD_NOLOAD 0x02000 /* Do not load if not already loaded. */ 824be7a2dcSbjh21 #if defined(_NETBSD_SOURCE) 83ee945410Spk #define DL_LAZY RTLD_LAZY /* Compat */ 84a681a370Skleink #endif 8587839200Spk 8687839200Spk /* 873605f021Sskrll * Special handle arguments for dlsym(). 884e9f5413Schristos */ 894e9f5413Schristos #define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ 904e9f5413Schristos #define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ 914e9f5413Schristos #define RTLD_SELF ((void *) -3) /* Search the caller itself. */ 924e9f5413Schristos 934e9f5413Schristos /* 9487839200Spk * dlctl() commands 9587839200Spk */ 964be7a2dcSbjh21 #if defined(_NETBSD_SOURCE) 9787839200Spk #define DL_GETERRNO 1 98c68cbc90Spk #define DL_GETSYMBOL 2 995cc521c0Spk #if 0 10087839200Spk #define DL_SETSRCHPATH x 10187839200Spk #define DL_GETLIST x 10287839200Spk #define DL_GETREFCNT x 10387839200Spk #define DL_GETLOADADDR x 104a681a370Skleink #endif /* 0 */ 1054be7a2dcSbjh21 #endif /* defined(_NETBSD_SOURCE) */ 10687839200Spk 1074c1e54d8Spooka /* 1084c1e54d8Spooka * dlinfo() commands 1094c1e54d8Spooka * 110c6ed7679Sskrll * From Solaris: http://docs.sun.com/app/docs/doc/816-5168/dlinfo-3c?a=view 1114c1e54d8Spooka */ 1124c1e54d8Spooka #if defined(_NETBSD_SOURCE) 1134c1e54d8Spooka #define RTLD_DI_LINKMAP 3 1144c1e54d8Spooka #if 0 1154c1e54d8Spooka #define RTLD_DI_ARGSINFO 1 1164c1e54d8Spooka #define RTLD_DI_CONFIGADDR 2 1174c1e54d8Spooka #define RTLD_DI_LMID 4 1184c1e54d8Spooka #define RTLD_DI_SERINFO 5 1194c1e54d8Spooka #define RTLD_DI_SERINFOSIZE 6 1204c1e54d8Spooka #define RTLD_DI_ORIGIN 7 1214c1e54d8Spooka #define RTLD_DI_GETSIGNAL 8 1224c1e54d8Spooka #define RTLD_DI_SETSIGNAL 9 1234c1e54d8Spooka #endif 1244c1e54d8Spooka #endif /* _NETBSD_SOURCE */ 1254c1e54d8Spooka 126a681a370Skleink #endif /* !defined(_DLFCN_H_) */ 127