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 --- iconv/gconv.c | 2 +- iconv/gconv_db.c | 1 + iconv/gconv_dl.c | 93 ++++++------------------------------------------------- iconv/gconv_int.h | 6 +--- 4 files changed, 12 insertions(+), 90 deletions(-) (limited to 'iconv') diff --git a/iconv/gconv.c b/iconv/gconv.c index 828db9d6f8..3120f00b3f 100644 --- a/iconv/gconv.c +++ b/iconv/gconv.c @@ -22,7 +22,7 @@ #include #include #include - +#include #include int diff --git a/iconv/gconv_db.c b/iconv/gconv_db.c index 727be41c25..39292994d8 100644 --- a/iconv/gconv_db.c +++ b/iconv/gconv_db.c @@ -25,6 +25,7 @@ #include #include +#include #include #include diff --git a/iconv/gconv_dl.c b/iconv/gconv_dl.c index dc90986077..7d327edc68 100644 --- a/iconv/gconv_dl.c +++ b/iconv/gconv_dl.c @@ -26,10 +26,8 @@ #include #include -#include #include - /* This is a tuning parameter. If a transformation module is not used anymore it gets not immediately unloaded. Instead we wait a certain number of load attempts for further modules. If none of the @@ -39,13 +37,10 @@ before unloading. */ #define TRIES_BEFORE_UNLOAD 2 - /* Array of loaded objects. This is shared by all threads so we have to use semaphores to access it. */ static void *loaded; - - /* Comparison function for searching `loaded_object' tree. */ static int known_compare (const void *p1, const void *p2) @@ -58,70 +53,6 @@ known_compare (const void *p1, const void *p2) return (intptr_t) s1->handle - (intptr_t) s2->handle; } - -static void -do_open (void *a) -{ - struct __gconv_loaded_object *args = (struct __gconv_loaded_object *) a; - /* Open and relocate the shared object. */ - args->handle = _dl_open (args->name, RTLD_LAZY, NULL); -} - - -static int -internal_function -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 get_sym_args -{ - /* Arguments to get_sym. */ - struct link_map *map; - const char *name; - - /* Return values of get_sym. */ - ElfW(Addr) loadbase; - const ElfW(Sym) *ref; -}; - -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); -} - - -void * -internal_function -__gconv_find_func (void *handle, const char *name) -{ - struct get_sym_args args; - - args.map = handle; - args.name = name; - - return (dlerror_run (get_sym, &args) ? NULL - : (void *) (args.loadbase + args.ref->st_value)); -} - - - /* Open the gconv database if necessary. A non-negative return value means success. */ struct __gconv_loaded_object * @@ -170,9 +101,10 @@ __gconv_find_shlib (const char *name) { if (found->counter < -TRIES_BEFORE_UNLOAD) { - if (dlerror_run (do_open, found) == 0) + found->handle = __libc_dlopen (found->name); + if (found->handle != NULL) { - found->fct = __gconv_find_func (found->handle, "gconv"); + found->fct = __libc_dlsym (found->handle, "gconv"); if (found->fct == NULL) { /* Argh, no conversion function. There is something @@ -182,10 +114,8 @@ __gconv_find_shlib (const char *name) } else { - found->init_fct = __gconv_find_func (found->handle, - "gconv_init"); - found->end_fct = __gconv_find_func (found->handle, - "gconv_end"); + found->init_fct = __libc_dlsym (found->handle, "gconv_init"); + found->end_fct = __libc_dlsym (found->handle, "gconv_end"); /* We have succeeded in loading the shared object. */ found->counter = 1; @@ -224,11 +154,8 @@ do_release_shlib (const void *nodep, VISIT value, int level) { if (--obj->counter < -TRIES_BEFORE_UNLOAD && obj->handle != NULL) { - /* Unload the shared object. We don't use the trick to - catch errors since in the case an error is signalled - something is really wrong. */ - _dl_close (obj->handle); - + /* Unload the shared object. */ + __libc_dlclose (obj->handle); obj->handle = NULL; } } @@ -258,11 +185,9 @@ do_release_all (void *nodep) { struct __gconv_loaded_object *obj = (struct __gconv_loaded_object *) nodep; - /* Unload the shared object. We don't use the trick to - catch errors since in the case an error is signalled - something is really wrong. */ + /* Unload the shared object. */ if (obj->handle != NULL) - _dl_close (obj->handle); + __libc_dlclose (obj->handle); free (obj); } diff --git a/iconv/gconv_int.h b/iconv/gconv_int.h index 29f495c30f..6048319372 100644 --- a/iconv/gconv_int.h +++ b/iconv/gconv_int.h @@ -51,7 +51,7 @@ struct __gconv_loaded_object int counter; /* The handle for the shared object. */ - struct link_map *handle; + void *handle; /* Pointer to the functions the module defines. */ __gconv_fct fct; @@ -135,10 +135,6 @@ extern int __gconv_close_transform (struct __gconv_step *__steps, extern struct __gconv_loaded_object *__gconv_find_shlib (const char *__name) internal_function; -/* Find function named NAME in shared object referenced by HANDLE. */ -void *__gconv_find_func (void *handle, const char *name) - internal_function; - /* Release shared object. If no further reference is available unload the object. */ extern int __gconv_release_shlib (struct __gconv_loaded_object *__handle) -- cgit 1.4.1