1276761Sdelphij/*	$NetBSD: dlfcn.h,v 1.22 2010/12/24 12:41:42 skrll Exp $	*/
2276761Sdelphij
3276761Sdelphij/*-
4276761Sdelphij * Copyright (c) 1998 The NetBSD Foundation, Inc.
5276761Sdelphij * All rights reserved.
6276761Sdelphij *
7276761Sdelphij * This code is derived from software contributed to The NetBSD Foundation
8276761Sdelphij * by Paul Kranenburg.
9276761Sdelphij *
10276761Sdelphij * Redistribution and use in source and binary forms, with or without
11276761Sdelphij * modification, are permitted provided that the following conditions
12276761Sdelphij * are met:
13276761Sdelphij * 1. Redistributions of source code must retain the above copyright
14276761Sdelphij *    notice, this list of conditions and the following disclaimer.
15276761Sdelphij * 2. Redistributions in binary form must reproduce the above copyright
16276761Sdelphij *    notice, this list of conditions and the following disclaimer in the
17276761Sdelphij *    documentation and/or other materials provided with the distribution.
18276761Sdelphij *
19276761Sdelphij * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20276761Sdelphij * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21276761Sdelphij * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22276761Sdelphij * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23276761Sdelphij * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24276761Sdelphij * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25276761Sdelphij * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26276761Sdelphij * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27276761Sdelphij * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28276761Sdelphij * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29276761Sdelphij * POSSIBILITY OF SUCH DAMAGE.
30276761Sdelphij */
31276761Sdelphij
32276761Sdelphij#ifndef _DLFCN_H_
33276761Sdelphij#define _DLFCN_H_
34276761Sdelphij
35276761Sdelphij#include <sys/featuretest.h>
36276761Sdelphij#include <sys/cdefs.h>
37276761Sdelphij
38276761Sdelphij#if defined(_NETBSD_SOURCE)
39276761Sdelphijtypedef struct _dl_info {
40276761Sdelphij	const char	*dli_fname;	/* File defining the symbol */
41276761Sdelphij	void		*dli_fbase;	/* Base address */
42276761Sdelphij	const char	*dli_sname;	/* Symbol name */
43276761Sdelphij	const void	*dli_saddr;	/* Symbol address */
44276761Sdelphij} Dl_info;
45276761Sdelphij#endif /* defined(_NETBSD_SOURCE) */
46276761Sdelphij
47276761Sdelphij/*
48276761Sdelphij * User interface to the run-time linker.
49276761Sdelphij */
50276761Sdelphij__BEGIN_DECLS
51276761Sdelphijvoid	*dlopen(const char *, int);
52276761Sdelphijint	dlclose(void *);
53276761Sdelphijvoid	*dlsym(void * __restrict, const char * __restrict);
54276761Sdelphij#if defined(_NETBSD_SOURCE)
55276761Sdelphijint	dladdr(const void * __restrict, Dl_info * __restrict);
56276761Sdelphijint	dlctl(void *, int, void *);
57276761Sdelphijint	dlinfo(void *, int, void *);
58276761Sdelphijvoid	*dlvsym(void * __restrict, const char * __restrict,
59276761Sdelphij	    const char * __restrict);
60276761Sdelphij#endif
61276761Sdelphij__aconst char *dlerror(void);
62276761Sdelphij__END_DECLS
63276761Sdelphij
64276761Sdelphij/* Values for dlopen `mode'. */
65276761Sdelphij#define RTLD_LAZY	1
66276761Sdelphij#define RTLD_NOW	2
67276761Sdelphij#define RTLD_GLOBAL	0x100		/* Allow global searches in object */
68276761Sdelphij#define RTLD_LOCAL	0x200
69276761Sdelphij#define RTLD_NODELETE	0x01000		/* Do not remove members. */
70276761Sdelphij#define RTLD_NOLOAD	0x02000		/* Do not load if not already loaded. */
71276761Sdelphij#if defined(_NETBSD_SOURCE)
72276761Sdelphij#define DL_LAZY		RTLD_LAZY	/* Compat */
73276761Sdelphij#endif
74276761Sdelphij
75276761Sdelphij/*
76276761Sdelphij * Special handle arguments for dlsym().
77276761Sdelphij */
78276761Sdelphij#define	RTLD_NEXT	((void *) -1)	/* Search subsequent objects. */
79276761Sdelphij#define	RTLD_DEFAULT	((void *) -2)	/* Use default search algorithm. */
80276761Sdelphij#define	RTLD_SELF	((void *) -3)	/* Search the caller itself. */
81276761Sdelphij
82276761Sdelphij/*
83276761Sdelphij * dlctl() commands
84276761Sdelphij */
85276761Sdelphij#if defined(_NETBSD_SOURCE)
86276761Sdelphij#define DL_GETERRNO	1
87276761Sdelphij#define DL_GETSYMBOL	2
88276761Sdelphij#if 0
89276761Sdelphij#define DL_SETSRCHPATH	x
90276761Sdelphij#define DL_GETLIST	x
91276761Sdelphij#define DL_GETREFCNT	x
92276761Sdelphij#define DL_GETLOADADDR	x
93276761Sdelphij#endif /* 0 */
94276761Sdelphij#endif /* defined(_NETBSD_SOURCE) */
95276761Sdelphij
96276761Sdelphij/*
97276761Sdelphij * dlinfo() commands
98276761Sdelphij *
99276761Sdelphij * From Solaris: http://docs.sun.com/app/docs/doc/816-5168/dlinfo-3c?a=view
100276761Sdelphij */
101276761Sdelphij#if defined(_NETBSD_SOURCE)
102276761Sdelphij#define RTLD_DI_LINKMAP		3
103276761Sdelphij#if 0
104276761Sdelphij#define RTLD_DI_ARGSINFO	1
105276761Sdelphij#define RTLD_DI_CONFIGADDR	2
106276761Sdelphij#define RTLD_DI_LMID		4
107276761Sdelphij#define RTLD_DI_SERINFO		5
108276761Sdelphij#define RTLD_DI_SERINFOSIZE	6
109276761Sdelphij#define RTLD_DI_ORIGIN		7
110276761Sdelphij#define RTLD_DI_GETSIGNAL	8
111276761Sdelphij#define RTLD_DI_SETSIGNAL	9
112276761Sdelphij#endif
113276761Sdelphij#endif /* _NETBSD_SOURCE */
114276761Sdelphij
115276761Sdelphij#endif /* !defined(_DLFCN_H_) */
116276761Sdelphij