1*de0e0e4dSAntonio Huete Jimenez /* $OpenBSD: dso.h,v 1.13 2022/07/12 14:42:49 kn Exp $ */ 2f5b1c8a1SJohn Marino /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL 3f5b1c8a1SJohn Marino * project 2000. 4f5b1c8a1SJohn Marino */ 5f5b1c8a1SJohn Marino /* ==================================================================== 6f5b1c8a1SJohn Marino * Copyright (c) 2000 The OpenSSL Project. All rights reserved. 7f5b1c8a1SJohn Marino * 8f5b1c8a1SJohn Marino * Redistribution and use in source and binary forms, with or without 9f5b1c8a1SJohn Marino * modification, are permitted provided that the following conditions 10f5b1c8a1SJohn Marino * are met: 11f5b1c8a1SJohn Marino * 12f5b1c8a1SJohn Marino * 1. Redistributions of source code must retain the above copyright 13f5b1c8a1SJohn Marino * notice, this list of conditions and the following disclaimer. 14f5b1c8a1SJohn Marino * 15f5b1c8a1SJohn Marino * 2. Redistributions in binary form must reproduce the above copyright 16f5b1c8a1SJohn Marino * notice, this list of conditions and the following disclaimer in 17f5b1c8a1SJohn Marino * the documentation and/or other materials provided with the 18f5b1c8a1SJohn Marino * distribution. 19f5b1c8a1SJohn Marino * 20f5b1c8a1SJohn Marino * 3. All advertising materials mentioning features or use of this 21f5b1c8a1SJohn Marino * software must display the following acknowledgment: 22f5b1c8a1SJohn Marino * "This product includes software developed by the OpenSSL Project 23f5b1c8a1SJohn Marino * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" 24f5b1c8a1SJohn Marino * 25f5b1c8a1SJohn Marino * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 26f5b1c8a1SJohn Marino * endorse or promote products derived from this software without 27f5b1c8a1SJohn Marino * prior written permission. For written permission, please contact 28f5b1c8a1SJohn Marino * licensing@OpenSSL.org. 29f5b1c8a1SJohn Marino * 30f5b1c8a1SJohn Marino * 5. Products derived from this software may not be called "OpenSSL" 31f5b1c8a1SJohn Marino * nor may "OpenSSL" appear in their names without prior written 32f5b1c8a1SJohn Marino * permission of the OpenSSL Project. 33f5b1c8a1SJohn Marino * 34f5b1c8a1SJohn Marino * 6. Redistributions of any form whatsoever must retain the following 35f5b1c8a1SJohn Marino * acknowledgment: 36f5b1c8a1SJohn Marino * "This product includes software developed by the OpenSSL Project 37f5b1c8a1SJohn Marino * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" 38f5b1c8a1SJohn Marino * 39f5b1c8a1SJohn Marino * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 40f5b1c8a1SJohn Marino * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 41f5b1c8a1SJohn Marino * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 42f5b1c8a1SJohn Marino * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 43f5b1c8a1SJohn Marino * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 44f5b1c8a1SJohn Marino * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 45f5b1c8a1SJohn Marino * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 46f5b1c8a1SJohn Marino * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 47f5b1c8a1SJohn Marino * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 48f5b1c8a1SJohn Marino * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 49f5b1c8a1SJohn Marino * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 50f5b1c8a1SJohn Marino * OF THE POSSIBILITY OF SUCH DAMAGE. 51f5b1c8a1SJohn Marino * ==================================================================== 52f5b1c8a1SJohn Marino * 53f5b1c8a1SJohn Marino * This product includes cryptographic software written by Eric Young 54f5b1c8a1SJohn Marino * (eay@cryptsoft.com). This product includes software written by Tim 55f5b1c8a1SJohn Marino * Hudson (tjh@cryptsoft.com). 56f5b1c8a1SJohn Marino * 57f5b1c8a1SJohn Marino */ 58f5b1c8a1SJohn Marino 59f5b1c8a1SJohn Marino #ifndef HEADER_DSO_H 60f5b1c8a1SJohn Marino #define HEADER_DSO_H 61f5b1c8a1SJohn Marino 62f5b1c8a1SJohn Marino #include <openssl/crypto.h> 63f5b1c8a1SJohn Marino 64f5b1c8a1SJohn Marino #ifdef __cplusplus 65f5b1c8a1SJohn Marino extern "C" { 66f5b1c8a1SJohn Marino #endif 67f5b1c8a1SJohn Marino 68f5b1c8a1SJohn Marino /* These values are used as commands to DSO_ctrl() */ 69f5b1c8a1SJohn Marino #define DSO_CTRL_GET_FLAGS 1 70f5b1c8a1SJohn Marino #define DSO_CTRL_SET_FLAGS 2 71f5b1c8a1SJohn Marino #define DSO_CTRL_OR_FLAGS 3 72f5b1c8a1SJohn Marino 73f5b1c8a1SJohn Marino /* By default, DSO_load() will translate the provided filename into a form 74f5b1c8a1SJohn Marino * typical for the platform (more specifically the DSO_METHOD) using the 75f5b1c8a1SJohn Marino * dso_name_converter function of the method. Eg. win32 will transform "blah" 76f5b1c8a1SJohn Marino * into "blah.dll", and dlfcn will transform it into "libblah.so". The 77f5b1c8a1SJohn Marino * behaviour can be overridden by setting the name_converter callback in the DSO 78f5b1c8a1SJohn Marino * object (using DSO_set_name_converter()). This callback could even utilise 79f5b1c8a1SJohn Marino * the DSO_METHOD's converter too if it only wants to override behaviour for 80f5b1c8a1SJohn Marino * one or two possible DSO methods. However, the following flag can be set in a 81f5b1c8a1SJohn Marino * DSO to prevent *any* native name-translation at all - eg. if the caller has 82f5b1c8a1SJohn Marino * prompted the user for a path to a driver library so the filename should be 83f5b1c8a1SJohn Marino * interpreted as-is. */ 84f5b1c8a1SJohn Marino #define DSO_FLAG_NO_NAME_TRANSLATION 0x01 85f5b1c8a1SJohn Marino /* An extra flag to give if only the extension should be added as 86f5b1c8a1SJohn Marino * translation. This is obviously only of importance on Unix and 87f5b1c8a1SJohn Marino * other operating systems where the translation also may prefix 88f5b1c8a1SJohn Marino * the name with something, like 'lib', and ignored everywhere else. 89f5b1c8a1SJohn Marino * This flag is also ignored if DSO_FLAG_NO_NAME_TRANSLATION is used 90f5b1c8a1SJohn Marino * at the same time. */ 91f5b1c8a1SJohn Marino #define DSO_FLAG_NAME_TRANSLATION_EXT_ONLY 0x02 92f5b1c8a1SJohn Marino 93f5b1c8a1SJohn Marino /* The following flag controls the translation of symbol names to upper 94f5b1c8a1SJohn Marino * case. This is currently only being implemented for OpenVMS. 95f5b1c8a1SJohn Marino */ 96f5b1c8a1SJohn Marino #define DSO_FLAG_UPCASE_SYMBOL 0x10 97f5b1c8a1SJohn Marino 98f5b1c8a1SJohn Marino /* This flag loads the library with public symbols. 99f5b1c8a1SJohn Marino * Meaning: The exported symbols of this library are public 100f5b1c8a1SJohn Marino * to all libraries loaded after this library. 101f5b1c8a1SJohn Marino * At the moment only implemented in unix. 102f5b1c8a1SJohn Marino */ 103f5b1c8a1SJohn Marino #define DSO_FLAG_GLOBAL_SYMBOLS 0x20 104f5b1c8a1SJohn Marino 105f5b1c8a1SJohn Marino 106f5b1c8a1SJohn Marino typedef void (*DSO_FUNC_TYPE)(void); 107f5b1c8a1SJohn Marino 108f5b1c8a1SJohn Marino typedef struct dso_st DSO; 109f5b1c8a1SJohn Marino 110f5b1c8a1SJohn Marino /* The function prototype used for method functions (or caller-provided 111f5b1c8a1SJohn Marino * callbacks) that transform filenames. They are passed a DSO structure pointer 112f5b1c8a1SJohn Marino * (or NULL if they are to be used independantly of a DSO object) and a 113f5b1c8a1SJohn Marino * filename to transform. They should either return NULL (if there is an error 114f5b1c8a1SJohn Marino * condition) or a newly allocated string containing the transformed form that 115f5b1c8a1SJohn Marino * the caller will need to free with free() when done. */ 116f5b1c8a1SJohn Marino typedef char* (*DSO_NAME_CONVERTER_FUNC)(DSO *, const char *); 117f5b1c8a1SJohn Marino /* The function prototype used for method functions (or caller-provided 118f5b1c8a1SJohn Marino * callbacks) that merge two file specifications. They are passed a 119f5b1c8a1SJohn Marino * DSO structure pointer (or NULL if they are to be used independantly of 120f5b1c8a1SJohn Marino * a DSO object) and two file specifications to merge. They should 121f5b1c8a1SJohn Marino * either return NULL (if there is an error condition) or a newly allocated 122f5b1c8a1SJohn Marino * string containing the result of merging that the caller will need 123f5b1c8a1SJohn Marino * to free with free() when done. 124f5b1c8a1SJohn Marino * Here, merging means that bits and pieces are taken from each of the 125f5b1c8a1SJohn Marino * file specifications and added together in whatever fashion that is 126f5b1c8a1SJohn Marino * sensible for the DSO method in question. The only rule that really 127f5b1c8a1SJohn Marino * applies is that if the two specification contain pieces of the same 128f5b1c8a1SJohn Marino * type, the copy from the first string takes priority. One could see 129f5b1c8a1SJohn Marino * it as the first specification is the one given by the user and the 130f5b1c8a1SJohn Marino * second being a bunch of defaults to add on if they're missing in the 131f5b1c8a1SJohn Marino * first. */ 132f5b1c8a1SJohn Marino typedef char* (*DSO_MERGER_FUNC)(DSO *, const char *, const char *); 133f5b1c8a1SJohn Marino 134f5b1c8a1SJohn Marino typedef struct dso_meth_st { 135f5b1c8a1SJohn Marino const char *name; 136f5b1c8a1SJohn Marino /* Loads a shared library, NB: new DSO_METHODs must ensure that a 137f5b1c8a1SJohn Marino * successful load populates the loaded_filename field, and likewise a 138f5b1c8a1SJohn Marino * successful unload frees and NULLs it out. */ 139f5b1c8a1SJohn Marino int (*dso_load)(DSO *dso); 140f5b1c8a1SJohn Marino /* Unloads a shared library */ 141f5b1c8a1SJohn Marino int (*dso_unload)(DSO *dso); 142f5b1c8a1SJohn Marino /* Binds a variable */ 143f5b1c8a1SJohn Marino void *(*dso_bind_var)(DSO *dso, const char *symname); 144f5b1c8a1SJohn Marino /* Binds a function - assumes a return type of DSO_FUNC_TYPE. 145f5b1c8a1SJohn Marino * This should be cast to the real function prototype by the 146f5b1c8a1SJohn Marino * caller. Platforms that don't have compatible representations 147f5b1c8a1SJohn Marino * for different prototypes (this is possible within ANSI C) 148f5b1c8a1SJohn Marino * are highly unlikely to have shared libraries at all, let 149f5b1c8a1SJohn Marino * alone a DSO_METHOD implemented for them. */ 150f5b1c8a1SJohn Marino DSO_FUNC_TYPE (*dso_bind_func)(DSO *dso, const char *symname); 151f5b1c8a1SJohn Marino 152f5b1c8a1SJohn Marino /* The generic (yuck) "ctrl()" function. NB: Negative return 153f5b1c8a1SJohn Marino * values (rather than zero) indicate errors. */ 154f5b1c8a1SJohn Marino long (*dso_ctrl)(DSO *dso, int cmd, long larg, void *parg); 155f5b1c8a1SJohn Marino /* The default DSO_METHOD-specific function for converting filenames to 156f5b1c8a1SJohn Marino * a canonical native form. */ 157f5b1c8a1SJohn Marino DSO_NAME_CONVERTER_FUNC dso_name_converter; 158f5b1c8a1SJohn Marino /* The default DSO_METHOD-specific function for converting filenames to 159f5b1c8a1SJohn Marino * a canonical native form. */ 160f5b1c8a1SJohn Marino DSO_MERGER_FUNC dso_merger; 161f5b1c8a1SJohn Marino 162f5b1c8a1SJohn Marino /* [De]Initialisation handlers. */ 163f5b1c8a1SJohn Marino int (*init)(DSO *dso); 164f5b1c8a1SJohn Marino int (*finish)(DSO *dso); 165f5b1c8a1SJohn Marino 166f5b1c8a1SJohn Marino /* Return pathname of the module containing location */ 167f5b1c8a1SJohn Marino int (*pathbyaddr)(void *addr, char *path, int sz); 168f5b1c8a1SJohn Marino /* Perform global symbol lookup, i.e. among *all* modules */ 169f5b1c8a1SJohn Marino void *(*globallookup)(const char *symname); 170f5b1c8a1SJohn Marino } DSO_METHOD; 171f5b1c8a1SJohn Marino 172f5b1c8a1SJohn Marino /**********************************************************************/ 173f5b1c8a1SJohn Marino /* The low-level handle type used to refer to a loaded shared library */ 174f5b1c8a1SJohn Marino 175f5b1c8a1SJohn Marino struct dso_st { 176f5b1c8a1SJohn Marino DSO_METHOD *meth; 177f5b1c8a1SJohn Marino /* Standard dlopen uses a (void *). Win32 uses a HANDLE. VMS 178f5b1c8a1SJohn Marino * doesn't use anything but will need to cache the filename 179f5b1c8a1SJohn Marino * for use in the dso_bind handler. All in all, let each 180f5b1c8a1SJohn Marino * method control its own destiny. "Handles" and such go in 181f5b1c8a1SJohn Marino * a STACK. */ 182f5b1c8a1SJohn Marino STACK_OF(void) *meth_data; 183f5b1c8a1SJohn Marino int references; 184f5b1c8a1SJohn Marino int flags; 185f5b1c8a1SJohn Marino /* For use by applications etc ... use this for your bits'n'pieces, 186f5b1c8a1SJohn Marino * don't touch meth_data! */ 187f5b1c8a1SJohn Marino CRYPTO_EX_DATA ex_data; 188f5b1c8a1SJohn Marino /* If this callback function pointer is set to non-NULL, then it will 189f5b1c8a1SJohn Marino * be used in DSO_load() in place of meth->dso_name_converter. NB: This 190f5b1c8a1SJohn Marino * should normally set using DSO_set_name_converter(). */ 191f5b1c8a1SJohn Marino DSO_NAME_CONVERTER_FUNC name_converter; 192f5b1c8a1SJohn Marino /* If this callback function pointer is set to non-NULL, then it will 193f5b1c8a1SJohn Marino * be used in DSO_load() in place of meth->dso_merger. NB: This 194f5b1c8a1SJohn Marino * should normally set using DSO_set_merger(). */ 195f5b1c8a1SJohn Marino DSO_MERGER_FUNC merger; 196f5b1c8a1SJohn Marino /* This is populated with (a copy of) the platform-independant 197f5b1c8a1SJohn Marino * filename used for this DSO. */ 198f5b1c8a1SJohn Marino char *filename; 199f5b1c8a1SJohn Marino /* This is populated with (a copy of) the translated filename by which 200f5b1c8a1SJohn Marino * the DSO was actually loaded. It is NULL iff the DSO is not currently 201f5b1c8a1SJohn Marino * loaded. NB: This is here because the filename translation process 202f5b1c8a1SJohn Marino * may involve a callback being invoked more than once not only to 203f5b1c8a1SJohn Marino * convert to a platform-specific form, but also to try different 204f5b1c8a1SJohn Marino * filenames in the process of trying to perform a load. As such, this 205f5b1c8a1SJohn Marino * variable can be used to indicate (a) whether this DSO structure 206f5b1c8a1SJohn Marino * corresponds to a loaded library or not, and (b) the filename with 207f5b1c8a1SJohn Marino * which it was actually loaded. */ 208f5b1c8a1SJohn Marino char *loaded_filename; 209f5b1c8a1SJohn Marino }; 210f5b1c8a1SJohn Marino 211f5b1c8a1SJohn Marino 212f5b1c8a1SJohn Marino DSO * DSO_new(void); 213f5b1c8a1SJohn Marino DSO * DSO_new_method(DSO_METHOD *method); 214f5b1c8a1SJohn Marino int DSO_free(DSO *dso); 215f5b1c8a1SJohn Marino int DSO_flags(DSO *dso); 216f5b1c8a1SJohn Marino int DSO_up_ref(DSO *dso); 217f5b1c8a1SJohn Marino long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg); 218f5b1c8a1SJohn Marino 219f5b1c8a1SJohn Marino /* This function sets the DSO's name_converter callback. If it is non-NULL, 220f5b1c8a1SJohn Marino * then it will be used instead of the associated DSO_METHOD's function. If 221f5b1c8a1SJohn Marino * oldcb is non-NULL then it is set to the function pointer value being 222f5b1c8a1SJohn Marino * replaced. Return value is non-zero for success. */ 223f5b1c8a1SJohn Marino int DSO_set_name_converter(DSO *dso, DSO_NAME_CONVERTER_FUNC cb, 224f5b1c8a1SJohn Marino DSO_NAME_CONVERTER_FUNC *oldcb); 225f5b1c8a1SJohn Marino /* These functions can be used to get/set the platform-independant filename 226f5b1c8a1SJohn Marino * used for a DSO. NB: set will fail if the DSO is already loaded. */ 227f5b1c8a1SJohn Marino const char *DSO_get_filename(DSO *dso); 228f5b1c8a1SJohn Marino int DSO_set_filename(DSO *dso, const char *filename); 229f5b1c8a1SJohn Marino /* This function will invoke the DSO's name_converter callback to translate a 230f5b1c8a1SJohn Marino * filename, or if the callback isn't set it will instead use the DSO_METHOD's 231f5b1c8a1SJohn Marino * converter. If "filename" is NULL, the "filename" in the DSO itself will be 232f5b1c8a1SJohn Marino * used. If the DSO_FLAG_NO_NAME_TRANSLATION flag is set, then the filename is 233f5b1c8a1SJohn Marino * simply duplicated. NB: This function is usually called from within a 234f5b1c8a1SJohn Marino * DSO_METHOD during the processing of a DSO_load() call, and is exposed so that 235f5b1c8a1SJohn Marino * caller-created DSO_METHODs can do the same thing. A non-NULL return value 236f5b1c8a1SJohn Marino * will need to be free()'d. */ 237f5b1c8a1SJohn Marino char *DSO_convert_filename(DSO *dso, const char *filename); 238f5b1c8a1SJohn Marino /* This function will invoke the DSO's merger callback to merge two file 239f5b1c8a1SJohn Marino * specifications, or if the callback isn't set it will instead use the 240f5b1c8a1SJohn Marino * DSO_METHOD's merger. A non-NULL return value will need to be 241f5b1c8a1SJohn Marino * free()'d. */ 242f5b1c8a1SJohn Marino char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2); 243f5b1c8a1SJohn Marino /* If the DSO is currently loaded, this returns the filename that it was loaded 244f5b1c8a1SJohn Marino * under, otherwise it returns NULL. So it is also useful as a test as to 245f5b1c8a1SJohn Marino * whether the DSO is currently loaded. NB: This will not necessarily return 246f5b1c8a1SJohn Marino * the same value as DSO_convert_filename(dso, dso->filename), because the 247f5b1c8a1SJohn Marino * DSO_METHOD's load function may have tried a variety of filenames (with 248f5b1c8a1SJohn Marino * and/or without the aid of the converters) before settling on the one it 249f5b1c8a1SJohn Marino * actually loaded. */ 250f5b1c8a1SJohn Marino const char *DSO_get_loaded_filename(DSO *dso); 251f5b1c8a1SJohn Marino 252f5b1c8a1SJohn Marino void DSO_set_default_method(DSO_METHOD *meth); 253f5b1c8a1SJohn Marino DSO_METHOD *DSO_get_default_method(void); 254f5b1c8a1SJohn Marino DSO_METHOD *DSO_get_method(DSO *dso); 255f5b1c8a1SJohn Marino DSO_METHOD *DSO_set_method(DSO *dso, DSO_METHOD *meth); 256f5b1c8a1SJohn Marino 257f5b1c8a1SJohn Marino /* The all-singing all-dancing load function, you normally pass NULL 258f5b1c8a1SJohn Marino * for the first and third parameters. Use DSO_up and DSO_free for 259f5b1c8a1SJohn Marino * subsequent reference count handling. Any flags passed in will be set 260f5b1c8a1SJohn Marino * in the constructed DSO after its init() function but before the 261f5b1c8a1SJohn Marino * load operation. If 'dso' is non-NULL, 'flags' is ignored. */ 262f5b1c8a1SJohn Marino DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags); 263f5b1c8a1SJohn Marino 264f5b1c8a1SJohn Marino /* This function binds to a variable inside a shared library. */ 265f5b1c8a1SJohn Marino void *DSO_bind_var(DSO *dso, const char *symname); 266f5b1c8a1SJohn Marino 267f5b1c8a1SJohn Marino /* This function binds to a function inside a shared library. */ 268f5b1c8a1SJohn Marino DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname); 269f5b1c8a1SJohn Marino 270f5b1c8a1SJohn Marino /* This method is the default, but will beg, borrow, or steal whatever 271f5b1c8a1SJohn Marino * method should be the default on any particular platform (including 272f5b1c8a1SJohn Marino * DSO_METH_null() if necessary). */ 273f5b1c8a1SJohn Marino DSO_METHOD *DSO_METHOD_openssl(void); 274f5b1c8a1SJohn Marino 275f5b1c8a1SJohn Marino /* This method is defined for all platforms - if a platform has no 276f5b1c8a1SJohn Marino * DSO support then this will be the only method! */ 277f5b1c8a1SJohn Marino DSO_METHOD *DSO_METHOD_null(void); 278f5b1c8a1SJohn Marino 279f5b1c8a1SJohn Marino /* If DSO_DLFCN is defined, the standard dlfcn.h-style functions 280f5b1c8a1SJohn Marino * (dlopen, dlclose, dlsym, etc) will be used and incorporated into 281f5b1c8a1SJohn Marino * this method. If not, this method will return NULL. */ 282f5b1c8a1SJohn Marino DSO_METHOD *DSO_METHOD_dlfcn(void); 283f5b1c8a1SJohn Marino 284f5b1c8a1SJohn Marino /* This function writes null-terminated pathname of DSO module 285f5b1c8a1SJohn Marino * containing 'addr' into 'sz' large caller-provided 'path' and 286f5b1c8a1SJohn Marino * returns the number of characters [including trailing zero] 287f5b1c8a1SJohn Marino * written to it. If 'sz' is 0 or negative, 'path' is ignored and 288f5b1c8a1SJohn Marino * required amount of charachers [including trailing zero] to 289f5b1c8a1SJohn Marino * accommodate pathname is returned. If 'addr' is NULL, then 290f5b1c8a1SJohn Marino * pathname of cryptolib itself is returned. Negative or zero 291f5b1c8a1SJohn Marino * return value denotes error. 292f5b1c8a1SJohn Marino */ 293f5b1c8a1SJohn Marino int DSO_pathbyaddr(void *addr, char *path, int sz); 294f5b1c8a1SJohn Marino 295f5b1c8a1SJohn Marino /* This function should be used with caution! It looks up symbols in 296f5b1c8a1SJohn Marino * *all* loaded modules and if module gets unloaded by somebody else 297f5b1c8a1SJohn Marino * attempt to dereference the pointer is doomed to have fatal 298f5b1c8a1SJohn Marino * consequences. Primary usage for this function is to probe *core* 299f5b1c8a1SJohn Marino * system functionality, e.g. check if getnameinfo(3) is available 300f5b1c8a1SJohn Marino * at run-time without bothering about OS-specific details such as 301f5b1c8a1SJohn Marino * libc.so.versioning or where does it actually reside: in libc 302f5b1c8a1SJohn Marino * itself or libsocket. */ 303f5b1c8a1SJohn Marino void *DSO_global_lookup(const char *name); 304f5b1c8a1SJohn Marino 305f5b1c8a1SJohn Marino void ERR_load_DSO_strings(void); 306f5b1c8a1SJohn Marino 307f5b1c8a1SJohn Marino /* Error codes for the DSO functions. */ 308f5b1c8a1SJohn Marino 309f5b1c8a1SJohn Marino /* Function codes. */ 310f5b1c8a1SJohn Marino #define DSO_F_BEOS_BIND_FUNC 144 311f5b1c8a1SJohn Marino #define DSO_F_BEOS_BIND_VAR 145 312f5b1c8a1SJohn Marino #define DSO_F_BEOS_LOAD 146 313f5b1c8a1SJohn Marino #define DSO_F_BEOS_NAME_CONVERTER 147 314f5b1c8a1SJohn Marino #define DSO_F_BEOS_UNLOAD 148 315f5b1c8a1SJohn Marino #define DSO_F_DLFCN_BIND_FUNC 100 316f5b1c8a1SJohn Marino #define DSO_F_DLFCN_BIND_VAR 101 317f5b1c8a1SJohn Marino #define DSO_F_DLFCN_LOAD 102 318f5b1c8a1SJohn Marino #define DSO_F_DLFCN_MERGER 130 319f5b1c8a1SJohn Marino #define DSO_F_DLFCN_NAME_CONVERTER 123 320f5b1c8a1SJohn Marino #define DSO_F_DLFCN_UNLOAD 103 321f5b1c8a1SJohn Marino #define DSO_F_DL_BIND_FUNC 104 322f5b1c8a1SJohn Marino #define DSO_F_DL_BIND_VAR 105 323f5b1c8a1SJohn Marino #define DSO_F_DL_LOAD 106 324f5b1c8a1SJohn Marino #define DSO_F_DL_MERGER 131 325f5b1c8a1SJohn Marino #define DSO_F_DL_NAME_CONVERTER 124 326f5b1c8a1SJohn Marino #define DSO_F_DL_UNLOAD 107 327f5b1c8a1SJohn Marino #define DSO_F_DSO_BIND_FUNC 108 328f5b1c8a1SJohn Marino #define DSO_F_DSO_BIND_VAR 109 329f5b1c8a1SJohn Marino #define DSO_F_DSO_CONVERT_FILENAME 126 330f5b1c8a1SJohn Marino #define DSO_F_DSO_CTRL 110 331f5b1c8a1SJohn Marino #define DSO_F_DSO_FREE 111 332f5b1c8a1SJohn Marino #define DSO_F_DSO_GET_FILENAME 127 333f5b1c8a1SJohn Marino #define DSO_F_DSO_GET_LOADED_FILENAME 128 334f5b1c8a1SJohn Marino #define DSO_F_DSO_GLOBAL_LOOKUP 139 335f5b1c8a1SJohn Marino #define DSO_F_DSO_LOAD 112 336f5b1c8a1SJohn Marino #define DSO_F_DSO_MERGE 132 337f5b1c8a1SJohn Marino #define DSO_F_DSO_NEW_METHOD 113 338f5b1c8a1SJohn Marino #define DSO_F_DSO_PATHBYADDR 140 339f5b1c8a1SJohn Marino #define DSO_F_DSO_SET_FILENAME 129 340f5b1c8a1SJohn Marino #define DSO_F_DSO_SET_NAME_CONVERTER 122 341f5b1c8a1SJohn Marino #define DSO_F_DSO_UP_REF 114 342f5b1c8a1SJohn Marino #define DSO_F_GLOBAL_LOOKUP_FUNC 138 343f5b1c8a1SJohn Marino #define DSO_F_PATHBYADDR 137 344f5b1c8a1SJohn Marino #define DSO_F_VMS_BIND_SYM 115 345f5b1c8a1SJohn Marino #define DSO_F_VMS_LOAD 116 346f5b1c8a1SJohn Marino #define DSO_F_VMS_MERGER 133 347f5b1c8a1SJohn Marino #define DSO_F_VMS_UNLOAD 117 348f5b1c8a1SJohn Marino #define DSO_F_WIN32_BIND_FUNC 118 349f5b1c8a1SJohn Marino #define DSO_F_WIN32_BIND_VAR 119 350f5b1c8a1SJohn Marino #define DSO_F_WIN32_GLOBALLOOKUP 142 351f5b1c8a1SJohn Marino #define DSO_F_WIN32_GLOBALLOOKUP_FUNC 143 352f5b1c8a1SJohn Marino #define DSO_F_WIN32_JOINER 135 353f5b1c8a1SJohn Marino #define DSO_F_WIN32_LOAD 120 354f5b1c8a1SJohn Marino #define DSO_F_WIN32_MERGER 134 355f5b1c8a1SJohn Marino #define DSO_F_WIN32_NAME_CONVERTER 125 356f5b1c8a1SJohn Marino #define DSO_F_WIN32_PATHBYADDR 141 357f5b1c8a1SJohn Marino #define DSO_F_WIN32_SPLITTER 136 358f5b1c8a1SJohn Marino #define DSO_F_WIN32_UNLOAD 121 359f5b1c8a1SJohn Marino 360f5b1c8a1SJohn Marino /* Reason codes. */ 361f5b1c8a1SJohn Marino #define DSO_R_CTRL_FAILED 100 362f5b1c8a1SJohn Marino #define DSO_R_DSO_ALREADY_LOADED 110 363f5b1c8a1SJohn Marino #define DSO_R_EMPTY_FILE_STRUCTURE 113 364f5b1c8a1SJohn Marino #define DSO_R_FAILURE 114 365f5b1c8a1SJohn Marino #define DSO_R_FILENAME_TOO_BIG 101 366f5b1c8a1SJohn Marino #define DSO_R_FINISH_FAILED 102 367f5b1c8a1SJohn Marino #define DSO_R_INCORRECT_FILE_SYNTAX 115 368f5b1c8a1SJohn Marino #define DSO_R_LOAD_FAILED 103 369f5b1c8a1SJohn Marino #define DSO_R_NAME_TRANSLATION_FAILED 109 370f5b1c8a1SJohn Marino #define DSO_R_NO_FILENAME 111 371f5b1c8a1SJohn Marino #define DSO_R_NO_FILE_SPECIFICATION 116 372f5b1c8a1SJohn Marino #define DSO_R_NULL_HANDLE 104 373f5b1c8a1SJohn Marino #define DSO_R_SET_FILENAME_FAILED 112 374f5b1c8a1SJohn Marino #define DSO_R_STACK_ERROR 105 375f5b1c8a1SJohn Marino #define DSO_R_SYM_FAILURE 106 376f5b1c8a1SJohn Marino #define DSO_R_UNLOAD_FAILED 107 377f5b1c8a1SJohn Marino #define DSO_R_UNSUPPORTED 108 378f5b1c8a1SJohn Marino 379f5b1c8a1SJohn Marino #ifdef __cplusplus 380f5b1c8a1SJohn Marino } 381f5b1c8a1SJohn Marino #endif 382f5b1c8a1SJohn Marino #endif 383