From b3fc5f84d13573b9494fb1f0db9b5e80679e5098 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 28 Jun 1999 15:52:36 +0000 Subject: Update. * sysdeps/libm-ieee754/e_gamma_r.c: Initialize *signgamp for NaN returns. * sysdeps/libm-ieee754/e_gammaf_r.c: Likewise. * sysdeps/libm-ieee754/e_gammal_r.c: Likewise. Reported by John Reiser [PR libc/1185]. * elf/dl-dst.h: Fix typo. * elf/dl-open.c: Likewise. 1999-06-26 Zack Weinberg * elf/dl-libc.c: New file, provides three functions: __libc_dlopen, __libc_dlclose, __libc_dlsym. * include/dlfcn.h: Prototype them. Prototype _dl_addr. * elf/Makefile (routines): Add dl-libc.c. * elf/dl-profstub.c (_dl_mcount_wrapper): Change type of argument to void *. * elf/ldsodefs.h: Change proto and use of _dl_mcount_wrapper to match. * iconv/gconv.c: Include dlfcn.h. * iconv/gconv_db.c: Likewise. * malloc/mtrace.c: Likewise. Don't include ldsodefs.h. * iconv/gconv_int.h (struct __gconv_loaded_object): Change `handle' to a void *. (__gconv_find_func): Delete prototype. * iconv/gconv_dl.c: Don't include ldsodefs.h. Remove dlerror_run and related functions and structs. Use __libc_dlopen, __libc_dlsym, __libc_dlclose. * nss/nsswitch.c: Likewise. 1999-06-28 Ulrich Drepper --- nss/nsswitch.c | 77 +++++++--------------------------------------------------- 1 file changed, 9 insertions(+), 68 deletions(-) (limited to 'nss') diff --git a/nss/nsswitch.c b/nss/nsswitch.c index 0fac09ef65..f1250262ff 100644 --- a/nss/nsswitch.c +++ b/nss/nsswitch.c @@ -26,7 +26,6 @@ #include #include #include -#include /* We need some help from ld.so. */ #if !defined DO_STATIC_NSS || defined PIC # include @@ -245,60 +244,6 @@ __nss_configure_lookup (const char *dbname, const char *service_line) } -#if !defined DO_STATIC_NSS || defined PIC -static int -nss_dlerror_run (void (*operate) (void *), void *args) -{ - char *last_errstring = NULL; - int result; - - (void) _dl_catch_error (&last_errstring, operate, args); - - result = last_errstring != NULL; - if (result) - free (last_errstring); - - return result; -} - - -struct do_open_args -{ - /* Argument to do_open. */ - char *shlib_name; - service_user *ni; -}; - -struct get_sym_args -{ - /* Arguments to get_sym. */ - struct link_map *map; - char *name; - - /* Return values of get_sym. */ - ElfW(Addr) loadbase; - const ElfW(Sym) *ref; -}; - -static void -do_open (void *a) -{ - struct do_open_args *args = (struct do_open_args *) a; - /* Open and relocate the shared object. */ - args->ni->library->lib_handle = _dl_open (args->shlib_name, RTLD_LAZY, NULL); -} - -static void -get_sym (void *a) -{ - struct get_sym_args *args = (struct get_sym_args *) a; - args->ref = NULL; - args->loadbase = _dl_lookup_symbol (args->name, &args->ref, - args->map->l_local_scope, - args->map->l_name, 0); -} -#endif - /* Comparison function for searching NI->known tree. */ static int known_compare (const void *p1, const void *p2) @@ -376,18 +321,17 @@ __nss_lookup_function (service_user *ni, const char *fct_name) size_t shlen = (7 + strlen (ni->library->name) + 3 + strlen (__nss_shlib_revision) + 1); int saved_errno = errno; - struct do_open_args args; - args.shlib_name = __alloca (shlen); - args.ni = ni; + char shlib_name[shlen]; /* Construct shared object name. */ - __stpcpy (__stpcpy (__stpcpy (__stpcpy (args.shlib_name, + __stpcpy (__stpcpy (__stpcpy (__stpcpy (shlib_name, "libnss_"), ni->library->name), ".so"), __nss_shlib_revision); - if (nss_dlerror_run (do_open, &args) != 0) + ni->library->lib_handle = __libc_dlopen (shlib_name); + if (ni->library->lib_handle == NULL) { /* Failed to load the library. */ ni->library->lib_handle = (void *) -1l; @@ -400,22 +344,19 @@ __nss_lookup_function (service_user *ni, const char *fct_name) result = NULL; else { - /* Get the desired function. Again, GNU ld.so magic ahead. */ + /* Get the desired function. */ size_t namlen = (5 + strlen (ni->library->name) + 1 + strlen (fct_name) + 1); - struct get_sym_args args; - args.name = __alloca (namlen); - args.map = ni->library->lib_handle; + char name[namlen]; /* Construct the function name. */ - __stpcpy (__stpcpy (__stpcpy (__stpcpy (args.name, "_nss_"), + __stpcpy (__stpcpy (__stpcpy (__stpcpy (name, "_nss_"), ni->library->name), "_"), fct_name); /* Look up the symbol. */ - result = (nss_dlerror_run (get_sym, &args) ? NULL - : (void *) (args.loadbase + args.ref->st_value)); + result = __libc_dlsym (ni->library->lib_handle, name); } #else /* We can't get function address dynamically in static linking. */ @@ -796,7 +737,7 @@ free_mem (void) { service_library *oldl = library; - _dl_close (library->lib_handle); + __libc_dlclose (library->lib_handle); library = library->next; free (oldl); -- cgit 1.4.1