Home | History | Annotate | Line # | Download | only in include
dlfcn.h revision 1.25.18.1
      1  1.25.18.1  perseant /*	$NetBSD: dlfcn.h,v 1.25.18.1 2025/08/02 05:54:27 perseant Exp $	*/
      2        1.1        pk 
      3        1.9        pk /*-
      4        1.9        pk  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5        1.1        pk  * All rights reserved.
      6        1.1        pk  *
      7        1.9        pk  * This code is derived from software contributed to The NetBSD Foundation
      8        1.9        pk  * by Paul Kranenburg.
      9        1.9        pk  *
     10        1.1        pk  * Redistribution and use in source and binary forms, with or without
     11        1.1        pk  * modification, are permitted provided that the following conditions
     12        1.1        pk  * are met:
     13        1.1        pk  * 1. Redistributions of source code must retain the above copyright
     14        1.1        pk  *    notice, this list of conditions and the following disclaimer.
     15        1.1        pk  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.1        pk  *    notice, this list of conditions and the following disclaimer in the
     17        1.1        pk  *    documentation and/or other materials provided with the distribution.
     18        1.1        pk  *
     19        1.9        pk  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20        1.9        pk  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21        1.9        pk  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22        1.9        pk  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23        1.9        pk  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24        1.9        pk  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25        1.9        pk  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26        1.9        pk  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27        1.9        pk  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28        1.9        pk  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29        1.9        pk  * POSSIBILITY OF SUCH DAMAGE.
     30        1.1        pk  */
     31        1.1        pk 
     32        1.1        pk #ifndef _DLFCN_H_
     33        1.1        pk #define _DLFCN_H_
     34        1.1        pk 
     35       1.14     bjh21 #include <sys/featuretest.h>
     36        1.1        pk #include <sys/cdefs.h>
     37       1.25     joerg #include <machine/ansi.h>
     38       1.25     joerg 
     39       1.25     joerg #ifdef	_BSD_SSIZE_T_
     40       1.25     joerg typedef	_BSD_SSIZE_T_	ssize_t;
     41       1.25     joerg #undef	_BSD_SSIZE_T_
     42       1.25     joerg #endif
     43        1.1        pk 
     44       1.14     bjh21 #if defined(_NETBSD_SOURCE)
     45        1.7        pk typedef struct _dl_info {
     46        1.7        pk 	const char	*dli_fname;	/* File defining the symbol */
     47        1.7        pk 	void		*dli_fbase;	/* Base address */
     48        1.7        pk 	const char	*dli_sname;	/* Symbol name */
     49       1.12   thorpej 	const void	*dli_saddr;	/* Symbol address */
     50        1.7        pk } Dl_info;
     51       1.14     bjh21 #endif /* defined(_NETBSD_SOURCE) */
     52        1.7        pk 
     53        1.1        pk /*
     54        1.1        pk  * User interface to the run-time linker.
     55        1.1        pk  */
     56        1.2        pk __BEGIN_DECLS
     57       1.24     joerg void *_dlauxinfo(void) __pure;
     58       1.24     joerg 
     59       1.17     perry void	*dlopen(const char *, int);
     60       1.17     perry int	dlclose(void *);
     61       1.18    kleink void	*dlsym(void * __restrict, const char * __restrict);
     62  1.25.18.1  perseant #if (_POSIX_C_SOURCE - 0 >= 202405L) || defined(_NETBSD_SOURCE)
     63       1.18    kleink int	dladdr(const void * __restrict, Dl_info * __restrict);
     64  1.25.18.1  perseant #endif
     65  1.25.18.1  perseant #if defined(_NETBSD_SOURCE)
     66       1.17     perry int	dlctl(void *, int, void *);
     67       1.20     pooka int	dlinfo(void *, int, void *);
     68       1.23    nonaka void	*dlvsym(void * __restrict, const char * __restrict,
     69       1.23    nonaka 	    const char * __restrict);
     70       1.25     joerg void	__dl_cxa_refcount(void *, ssize_t);
     71        1.5    kleink #endif
     72       1.17     perry __aconst char *dlerror(void);
     73        1.2        pk __END_DECLS
     74        1.1        pk 
     75        1.1        pk /* Values for dlopen `mode'. */
     76        1.3        pk #define RTLD_LAZY	1
     77        1.3        pk #define RTLD_NOW	2
     78        1.4        pk #define RTLD_GLOBAL	0x100		/* Allow global searches in object */
     79        1.8        tv #define RTLD_LOCAL	0x200
     80       1.22     skrll #define RTLD_NODELETE	0x01000		/* Do not remove members. */
     81       1.22     skrll #define RTLD_NOLOAD	0x02000		/* Do not load if not already loaded. */
     82       1.14     bjh21 #if defined(_NETBSD_SOURCE)
     83        1.4        pk #define DL_LAZY		RTLD_LAZY	/* Compat */
     84        1.5    kleink #endif
     85       1.15  christos 
     86       1.15  christos /*
     87       1.16     skrll  * Special handle arguments for dlsym().
     88       1.15  christos  */
     89       1.15  christos #define	RTLD_NEXT	((void *) -1)	/* Search subsequent objects. */
     90       1.15  christos #define	RTLD_DEFAULT	((void *) -2)	/* Use default search algorithm. */
     91       1.15  christos #define	RTLD_SELF	((void *) -3)	/* Search the caller itself. */
     92        1.1        pk 
     93        1.1        pk /*
     94        1.1        pk  * dlctl() commands
     95        1.1        pk  */
     96       1.14     bjh21 #if defined(_NETBSD_SOURCE)
     97        1.1        pk #define DL_GETERRNO	1
     98        1.7        pk #define DL_GETSYMBOL	2
     99        1.4        pk #if 0
    100        1.1        pk #define DL_SETSRCHPATH	x
    101        1.1        pk #define DL_GETLIST	x
    102        1.1        pk #define DL_GETREFCNT	x
    103        1.1        pk #define DL_GETLOADADDR	x
    104        1.5    kleink #endif /* 0 */
    105       1.14     bjh21 #endif /* defined(_NETBSD_SOURCE) */
    106        1.1        pk 
    107       1.20     pooka /*
    108       1.20     pooka  * dlinfo() commands
    109       1.20     pooka  *
    110       1.21     skrll  * From Solaris: http://docs.sun.com/app/docs/doc/816-5168/dlinfo-3c?a=view
    111       1.20     pooka  */
    112       1.20     pooka #if defined(_NETBSD_SOURCE)
    113       1.20     pooka #define RTLD_DI_LINKMAP		3
    114       1.20     pooka #if 0
    115       1.20     pooka #define RTLD_DI_ARGSINFO	1
    116       1.20     pooka #define RTLD_DI_CONFIGADDR	2
    117       1.20     pooka #define RTLD_DI_LMID		4
    118       1.20     pooka #define RTLD_DI_SERINFO		5
    119       1.20     pooka #define RTLD_DI_SERINFOSIZE	6
    120       1.20     pooka #define RTLD_DI_ORIGIN		7
    121       1.20     pooka #define RTLD_DI_GETSIGNAL	8
    122       1.20     pooka #define RTLD_DI_SETSIGNAL	9
    123       1.20     pooka #endif
    124       1.20     pooka #endif /* _NETBSD_SOURCE */
    125       1.20     pooka 
    126        1.5    kleink #endif /* !defined(_DLFCN_H_) */
    127