xref: /minix3/include/dlfcn.h (revision f14fb602092e015ff630df58e17c2a9cd57d29b3)
1*f14fb602SLionel Sambuc /*	$NetBSD: dlfcn.h,v 1.24 2012/02/16 23:00:39 joerg Exp $	*/
22fe8fb19SBen Gras 
32fe8fb19SBen Gras /*-
42fe8fb19SBen Gras  * Copyright (c) 1998 The NetBSD Foundation, Inc.
52fe8fb19SBen Gras  * All rights reserved.
62fe8fb19SBen Gras  *
72fe8fb19SBen Gras  * This code is derived from software contributed to The NetBSD Foundation
82fe8fb19SBen Gras  * by Paul Kranenburg.
92fe8fb19SBen Gras  *
102fe8fb19SBen Gras  * Redistribution and use in source and binary forms, with or without
112fe8fb19SBen Gras  * modification, are permitted provided that the following conditions
122fe8fb19SBen Gras  * are met:
132fe8fb19SBen Gras  * 1. Redistributions of source code must retain the above copyright
142fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer.
152fe8fb19SBen Gras  * 2. Redistributions in binary form must reproduce the above copyright
162fe8fb19SBen Gras  *    notice, this list of conditions and the following disclaimer in the
172fe8fb19SBen Gras  *    documentation and/or other materials provided with the distribution.
182fe8fb19SBen Gras  *
192fe8fb19SBen Gras  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
202fe8fb19SBen Gras  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
212fe8fb19SBen Gras  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
222fe8fb19SBen Gras  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
232fe8fb19SBen Gras  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
242fe8fb19SBen Gras  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
252fe8fb19SBen Gras  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
262fe8fb19SBen Gras  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
272fe8fb19SBen Gras  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
282fe8fb19SBen Gras  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
292fe8fb19SBen Gras  * POSSIBILITY OF SUCH DAMAGE.
302fe8fb19SBen Gras  */
312fe8fb19SBen Gras 
322fe8fb19SBen Gras #ifndef _DLFCN_H_
332fe8fb19SBen Gras #define _DLFCN_H_
342fe8fb19SBen Gras 
352fe8fb19SBen Gras #include <sys/featuretest.h>
362fe8fb19SBen Gras #include <sys/cdefs.h>
372fe8fb19SBen Gras 
382fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
392fe8fb19SBen Gras typedef struct _dl_info {
402fe8fb19SBen Gras 	const char	*dli_fname;	/* File defining the symbol */
412fe8fb19SBen Gras 	void		*dli_fbase;	/* Base address */
422fe8fb19SBen Gras 	const char	*dli_sname;	/* Symbol name */
432fe8fb19SBen Gras 	const void	*dli_saddr;	/* Symbol address */
442fe8fb19SBen Gras } Dl_info;
452fe8fb19SBen Gras #endif /* defined(_NETBSD_SOURCE) */
462fe8fb19SBen Gras 
472fe8fb19SBen Gras /*
482fe8fb19SBen Gras  * User interface to the run-time linker.
492fe8fb19SBen Gras  */
502fe8fb19SBen Gras __BEGIN_DECLS
51*f14fb602SLionel Sambuc void *_dlauxinfo(void) __pure;
52*f14fb602SLionel Sambuc 
532fe8fb19SBen Gras void	*dlopen(const char *, int);
542fe8fb19SBen Gras int	dlclose(void *);
552fe8fb19SBen Gras void	*dlsym(void * __restrict, const char * __restrict);
562fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
572fe8fb19SBen Gras int	dladdr(const void * __restrict, Dl_info * __restrict);
582fe8fb19SBen Gras int	dlctl(void *, int, void *);
592fe8fb19SBen Gras int	dlinfo(void *, int, void *);
60*f14fb602SLionel Sambuc void	*dlvsym(void * __restrict, const char * __restrict,
61*f14fb602SLionel Sambuc 	    const char * __restrict);
622fe8fb19SBen Gras #endif
632fe8fb19SBen Gras __aconst char *dlerror(void);
642fe8fb19SBen Gras __END_DECLS
652fe8fb19SBen Gras 
662fe8fb19SBen Gras /* Values for dlopen `mode'. */
672fe8fb19SBen Gras #define RTLD_LAZY	1
682fe8fb19SBen Gras #define RTLD_NOW	2
692fe8fb19SBen Gras #define RTLD_GLOBAL	0x100		/* Allow global searches in object */
702fe8fb19SBen Gras #define RTLD_LOCAL	0x200
712fe8fb19SBen Gras #define RTLD_NODELETE	0x01000		/* Do not remove members. */
722fe8fb19SBen Gras #define RTLD_NOLOAD	0x02000		/* Do not load if not already loaded. */
732fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
742fe8fb19SBen Gras #define DL_LAZY		RTLD_LAZY	/* Compat */
752fe8fb19SBen Gras #endif
762fe8fb19SBen Gras 
772fe8fb19SBen Gras /*
782fe8fb19SBen Gras  * Special handle arguments for dlsym().
792fe8fb19SBen Gras  */
802fe8fb19SBen Gras #define	RTLD_NEXT	((void *) -1)	/* Search subsequent objects. */
812fe8fb19SBen Gras #define	RTLD_DEFAULT	((void *) -2)	/* Use default search algorithm. */
822fe8fb19SBen Gras #define	RTLD_SELF	((void *) -3)	/* Search the caller itself. */
832fe8fb19SBen Gras 
842fe8fb19SBen Gras /*
852fe8fb19SBen Gras  * dlctl() commands
862fe8fb19SBen Gras  */
872fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
882fe8fb19SBen Gras #define DL_GETERRNO	1
892fe8fb19SBen Gras #define DL_GETSYMBOL	2
902fe8fb19SBen Gras #if 0
912fe8fb19SBen Gras #define DL_SETSRCHPATH	x
922fe8fb19SBen Gras #define DL_GETLIST	x
932fe8fb19SBen Gras #define DL_GETREFCNT	x
942fe8fb19SBen Gras #define DL_GETLOADADDR	x
952fe8fb19SBen Gras #endif /* 0 */
962fe8fb19SBen Gras #endif /* defined(_NETBSD_SOURCE) */
972fe8fb19SBen Gras 
982fe8fb19SBen Gras /*
992fe8fb19SBen Gras  * dlinfo() commands
1002fe8fb19SBen Gras  *
1012fe8fb19SBen Gras  * From Solaris: http://docs.sun.com/app/docs/doc/816-5168/dlinfo-3c?a=view
1022fe8fb19SBen Gras  */
1032fe8fb19SBen Gras #if defined(_NETBSD_SOURCE)
1042fe8fb19SBen Gras #define RTLD_DI_LINKMAP		3
1052fe8fb19SBen Gras #if 0
1062fe8fb19SBen Gras #define RTLD_DI_ARGSINFO	1
1072fe8fb19SBen Gras #define RTLD_DI_CONFIGADDR	2
1082fe8fb19SBen Gras #define RTLD_DI_LMID		4
1092fe8fb19SBen Gras #define RTLD_DI_SERINFO		5
1102fe8fb19SBen Gras #define RTLD_DI_SERINFOSIZE	6
1112fe8fb19SBen Gras #define RTLD_DI_ORIGIN		7
1122fe8fb19SBen Gras #define RTLD_DI_GETSIGNAL	8
1132fe8fb19SBen Gras #define RTLD_DI_SETSIGNAL	9
1142fe8fb19SBen Gras #endif
1152fe8fb19SBen Gras #endif /* _NETBSD_SOURCE */
1162fe8fb19SBen Gras 
1172fe8fb19SBen Gras #endif /* !defined(_DLFCN_H_) */
118