dlfcn.h revision 153515
1210284Sjmallett/*- 2232812Sjmallett * Copyright (c) 1994 3215990Sjmallett * The Regents of the University of California. All rights reserved. 4210284Sjmallett * 5210284Sjmallett * Redistribution and use in source and binary forms, with or without 6215990Sjmallett * modification, are permitted provided that the following conditions 7215990Sjmallett * are met: 8215990Sjmallett * 1. Redistributions of source code must retain the above copyright 9210284Sjmallett * notice, this list of conditions and the following disclaimer. 10215990Sjmallett * 2. Redistributions in binary form must reproduce the above copyright 11215990Sjmallett * notice, this list of conditions and the following disclaimer in the 12210284Sjmallett * documentation and/or other materials provided with the distribution. 13215990Sjmallett * 3. All advertising materials mentioning features or use of this software 14215990Sjmallett * must display the following acknowledgement: 15215990Sjmallett * This product includes software developed by the University of 16215990Sjmallett * California, Berkeley and its contributors. 17215990Sjmallett * 4. Neither the name of the University nor the names of its contributors 18232812Sjmallett * may be used to endorse or promote products derived from this software 19215990Sjmallett * without specific prior written permission. 20215990Sjmallett * 21215990Sjmallett * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22215990Sjmallett * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23215990Sjmallett * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24215990Sjmallett * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25215990Sjmallett * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26215990Sjmallett * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27215990Sjmallett * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28215990Sjmallett * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29232812Sjmallett * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30215990Sjmallett * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31215990Sjmallett * SUCH DAMAGE. 32215990Sjmallett * 33215990Sjmallett * $FreeBSD: head/include/dlfcn.h 153515 2005-12-18 19:43:33Z kan $ 34215990Sjmallett */ 35215990Sjmallett 36215990Sjmallett#ifndef _DLFCN_H_ 37215990Sjmallett#define _DLFCN_H_ 38210284Sjmallett 39210284Sjmallett#include <sys/_types.h> 40210284Sjmallett 41210284Sjmallett/* 42210284Sjmallett * Modes and flags for dlopen(). 43210284Sjmallett */ 44210284Sjmallett#define RTLD_LAZY 1 /* Bind function calls lazily. */ 45215990Sjmallett#define RTLD_NOW 2 /* Bind function calls immediately. */ 46210284Sjmallett#define RTLD_MODEMASK 0x3 47210284Sjmallett#define RTLD_GLOBAL 0x100 /* Make symbols globally available. */ 48210284Sjmallett#define RTLD_LOCAL 0 /* Opposite of RTLD_GLOBAL, and the default. */ 49210284Sjmallett#define RTLD_TRACE 0x200 /* Trace loaded objects and exit. */ 50210284Sjmallett 51210284Sjmallett/* 52232812Sjmallett * Request arguments for dlinfo(). 53210284Sjmallett */ 54210284Sjmallett#define RTLD_DI_LINKMAP 2 /* Obtain link map. */ 55210284Sjmallett#define RTLD_DI_SERINFO 4 /* Obtain search path info. */ 56210284Sjmallett#define RTLD_DI_SERINFOSIZE 5 /* ... query for required space. */ 57210284Sjmallett#define RTLD_DI_ORIGIN 6 /* Obtain object origin */ 58210284Sjmallett#define RTLD_DI_MAX RTLD_DI_ORIGIN 59210284Sjmallett 60210284Sjmallett/* 61210284Sjmallett * Special handle arguments for dlsym()/dlinfo(). 62210284Sjmallett */ 63210284Sjmallett#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ 64210284Sjmallett#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ 65210284Sjmallett#define RTLD_SELF ((void *) -3) /* Search the caller itself. */ 66210284Sjmallett 67210284Sjmallett#if __BSD_VISIBLE 68210284Sjmallett 69210284Sjmallett#ifndef _SIZE_T_DECLARED 70210284Sjmalletttypedef __size_t size_t; 71210284Sjmallett#define _SIZE_T_DECLARED 72210284Sjmallett#endif 73210284Sjmallett 74210284Sjmallett/* 75210284Sjmallett * Structure filled in by dladdr(). 76210284Sjmallett */ 77210284Sjmalletttypedef struct dl_info { 78210284Sjmallett const char *dli_fname; /* Pathname of shared object. */ 79210284Sjmallett void *dli_fbase; /* Base address of shared object. */ 80210284Sjmallett const char *dli_sname; /* Name of nearest symbol. */ 81210284Sjmallett void *dli_saddr; /* Address of nearest symbol. */ 82210284Sjmallett} Dl_info; 83210284Sjmallett 84210284Sjmallett/*- 85210284Sjmallett * The actual type declared by this typedef is immaterial, provided that 86210284Sjmallett * it is a function pointer. Its purpose is to provide a return type for 87210284Sjmallett * dlfunc() which can be cast to a function pointer type without depending 88210284Sjmallett * on behavior undefined by the C standard, which might trigger a compiler 89210284Sjmallett * diagnostic. We intentionally declare a unique type signature to force 90210284Sjmallett * a diagnostic should the application not cast the return value of dlfunc() 91210284Sjmallett * appropriately. 92210284Sjmallett */ 93210284Sjmallettstruct __dlfunc_arg { 94210284Sjmallett int __dlfunc_dummy; 95210284Sjmallett}; 96210284Sjmallett 97210284Sjmalletttypedef void (*dlfunc_t)(struct __dlfunc_arg); 98210284Sjmallett 99210284Sjmallett/* 100210284Sjmallett * Structures, returned by the RTLD_DI_SERINFO dlinfo() request. 101210284Sjmallett */ 102210284Sjmalletttypedef struct dl_serpath { 103210284Sjmallett char * dls_name; /* single search path entry */ 104210284Sjmallett unsigned int dls_flags; /* path information */ 105210284Sjmallett} Dl_serpath; 106210284Sjmallett 107210284Sjmalletttypedef struct dl_serinfo { 108210311Sjmallett size_t dls_size; /* total buffer size */ 109215990Sjmallett unsigned int dls_cnt; /* number of path entries */ 110210284Sjmallett Dl_serpath dls_serpath[1]; /* there may be more than one */ 111210284Sjmallett} Dl_serinfo; 112210284Sjmallett 113210284Sjmallett#endif /* __BSD_VISIBLE */ 114210284Sjmallett 115210284Sjmallett__BEGIN_DECLS 116210284Sjmallett/* XSI functions first. */ 117210284Sjmallettint dlclose(void *); 118210284Sjmallettconst char * 119210284Sjmallett dlerror(void); 120210284Sjmallettvoid *dlopen(const char *, int); 121210284Sjmallettvoid *dlsym(void * __restrict, const char * __restrict); 122210284Sjmallett 123210284Sjmallett#if __BSD_VISIBLE 124215990Sjmallettint dladdr(const void * __restrict, Dl_info * __restrict); 125210311Sjmallettdlfunc_t dlfunc(void * __restrict, const char * __restrict); 126210311Sjmallettint dlinfo(void * __restrict, int, void * __restrict); 127215990Sjmallettvoid dllockinit(void *_context, 128210284Sjmallett void *(*_lock_create)(void *_context), 129215990Sjmallett void (*_rlock_acquire)(void *_lock), 130215990Sjmallett void (*_wlock_acquire)(void *_lock), 131210311Sjmallett void (*_lock_release)(void *_lock), 132215990Sjmallett void (*_lock_destroy)(void *_lock), 133210284Sjmallett void (*_context_destroy)(void *_context)); 134210284Sjmallettvoid *dlvsym(void * __restrict, const char * __restrict, 135210284Sjmallett const char * __restrict); 136210284Sjmallett#endif /* __BSD_VISIBLE */ 137210284Sjmallett__END_DECLS 138210284Sjmallett 139210284Sjmallett#endif /* !_DLFCN_H_ */ 140210284Sjmallett