diff options
| author | Ulrich Drepper <drepper@redhat.com> | 1999-07-07 18:39:33 +0000 |
|---|---|---|
| committer | Ulrich Drepper <drepper@redhat.com> | 1999-07-07 18:39:33 +0000 |
| commit | 94e365c61202e2472c8aea42c7c95ce40f5b843c (patch) | |
| tree | 15cf6a02604ab91d5aa1feeaeb338f0fc6b91f34 | |
| parent | 2556bfe6fdb5ccb4864e0249d5fdd475e4100c71 (diff) | |
| download | glibc-94e365c61202e2472c8aea42c7c95ce40f5b843c.tar.xz glibc-94e365c61202e2472c8aea42c7c95ce40f5b843c.zip | |
Update.
* sysdeps/gnu/Makefile (libdl-routines): Add eval.
1999-07-06 Zack Weinberg <zack@rabi.columbia.edu>
* dlfcn: New directory. Move the following files from elf:
dladdr.c, dlclose.c, dlerror.c, dlfcn.h, dlopen.c,
dlopenold.c, dlsym.c, dlvsym.c.
* dlfcn/Makefile: New file.
* dlfcn/Versions: New file.
* dlfcn/dlsym.c: All ELF-specific code split out to new
function _dl_sym.
* dlfcn/dlvsym.c: All ELF-specific code split out to new
function _dl_vsym.
* elf/dl-sym.c: New file. _dl_sym and _dl_vsym are
implemented here.
* dlfcn/dladdr.c: Remove all references to ELF data structures
or headers.
* dlfcn/dlclose.c: Likewise.
* dlfcn/dlerror.c: Likewise.
* dlfcn/dlopen.c: Likewise.
* dlfcn/dlopenold.c: Likewise.
* Makeconfig (dlfcn): New variable - set to `dlfcn' if elf is
yes, empty otherwise.
(libdl): Set to dlfcn/libdl.so or libdl.a if elf is yes,
depending on build-shared.
(subdirs): Add $(dlfcn).
(rpath-dirs): Add dlfcn.
* elf/Makefile: Remove all references to libdl or its
components, except the ones relating to the test cases.
(routines): Add dl-sym.
* elf/Versions (libc): Add _dl_sym and _dl_vsym for GLIBC_2.2.
(libdl): Delete.
* elf/dl-close.c (_dl_close): Change argument to void *.
* elf/dl-open.c (_dl_open): Change return type to void *.
* elf/eval.c: Removed.
* elf/ldsodefs.h: Move prototypes of _dl_catch_error,
_dlerror_run, _dl_open, _dl_close, _dl_addr, and
_dl_mcount_wrapper_check to include/dlfcn.h. Delete
_CALL_DL_FCT macro.
* include/dlfcn.h: Also prototype _dl_sym and _dl_vsym here.
Include real header from dlfcn directory.
* include/ldsodefs.h: Removed.
* grp/initgroups.c: Use DL_CALL_FCT not _CALL_DL_FCT.
* nss/getXXbyYY_r.c: Likewise.
* nss/getXXent_r.c: Likewise.
* iconv/gconv.c: Likewise. Don't include ldsodefs.h.
* iconv/gconv_db.c: Likewise. Don't include ldsodefs.h.
* iconv/skeleton.c: Don't include ldsodefs.h.
* nss/nsswitch.h: Don't include ldsodefs.h. Include dlfcn.h.
1999-07-07 Ulrich Drepper <drepper@cygnus.com>
| -rw-r--r-- | ChangeLog | 56 | ||||
| -rw-r--r-- | Makeconfig | 17 | ||||
| -rw-r--r-- | dlfcn/Makefile | 34 | ||||
| -rw-r--r-- | dlfcn/Versions | 8 | ||||
| -rw-r--r-- | dlfcn/dladdr.c (renamed from elf/dladdr.c) | 5 | ||||
| -rw-r--r-- | dlfcn/dlclose.c (renamed from elf/dlclose.c) | 3 | ||||
| -rw-r--r-- | dlfcn/dlerror.c (renamed from elf/dlerror.c) | 2 | ||||
| -rw-r--r-- | dlfcn/dlfcn.h | 100 | ||||
| -rw-r--r-- | dlfcn/dlopen.c (renamed from elf/dlopen.c) | 5 | ||||
| -rw-r--r-- | dlfcn/dlopenold.c (renamed from elf/dlopenold.c) | 5 | ||||
| -rw-r--r-- | dlfcn/dlsym.c | 51 | ||||
| -rw-r--r-- | dlfcn/dlvsym.c | 55 | ||||
| -rw-r--r-- | elf/Makefile | 47 | ||||
| -rw-r--r-- | elf/Versions | 13 | ||||
| -rw-r--r-- | elf/dl-close.c | 3 | ||||
| -rw-r--r-- | elf/dl-open.c | 2 | ||||
| -rw-r--r-- | elf/dl-sym.c | 129 | ||||
| -rw-r--r-- | elf/dlsym.c | 100 | ||||
| -rw-r--r-- | elf/dlvsym.c | 116 | ||||
| -rw-r--r-- | elf/ldsodefs.h | 48 | ||||
| -rw-r--r-- | grp/initgroups.c | 9 | ||||
| -rw-r--r-- | iconv/gconv.c | 5 | ||||
| -rw-r--r-- | iconv/gconv_db.c | 7 | ||||
| -rw-r--r-- | iconv/skeleton.c | 2 | ||||
| -rw-r--r-- | include/dlfcn.h | 48 | ||||
| -rw-r--r-- | include/ldsodefs.h | 15 | ||||
| -rw-r--r-- | nss/getXXbyYY_r.c | 2 | ||||
| -rw-r--r-- | nss/getXXent_r.c | 8 | ||||
| -rw-r--r-- | nss/nsswitch.h | 3 | ||||
| -rw-r--r-- | sysdeps/gnu/Makefile | 5 | ||||
| -rw-r--r-- | sysdeps/gnu/eval.c | 138 |
31 files changed, 674 insertions, 367 deletions
@@ -1,5 +1,61 @@ 1999-07-07 Ulrich Drepper <drepper@cygnus.com> + * sysdeps/gnu/Makefile (libdl-routines): Add eval. + +1999-07-06 Zack Weinberg <zack@rabi.columbia.edu> + + * dlfcn: New directory. Move the following files from elf: + dladdr.c, dlclose.c, dlerror.c, dlfcn.h, dlopen.c, + dlopenold.c, dlsym.c, dlvsym.c. + * dlfcn/Makefile: New file. + * dlfcn/Versions: New file. + * dlfcn/dlsym.c: All ELF-specific code split out to new + function _dl_sym. + * dlfcn/dlvsym.c: All ELF-specific code split out to new + function _dl_vsym. + * elf/dl-sym.c: New file. _dl_sym and _dl_vsym are + implemented here. + + * dlfcn/dladdr.c: Remove all references to ELF data structures + or headers. + * dlfcn/dlclose.c: Likewise. + * dlfcn/dlerror.c: Likewise. + * dlfcn/dlopen.c: Likewise. + * dlfcn/dlopenold.c: Likewise. + + * Makeconfig (dlfcn): New variable - set to `dlfcn' if elf is + yes, empty otherwise. + (libdl): Set to dlfcn/libdl.so or libdl.a if elf is yes, + depending on build-shared. + (subdirs): Add $(dlfcn). + (rpath-dirs): Add dlfcn. + * elf/Makefile: Remove all references to libdl or its + components, except the ones relating to the test cases. + (routines): Add dl-sym. + * elf/Versions (libc): Add _dl_sym and _dl_vsym for GLIBC_2.2. + (libdl): Delete. + + * elf/dl-close.c (_dl_close): Change argument to void *. + * elf/dl-open.c (_dl_open): Change return type to void *. + * elf/eval.c: Removed. + * elf/ldsodefs.h: Move prototypes of _dl_catch_error, + _dlerror_run, _dl_open, _dl_close, _dl_addr, and + _dl_mcount_wrapper_check to include/dlfcn.h. Delete + _CALL_DL_FCT macro. + * include/dlfcn.h: Also prototype _dl_sym and _dl_vsym here. + Include real header from dlfcn directory. + * include/ldsodefs.h: Removed. + + * grp/initgroups.c: Use DL_CALL_FCT not _CALL_DL_FCT. + * nss/getXXbyYY_r.c: Likewise. + * nss/getXXent_r.c: Likewise. + * iconv/gconv.c: Likewise. Don't include ldsodefs.h. + * iconv/gconv_db.c: Likewise. Don't include ldsodefs.h. + * iconv/skeleton.c: Don't include ldsodefs.h. + * nss/nsswitch.h: Don't include ldsodefs.h. Include dlfcn.h. + +1999-07-07 Ulrich Drepper <drepper@cygnus.com> + * sysdeps/generic/setenv.c: Describe problem. * malloc/malloc.c (request2size): Also set errno if failing. diff --git a/Makeconfig b/Makeconfig index 6ae27e9dc6..e1e53605ab 100644 --- a/Makeconfig +++ b/Makeconfig @@ -415,7 +415,7 @@ else default-rpath = $(libdir) endif # This is how to find at build-time things that will be installed there. -rpath-dirs = math elf nss nis db2 rt resolv +rpath-dirs = math elf dlfcn nss nis db2 rt resolv rpath-link = \ $(common-objdir):$(subst $(empty) ,:,$(patsubst ../$(subdir),.,$(rpath-dirs:%=$(common-objpfx)%))) elfobjdir := $(patsubst ../$(subdir),.,$(common-objpfx)elf) @@ -746,6 +746,19 @@ endif -include $(common-objpfx)sysd-dirs +ifeq ($(elf),yes) +dlfcn = dlfcn +ifeq ($(build-shared),yes) +libdl = $(common-objpfx)dlfcn/libdl.so$(libdl.so-version) +else +libdl = $(common-objpfx)dlfcn/libdl.a +endif +else +# No ELF - no libdl, at least for now. +dlfcn = +libdl = +endif + # These are the subdirectories containing the library source. The order # is more or less arbitrary. The sorting step will take care of the # dependencies. Only the $(binfmt-subdir) should always be kept at the @@ -755,7 +768,7 @@ all-subdirs = csu assert ctype db db2 locale intl catgets math setjmp signal\ grp pwd posix io termios resource misc socket sysvipc gmon \ gnulib iconv iconvdata wctype manual shadow md5-crypt po argp \ $(add-ons) nss localedata timezone rt debug $(sysdep-subdirs) \ - $(binfmt-subdir) + $(dlfcn) $(binfmt-subdir) all-subdirs := $(filter-out $(sysdep-inhibit-subdirs),$(all-subdirs)) ifeq ($(sysd-dirs-done),t) diff --git a/dlfcn/Makefile b/dlfcn/Makefile new file mode 100644 index 0000000000..ee8203cf68 --- /dev/null +++ b/dlfcn/Makefile @@ -0,0 +1,34 @@ +# Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU Library General Public +# License along with the GNU C Library; see the file COPYING.LIB. If not, +# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +subdir := dlfcn +headers := dlfcn.h +extra-libs := libdl +libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr +distribute := dlopenold.c + +extra-libs-others := libdl + +include ../Makeconfig + +ifeq ($(versioning),yes) +libdl-routines += dlopenold +libdl-shared-only-routines := dlopenold +endif + +include ../Rules diff --git a/dlfcn/Versions b/dlfcn/Versions new file mode 100644 index 0000000000..b99822ad08 --- /dev/null +++ b/dlfcn/Versions @@ -0,0 +1,8 @@ +libdl { + GLIBC_2.0 { + dladdr; dlclose; dlerror; dlopen; dlsym; + } + GLIBC_2.1 { + dlopen; dlvsym; + } +} diff --git a/elf/dladdr.c b/dlfcn/dladdr.c index 3456aae9ad..2bcc25e2fd 100644 --- a/elf/dladdr.c +++ b/dlfcn/dladdr.c @@ -1,5 +1,5 @@ /* Locate the shared object symbol nearest a given address. - Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,9 +18,6 @@ Boston, MA 02111-1307, USA. */ #include <dlfcn.h> -#include <stddef.h> -#include <elf/ldsodefs.h> - int dladdr (const void *address, Dl_info *info) diff --git a/elf/dlclose.c b/dlfcn/dlclose.c index b25ca48d65..dea2391128 100644 --- a/elf/dlclose.c +++ b/dlfcn/dlclose.c @@ -1,5 +1,5 @@ /* Close a handle opened by `dlopen'. - Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -18,7 +18,6 @@ Boston, MA 02111-1307, USA. */ #include <dlfcn.h> -#include <elf/ldsodefs.h> static void dlclose_doit (void *handle) diff --git a/elf/dlerror.c b/dlfcn/dlerror.c index 4716bdd272..c43d511156 100644 --- a/elf/dlerror.c +++ b/dlfcn/dlerror.c @@ -22,8 +22,6 @@ #include <stdlib.h> #include <string.h> #include <bits/libc-lock.h> -#include <elf/ldsodefs.h> - /* Type for storing results of dynamic loading actions. */ struct dl_action_result diff --git a/dlfcn/dlfcn.h b/dlfcn/dlfcn.h new file mode 100644 index 0000000000..76fdc3c1c9 --- /dev/null +++ b/dlfcn/dlfcn.h @@ -0,0 +1,100 @@ +/* User functions for run-time dynamic loading. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _DLFCN_H +#define _DLFCN_H 1 + +#include <features.h> +#define __need_NULL +#include <stddef.h> + +/* Collect various system dependent definitions and declarations. */ +#include <bits/dlfcn.h> + +/* If the first argument of `dlsym' or `dlvsym' is set to RTLD_NEXT + the run-time address of the symbol called NAME in the next shared + object is returned. The "next" relation is defined by the order + the shared objects were loaded. */ +#define RTLD_NEXT ((void *) -1l) + +/* If the first argument to `dlsym' or `dlvsym' is set to RTLD_DEFAULT + the run-time address of the symbol called NAME in the global scope + is returned. */ +#define RTLD_DEFAULT NULL + +__BEGIN_DECLS + +/* Open the shared object FILE and map it in; return a handle that can be + passed to `dlsym' to get symbol values from it. */ +extern void *dlopen __P ((__const char *__file, int __mode)); + +/* Unmap and close a shared object opened by `dlopen'. + The handle cannot be used again after calling `dlclose'. */ +extern int dlclose __P ((void *__handle)); + +/* Find the run-time address in the shared object HANDLE refers to + of the symbol called NAME. */ +extern void *dlsym __P ((void *__restrict __handle, + __const char *__restrict __name)); + +#ifdef __USE_GNU +/* Find the run-time address in the shared object HANDLE refers to + of the symbol called NAME with VERSION. */ +extern void *dlvsym __P ((void *__restrict __handle, + __const char *__restrict __name, + __const char *__restrict __version)); +#endif + +/* When any of the above functions fails, call this function + to return a string describing the error. Each call resets + the error string so that a following call returns null. */ +extern char *dlerror __P ((void)); + +#ifdef __USE_GNU +/* Fill in *INFO with the following information about ADDRESS. + Returns 0 iff no shared object's segments contain that address. */ +typedef struct + { + __const char *dli_fname; /* File name of defining object. */ + void *dli_fbase; /* Load address of that object. */ + __const char *dli_sname; /* Name of nearest symbol. */ + void *dli_saddr; /* Exact value of nearest symbol. */ + } Dl_info; +extern int dladdr __P ((const void *__address, Dl_info *__info)); + +/* To support profiling of shared objects it is a good idea to call + the function found using `dlsym' using the following macro since + these calls do not use the PLT. But this would mean the dynamic + loader has no chance to find out when the function is called. The + macro applies the necessary magic so that profiling is possible. + Rewrite + foo = (*fctp) (arg1, arg2); + into + foo = DL_CALL_FCT (fctp, (arg1, arg2)); +*/ +# define DL_CALL_FCT(fctp, args) \ + (_dl_mcount_wrapper_check (fctp), (*(fctp)) args) + +/* This function calls the profiling functions. */ +extern void _dl_mcount_wrapper_check __P ((void *__selfpc)); +#endif + +__END_DECLS + +#endif /* dlfcn.h */ diff --git a/elf/dlopen.c b/dlfcn/dlopen.c index b72300df5c..cb49e6b142 100644 --- a/elf/dlopen.c +++ b/dlfcn/dlopen.c @@ -18,8 +18,6 @@ Boston, MA 02111-1307, USA. */ #include <dlfcn.h> -#include <stddef.h> -#include <elf/ldsodefs.h> struct dlopen_args { @@ -27,12 +25,11 @@ struct dlopen_args const char *file; int mode; /* The return value of dlopen_doit. */ - struct link_map *new; + void *new; /* Address of the caller. */ const void *caller; }; - static void dlopen_doit (void *a) { diff --git a/elf/dlopenold.c b/dlfcn/dlopenold.c index 661a40579a..f453cfb881 100644 --- a/elf/dlopenold.c +++ b/dlfcn/dlopenold.c @@ -18,8 +18,6 @@ Boston, MA 02111-1307, USA. */ #include <dlfcn.h> -#include <stddef.h> -#include <elf/ldsodefs.h> /* This file is for compatibility with glibc 2.0. Compile it only if versioning is used. */ @@ -31,7 +29,7 @@ struct dlopen_args const char *file; int mode; /* The return value of dlopen_doit. */ - struct link_map *new; + void *new; /* Address of the caller. */ const void *caller; }; @@ -45,7 +43,6 @@ dlopen_doit (void *a) args->new = _dl_open (args->file ?: "", args->mode, args->caller); } - void * __dlopen_nocheck (const char *file, int mode) { diff --git a/dlfcn/dlsym.c b/dlfcn/dlsym.c new file mode 100644 index 0000000000..9a8fcdfbe6 --- /dev/null +++ b/dlfcn/dlsym.c @@ -0,0 +1,51 @@ +/* Look up a symbol in a shared object loaded by `dlopen'. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include <dlfcn.h> + +struct dlsym_args +{ + /* The arguments to dlsym_doit. */ + void *handle; + const char *name; + void *who; + + /* The return value of dlsym_doit. */ + void *sym; +}; + +static void +dlsym_doit (void *a) +{ + struct dlsym_args *args = (struct dlsym_args *) a; + + args->sym = _dl_sym (args->handle, args->name, args->who); +} + + +void * +dlsym (void *handle, const char *name) +{ + struct dlsym_args args; + args.who = __builtin_return_address (0); + args.handle = handle; + args.name = name; + + return (_dlerror_run (dlsym_doit, &args) ? NULL : args.sym); +} diff --git a/dlfcn/dlvsym.c b/dlfcn/dlvsym.c new file mode 100644 index 0000000000..a279b95ae9 --- /dev/null +++ b/dlfcn/dlvsym.c @@ -0,0 +1,55 @@ +/* Look up a versioned symbol in a shared object loaded by `dlopen'. + Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the |
