Path: blob/main/crypto/krb5/src/util/verto/module.h
34907 views
/*1* Copyright 2011 Red Hat, Inc.2*3* Permission is hereby granted, free of charge, to any person4* obtaining a copy of this software and associated documentation files5* (the "Software"), to deal in the Software without restriction,6* including without limitation the rights to use, copy, modify, merge,7* publish, distribute, sublicense, and/or sell copies of the Software,8* and to permit persons to whom the Software is furnished to do so,9* subject to the following conditions:10*11* The above copyright notice and this permission notice shall be12* included in all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,15* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF16* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND17* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS18* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN19* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN20* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*/2324/* Determines if a symbol is present in a given module.25*26* @param modname The name of the module.27* @param symbname The name of the symbol.28* @return Non-zero if found, zero if not found.29*/30int31module_symbol_is_present(const char *modname, const char *symbname);3233/* Finds the file for a given symbol.34*35* If filename is non-null, the name of the file will be stored. This must36* be freed with free().37*38* @param addr The address to resolve.39* @param filename Where to store the name of the file.40* @return 0 on error, non-zero on success.41*/42int43module_get_filename_for_symbol(void *addr, char **filename);4445/* Closes a module.46*47* Does nothing if dll is NULL.48*49* @param dll The module to close.50*/51void52module_close(void *dll);535455/* Loads a module and extracts the given symbol.56*57* This function loads the module specified by filename, but does not resolve58* any of its symbol dependencies. Next is gets the symbol symbname and calls59* shouldload(). If shouldload() returns non-zero, the module is reloaded60* with full symbol resolution and stores the results in dll and symb.61*62* The job of shouldload() is to determine, based on the metadata in the63* symbol fetched, if the module should be fully loaded. The shouldload()64* callback MUST NOT attempt to call any functions in the module. This will65* crash on WIN32.66*67* If an error occurs, an error string will be allocated and returned. If68* allocation of this string fails, NULL will be returned. Since this is the69* same as the non-error case, you should additionally check if dll or symb70* is NULL.71*72* @param filename Path to the module73* @param symbname Symbol name to load from the file and pass to shouldload()74* @param shouldload Callback to determine whether to fullly load the module75* @param misc Opaque pointer to pass to shouldload()76* @param dll Where the module will be stored (can be NULL)77* @param symb Where the symbol will be stored (can be NULL)78* @return An error string.79*/80char *81module_load(const char *filename, const char *symbname,82int (*shouldload)(void *symb, void *misc, char **err), void *misc,83void **dll, void **symb);848586