aboutsummaryrefslogtreecommitdiff
path: root/elf
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-07-07 18:39:33 +0000
committerUlrich Drepper <drepper@redhat.com>1999-07-07 18:39:33 +0000
commit94e365c61202e2472c8aea42c7c95ce40f5b843c (patch)
tree15cf6a02604ab91d5aa1feeaeb338f0fc6b91f34 /elf
parent2556bfe6fdb5ccb4864e0249d5fdd475e4100c71 (diff)
downloadglibc-94e365c61202e2472c8aea42c7c95ce40f5b843c.zip
glibc-94e365c61202e2472c8aea42c7c95ce40f5b843c.tar.gz
glibc-94e365c61202e2472c8aea42c7c95ce40f5b843c.tar.bz2
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>
Diffstat (limited to 'elf')
-rw-r--r--elf/Makefile47
-rw-r--r--elf/Versions13
-rw-r--r--elf/dl-close.c3
-rw-r--r--elf/dl-open.c2
-rw-r--r--elf/dl-sym.c129
-rw-r--r--elf/dladdr.c29
-rw-r--r--elf/dlclose.c33
-rw-r--r--elf/dlerror.c146
-rw-r--r--elf/dlopen.c59
-rw-r--r--elf/dlopenold.c64
-rw-r--r--elf/dlsym.c100
-rw-r--r--elf/dlvsym.c116
-rw-r--r--elf/ldsodefs.h48
13 files changed, 147 insertions, 642 deletions
diff --git a/elf/Makefile b/elf/Makefile
index b5145ea..48012ee 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -22,7 +22,7 @@ subdir := elf
headers = elf.h bits/elfclass.h bits/dlfcn.h link.h dlfcn.h
routines = $(dl-routines) dl-open dl-close dl-symbol dl-support \
- dl-addr enbl-secure dl-profstub dl-origin dl-libc
+ dl-addr enbl-secure dl-profstub dl-origin dl-libc dl-sym
# The core dynamic linking functions are in libc for the static and
# profiled libraries.
@@ -35,24 +35,16 @@ elide-routines.os = $(dl-routines) dl-support enbl-secure
# ld.so uses those routines, plus some special stuff for being the program
# interpreter and operating independent of libc.
rtld-routines := rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
-distribute = $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
- dl-hash.h soinit.c sofini.c ldd.bash.in eval.c \
- genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
- dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
- testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
- testobj6.c testobj1_1.c failobj.c do-lookup.h \
- gen-trusted-dirs.awk
+distribute := $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
+ dl-hash.h soinit.c sofini.c ldd.bash.in \
+ genrtldtbl.awk atomicity.h dl-procinfo.h ldsodefs.h \
+ dl-librecon.h interp.c sln.c dl-dst.h hp-timing.h \
+ do-lookup.h sprof.c gen-trusted-dirs.awk \
+ testobj1.c testobj2.c testobj3.c testobj4.c testobj5.c \
+ testobj6.c testobj1_1.c failobj.c
include ../Makeconfig
-extra-libs = libdl
-extra-libs-others = $(extra-libs)
-libdl-routines := dlopen dlclose dlsym dlvsym dlerror dladdr
-ifeq ($(versioning),yes)
-libdl-routines += dlopenold
-libdl-shared-only-routines := dlopenold
-endif
-
before-compile = $(objpfx)trusted-dirs.h
ifeq ($(versioning),yes)
@@ -60,7 +52,7 @@ ld-map = $(common-objpfx)ld.so.map
endif
ifeq (yes,$(build-shared))
-extra-objs = $(rtld-routines:=.os) soinit.os sofini.os eval.os interp.os
+extra-objs = $(rtld-routines:=.os) soinit.os sofini.os interp.os
generated = librtld.os dl-allobjs.os ld.so trusted-dirs.h trusted-dirs.st
install-others = $(inst_slibdir)/$(rtld-installed-name)
install-bin = ldd
@@ -85,15 +77,8 @@ modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
testobj1_1 failobj
extra-objs += $(modules-names:=.os)
-ifeq ($(build-shared),yes)
-libdl = $(objpfx)libdl.so$(libdl.so-version)
-else
-libdl = $(objpfx)libdl.a
-endif
-
include ../Rules
-
ifeq (yes,$(build-shared))
# Make sure these things are built in the `make lib' pass so they can be used
# to run programs during the `make others' pass.
@@ -163,10 +148,6 @@ $(objpfx)trusted-dirs.st: Makefile $(..)Makeconfig
CPPFLAGS-dl-load.c = -I$(objpfx).
CFLAGS-dl-load.c += -Wno-uninitialized
-# Specify the dependencies of libdl.so; its commands come from the generic
-# rule to build a shared library.
-$(objpfx)libdl.so: $(objpfx)libdl_pic.a $(common-objpfx)libc.so $(objpfx)ld.so
-
ifeq (yes,$(build-shared))
$(inst_slibdir)/$(rtld-version-installed-name): $(objpfx)ld.so $(+force)
$(do-install-program)
@@ -209,9 +190,8 @@ $(objpfx)ldd: ldd.bash.in $(common-objpfx)soversions.mk \
chmod 555 $@.new
mv -f $@.new $@
-
$(objpfx)sprof: $(libdl)
-
+
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(modules-names)))
generated += $(addsuffix .so,$(modules-names))
@@ -251,14 +231,9 @@ $(objpfx)loadfail.out: $(objpfx)failobj.so
$(objpfx)multiload: $(libdl)
LDFLAGS-multiload = -rdynamic
-CFLAGS-multiload.c = -DOBJDIR=\"$(elf-objpfx)\"
+CFLAGS-multiload.c = -DOBJDIR=\"$(objpfx)\"
$(objpfx)multiload.out: $(objpfx)testobj1.so
$(objpfx)origtest: $(libdl)
$(objpfx)origtest.out: $(objpfx)testobj1.so
-
-# muwahaha
-
-LDFLAGS-dl.so = -Wl,-dynamic-linker,$(slibdir)/$(rtld-installed-name)
-$(objpfx)libdl.so: $(objpfx)eval.os
diff --git a/elf/Versions b/elf/Versions
index 8f1981e..c45ba04 100644
--- a/elf/Versions
+++ b/elf/Versions
@@ -7,6 +7,10 @@ libc {
# functions used in other libraries
_dl_mcount_wrapper; _dl_mcount_wrapper_check;
}
+ GLIBC_2.2 {
+ # functions used in other libraries
+ _dl_sym; _dl_vsym;
+ }
}
ld.so {
@@ -45,12 +49,3 @@ ld.so {
_dl_dst_count; _dl_dst_substitute;
}
}
-
-libdl {
- GLIBC_2.0 {
- dladdr; dlclose; dlerror; dlopen; dlsym;
- }
- GLIBC_2.1 {
- dlopen; dlvsym;
- }
-}
diff --git a/elf/dl-close.c b/elf/dl-close.c
index a738b11..324f49a 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -36,9 +36,10 @@ __libc_lock_define (extern, _dl_load_lock)
void
internal_function
-_dl_close (struct link_map *map)
+_dl_close (void *_map)
{
struct link_map **list;
+ struct link_map *map = _map;
unsigned nsearchlist;
unsigned int i;
diff --git a/elf/dl-open.c b/elf/dl-open.c
index a9d81c7..a3cd8a0 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -211,7 +211,7 @@ dl_open_worker (void *a)
}
-struct link_map *
+void *
internal_function
_dl_open (const char *file, int mode, const void *caller)
{
diff --git a/elf/dl-sym.c b/elf/dl-sym.c
new file mode 100644
index 0000000..441b54f
--- /dev/null
+++ b/elf/dl-sym.c
@@ -0,0 +1,129 @@
+/* Look up a symbol in a shared object loaded by `dlopen'.
+ Copyright (C) 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 <stddef.h>
+#include <setjmp.h>
+#include <libintl.h>
+
+#include <dlfcn.h>
+#include <ldsodefs.h>
+#include <dl-hash.h>
+
+void *
+internal_function
+_dl_sym (void *handle, const char *name, void *who)
+{
+ ElfW(Addr) loadbase;
+ const ElfW(Sym) *ref = NULL;
+
+ if (handle == RTLD_DEFAULT)
+ /* Search the global scope. */
+ loadbase = _dl_lookup_symbol (name, &ref, _dl_global_scope, NULL, 0);
+ else if (handle == RTLD_NEXT)
+ {
+ struct link_map *l, *match;
+ ElfW(Addr) caller = (ElfW(Addr)) who;
+
+ /* Find the highest-addressed object that CALLER is not below. */
+ match = NULL;
+ for (l = _dl_loaded; l; l = l->l_next)
+ if (caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
+ match = l;
+
+ if (! match)
+ _dl_signal_error (0, NULL, _("\
+RTLD_NEXT used in code not dynamically loaded"));
+
+ l = match;
+ while (l->l_loader)
+ l = l->l_loader;
+
+ loadbase = _dl_lookup_symbol_skip (name, &ref, l->l_local_scope,
+ NULL, match);
+ }
+ else
+ {
+ /* Search the scope of the given object. */
+ struct link_map *map = handle;
+ loadbase = _dl_lookup_symbol (name, &ref, map->l_local_scope,
+ map->l_name, 0);
+ }
+
+ if (loadbase)
+ return (void *) (loadbase + ref->st_value);
+
+ return NULL;
+}
+
+void *
+internal_function
+_dl_vsym (void *handle, const char *name, const char *version, void *who)
+{
+ ElfW(Addr) loadbase;
+ const ElfW(Sym) *ref = NULL;
+ struct r_found_version vers;
+
+ /* Compute hash value to the version string. */
+ vers.name = version;
+ vers.hidden = 1;
+ vers.hash = _dl_elf_hash (version);
+ /* We don't have a specific file where the symbol can be found. */
+ vers.filename = NULL;
+
+ if (handle == RTLD_DEFAULT)
+ /* Search the global scope. */
+ loadbase = _dl_lookup_versioned_symbol (name, &ref, _dl_global_scope,
+ NULL, &vers, 0);
+ else if (handle == RTLD_NEXT)
+ {
+ struct link_map *l, *match;
+ ElfW(Addr) caller = (ElfW(Addr)) who;
+
+ /* Find the highest-addressed object that CALLER is not below. */
+ match = NULL;
+ for (l = _dl_loaded; l; l = l->l_next)
+ if (caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
+ match = l;
+
+ if (! match)
+ _dl_signal_error (0, NULL, _("\
+RTLD_NEXT used in code not dynamically loaded"));
+
+ l = match;
+ while (l->l_loader)
+ l = l->l_loader;
+
+ loadbase = _dl_lookup_versioned_symbol_skip (name, &ref,
+ l->l_local_scope,
+ NULL, &vers, match);
+ }
+ else
+ {
+ /* Search the scope of the given object. */
+ struct link_map *map = handle;
+ loadbase = _dl_lookup_versioned_symbol (name, &ref,
+ map->l_local_scope,
+ map->l_name, &vers, 0);
+ }
+
+ if (loadbase)
+ return (void *) (loadbase + ref->st_value);
+
+ return NULL;
+}
diff --git a/elf/dladdr.c b/elf/dladdr.c
deleted file mode 100644
index 3456aae..0000000
--- a/elf/dladdr.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/* Locate the shared object symbol nearest a given address.
- Copyright (C) 1996, 1997, 1998 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>
-#include <stddef.h>
-#include <elf/ldsodefs.h>
-
-
-int
-dladdr (const void *address, Dl_info *info)
-{
- return _dl_addr (address, info);
-}
diff --git a/elf/dlclose.c b/elf/dlclose.c
deleted file mode 100644
index b25ca48..0000000
--- a/elf/dlclose.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Close a handle opened by `dlopen'.
- Copyright (C) 1995, 1996, 1997, 1998 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>
-#include <elf/ldsodefs.h>
-
-static void
-dlclose_doit (void *handle)
-{
- _dl_close (handle);
-}
-
-int
-dlclose (void *handle)
-{
- return _dlerror_run (dlclose_doit, handle) ? -1 : 0;
-}
diff --git a/elf/dlerror.c b/elf/dlerror.c
deleted file mode 100644
index 4716bdd..0000000
--- a/elf/dlerror.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/* Return error detail for failing <dlfcn.h> functions.
- Copyright (C) 1995, 1996, 1997, 1998 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>
-#include <stdio.h>
-#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
- {
- int errcode;
- char *errstring;
- };
-static struct dl_action_result last_result;
-static struct dl_action_result *static_buf;
-
-
-/* This is the key for the thread specific memory. */
-static __libc_key_t key;
-
-/* Destructor for the thread-specific data. */
-static void init (void);
-static void free_key_mem (void *mem);
-
-
-char *
-dlerror (void)
-{
- static char *buf;
- struct dl_action_result *result;
-
- if (buf)
- {
- free (buf);
- buf = NULL;
- }
-
- /* Get error string. */
- result = (struct dl_action_result *) __libc_getspecific (key);
- if (result == NULL)
- result = &last_result;
-
- if (! result->errstring)
- return NULL;
-
- if (result->errcode == 0)
- buf = result->errstring;
- else
- {
- if (__asprintf (&buf, "%s: %s",
- result->errstring, strerror (result->errcode)) == -1)
- buf = NULL;
-
- /* We don't need the error string anymore. */
- free (result->errstring);
- }
-
- /* Reset the error indicator. */
- result->errstring = NULL;
-
- return buf;
-}
-
-int
-internal_function
-_dlerror_run (void (*operate) (void *), void *args)
-{
- __libc_once_define (static, once);
- struct dl_action_result *result;
-
- /* If we have not yet initialized the buffer do it now. */
- __libc_once (once, init);
-
- /* Get error string and number. */
- if (static_buf != NULL)
- result = static_buf;
- else
- {
- /* We don't use the static buffer and so we have a key. Use it
- to get the thread-specific buffer. */
- result = __libc_getspecific (key);
- if (result == NULL)
- {
- result = (struct dl_action_result *) calloc (1, sizeof (*result));
- if (result == NULL)
- /* We are out of memory. Since this is no really critical
- situation we carry on by using the global variable.
- This might lead to conflicts between the threads but
- they soon all will have memory problems. */
- result = &last_result;
- else
- /* Set the tsd. */
- __libc_setspecific (key, result);
- }
- }
-
- if (result->errstring != NULL)
- /* Free the error string from the last failed command. This can
- happen if `dlerror' was not run after an error was found. */
- free (result->errstring);
-
- result->errcode = _dl_catch_error (&result->errstring, operate, args);
-
- return result->errstring != NULL;
-}
-
-
-/* Initialize buffers for results. */
-static void
-init (void)
-{
- if (__libc_key_create (&key, free_key_mem))
- /* Creating the key failed. This means something really went
- wrong. In any case use a static buffer which is better than
- nothing. */
- static_buf = &last_result;
-}
-
-
-/* Free the thread specific data, this is done if a thread terminates. */
-static void
-free_key_mem (void *mem)
-{
- free (mem);
- __libc_setspecific (key, NULL);
-}
diff --git a/elf/dlopen.c b/elf/dlopen.c
deleted file mode 100644
index b72300d..0000000
--- a/elf/dlopen.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Load a shared object at run time.
- 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>
-#include <stddef.h>
-#include <elf/ldsodefs.h>
-
-struct dlopen_args
-{
- /* The arguments for dlopen_doit. */
- const char *file;
- int mode;
- /* The return value of dlopen_doit. */
- struct link_map *new;
- /* Address of the caller. */
- const void *caller;
-};
-
-
-static void
-dlopen_doit (void *a)
-{
- struct dlopen_args *args = (struct dlopen_args *) a;
-
- args->new = _dl_open (args->file ?: "", args->mode, args->caller);
-}
-
-
-void *
-__dlopen_check (const char *file, int mode)
-{
- struct dlopen_args args;
- args.file = file;
- args.mode = mode;
- args.caller = __builtin_return_address (0);
-
- return _dlerror_run (dlopen_doit, &args) ? NULL : args.new;
-}
-#if defined PIC && defined DO_VERSIONING
-default_symbol_version (__dlopen_check, dlopen, GLIBC_2.1);
-#else
-weak_alias (__dlopen_check, dlopen)
-#endif
diff --git a/elf/dlopenold.c b/elf/dlopenold.c
deleted file mode 100644
index 661a405..0000000
--- a/elf/dlopenold.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/* Load a shared object at run time.
- 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>
-#include <stddef.h>
-#include <elf/ldsodefs.h>
-
-/* This file is for compatibility with glibc 2.0. Compile it only if
- versioning is used. */
-#if defined PIC && DO_VERSIONING
-
-struct dlopen_args
-{
- /* The arguments for dlopen_doit. */
- const char *file;
- int mode;
- /* The return value of dlopen_doit. */
- struct link_map *new;
- /* Address of the caller. */
- const void *caller;
-};
-
-
-static void
-dlopen_doit (void *a)
-{
- struct dlopen_args *args = (struct dlopen_args *) a;
-
- args->new = _dl_open (args->file ?: "", args->mode, args->caller);
-}
-
-
-void *
-__dlopen_nocheck (const char *file, int mode)
-{
- struct dlopen_args args;
- args.file = file;
- args.caller = __builtin_return_address (0);
-
- if ((mode & RTLD_BINDING_MASK) == 0)
- /* By default assume RTLD_LAZY. */
- mode |= RTLD_LAZY;
- args.mode = mode;
-
- return _dlerror_run (dlopen_doit, &args) ? NULL : args.new;
-}
-symbol_version (__dlopen_nocheck, dlopen, GLIBC_2.0);
-#endif
diff --git a/elf/dlsym.c b/elf/dlsym.c
deleted file mode 100644
index 6627ffc..0000000
--- a/elf/dlsym.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/* 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>
-#include <setjmp.h>
-#include <stddef.h>
-#include <libintl.h>
-#include <elf/ldsodefs.h>
-
-struct dlsym_args
-{
- /* The arguments to dlsym_doit. */
- void *handle;
- const char *name;
- struct r_found_version version;
- ElfW(Addr) caller;
- /* The return values of dlsym_doit. */
- ElfW(Addr) loadbase;
- const ElfW(Sym) *ref;
-};
-
-
-static void
-dlsym_doit (void *a)
-{
- struct dlsym_args *args = (struct dlsym_args *) a;
- args->ref = NULL;
-
- if (args->handle == RTLD_DEFAULT)
- /* Search the global scope. */
- args->loadbase = _dl_lookup_symbol (args->name, &args->ref,
- _dl_global_scope, NULL, 0);
- else if (args->handle == RTLD_NEXT)
- {
- struct link_map *l, *match;
-
- /* Find the highest-addressed object that CALLER is not below. */
- match = NULL;
- for (l = _dl_loaded; l; l = l->l_next)
- if (args->caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
- match = l;
-
- if (! match)
- _dl_signal_error (0, NULL, _("\
-RTLD_NEXT used in code not dynamically loaded"));
-
- l = match;
- while (l->l_loader)
- l = l->l_loader;
-
- args->loadbase = _dl_lookup_symbol_skip (args->name, &args->ref,
- l->l_local_scope, NULL, match);
-
- if (args->loadbase == 0)
- {
- /* This means that no such symbol is defined. In this case we
- have to provide a phony Elfxx_Sym entry since the value is
- referenced in `dlsym'. */
- static const ElfW(Sym) null_result;
-
- args->ref = &null_result;
- }
- }
- else
- {
- /* Search the scope of the given object. */
- struct link_map *map = args->handle;
- args->loadbase = _dl_lookup_symbol (args->name, &args->ref,
- map->l_local_scope, map->l_name, 0);
- }
-}
-
-
-void *
-dlsym (void *handle, const char *name)
-{
- struct dlsym_args args;
- args.caller = (ElfW(Addr)) __builtin_return_address (0);
- args.handle = handle;
- args.name = name;
-
- return (_dlerror_run (dlsym_doit, &args)
- ? NULL : (void *) (args.loadbase + args.ref->st_value));
-}
diff --git a/elf/dlvsym.c b/elf/dlvsym.c
deleted file mode 100644
index 68e099b..0000000
--- a/elf/dlvsym.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/* 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
- 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>
-#include <setjmp.h>
-#include <stddef.h>
-#include <libintl.h>
-#include <elf/ldsodefs.h>
-
-#include <dl-hash.h>
-
-struct dlvsym_args
-{
- /* The arguments to dlvsym_doit. */
- void *handle;
- const char *name;
- struct r_found_version version;
- ElfW(Addr) caller;
- /* The return values of dlvsym_doit. */
- ElfW(Addr) loadbase;
- const ElfW(Sym) *ref;
-};
-
-
-static void
-dlvsym_doit (void *a)
-{
- struct dlvsym_args *args = (struct dlvsym_args *)a;
- args->ref = NULL;
-
- if (args->handle == RTLD_DEFAULT)
- /* Search the global scope. */
- args->loadbase = _dl_lookup_versioned_symbol (args->name, &args->ref,
- _dl_global_scope,
- NULL, &args->version, 0);
- else if (args->handle == RTLD_NEXT)
- {
- struct link_map *l, *match;
-
- /* Find the highest-addressed object that CALLER is not below. */
- match = NULL;
- for (l = _dl_loaded; l; l = l->l_next)
- if (args->caller >= l->l_addr && (!match || match->l_addr < l->l_addr))
- match = l;
-
- if (! match)
- _dl_signal_error (0, NULL, _("\
-RTLD_NEXT used in code not dynamically loaded"));
-
- l = match;
- while (l->l_loader)
- l = l->l_loader;
-
- args->loadbase = _dl_lookup_versioned_symbol_skip (args->name,
- &args->ref,
- l->l_local_scope,
- NULL, &args->version,
- match);
-
- if (args->loadbase == 0)
- {
- /* This means that no such symbol is defined. In this case we
- have to provide a phony Elfxx_Sym entry since the value is
- referenced in `dlsym'. */
- static const ElfW(Sym) null_result;
-
- args->ref = &null_result;
- }
- }
- else
- {
- /* Search the scope of the given object. */
- struct link_map *map = args->handle;
- args->loadbase = _dl_lookup_versioned_symbol (args->name, &args->ref,
- map->l_local_scope,
- map->l_name,
- &args->version, 0);
- }
-}
-
-void *
-__dlvsym (void *handle, const char *name, const char *version_str)
-{
- struct dlvsym_args args;
-
- args.handle = handle;
- args.name = name;
- args.caller = (ElfW(Addr)) __builtin_return_address (0);
-
- /* Compute hash value to the version string. */
- args.version.name = version_str;
- args.version.hidden = 1;
- args.version.hash = _dl_elf_hash (version_str);
- /* We don't have a specific file where the symbol can be found. */
- args.version.filename = NULL;
-
- return (_dlerror_run (dlvsym_doit, &args)
- ? NULL : (void *) (args.loadbase + args.ref->st_value));
-}
-weak_alias (__dlvsym, dlvsym)
diff --git a/elf/ldsodefs.h b/elf/ldsodefs.h
index bd33ba1..844e479 100644
--- a/elf/ldsodefs.h
+++ b/elf/ldsodefs.h
@@ -215,17 +215,6 @@ extern void _dl_signal_cerror (int errcode,
const char *errstring)
internal_function;
-/* Call OPERATE, catching errors from `dl_signal_error'. If there is no
- error, *ERRSTRING is set to null. If there is an error, *ERRSTRING is
- set to a string constructed from the strings passed to _dl_signal_error,
- and the error code passed is the return value. ERRSTRING if nonzero
- points to a malloc'ed string which the caller has to free after use.
- ARGS is passed as argument to OPERATE. */
-extern int _dl_catch_error (char **errstring,
- void (*operate) (void *),
- void *args)
- internal_function;
-
/* Call OPERATE, receiving errors from `dl_signal_cerror'. Unlike
`_dl_catch_error' the operation is resumed after the OPERATE
function returns.
@@ -235,14 +224,6 @@ extern void _dl_receive_error (receiver_fct fct, void (*operate) (void *),
internal_function;
-/* Helper function for <dlfcn.h> functions. Runs the OPERATE function via
- _dl_catch_error. Returns zero for success, nonzero for failure; and
- arranges for `dlerror' to return the error details.
- ARGS is passed as argument to OPERATE. */
-extern int _dlerror_run (void (*operate) (void *), void *args)
- internal_function;
-
-
/* Open the shared object NAME and map in its segments.
LOADER's DT_RPATH is used in searching for NAME.
If the object is already opened, returns its existing map.
@@ -267,18 +248,6 @@ extern unsigned int _dl_map_object_deps (struct link_map *map,
extern void _dl_setup_hash (struct link_map *map) internal_function;
-/* Open the shared object NAME, relocate it, and run its initializer if it
- hasn't already been run. MODE is as for `dlopen' (see <dlfcn.h>). If
- the object is already opened, returns its existing map. */
-extern struct link_map *_dl_open (const char *name, int mode,
- const void *caller)
- internal_function;
-
-/* Close an object previously opened by _dl_open. */
-extern void _dl_close (struct link_map *map)
- internal_function;
-
-
/* Search loaded objects' symbol tables for a definition of the symbol
referred to by UNDEF. *SYM is the symbol table entry containing the
reference; it is replaced with the defining symbol, and the base load
@@ -324,10 +293,6 @@ extern ElfW(Addr) _dl_lookup_versioned_symbol_skip (const char *undef,
struct link_map *skip_this)
internal_function;
-/* Locate shared object containing the given address. */
-extern int _dl_addr (const void *address, Dl_info *info)
- internal_function;
-
/* Look up symbol NAME in MAP's scope and return its run-time address. */
extern ElfW(Addr) _dl_symbol_value (struct link_map *map, const char *name)
internal_function;
@@ -409,7 +374,6 @@ extern void _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc);
calling function. */
extern void _dl_mcount_wrapper (void *selfpc);
-
/* Show the members of the auxiliary array passed up from the kernel. */
extern void _dl_show_auxv (void) internal_function;
@@ -424,18 +388,6 @@ extern const struct r_strlenpair *_dl_important_hwcaps (const char *platform,
size_t *max_capstrlen)
internal_function;
-
-/* When we do profiling we have the problem that uses of `dlopen'ed
- objects don't use the PLT but instead use a pointer to the function.
- We still want to have profiling data and in these cases we must do
- the work of calling `_dl_mcount' ourself. The following macros
- helps do it. */
-#define _CALL_DL_FCT(fctp, args) \
- ({ if (_dl_profile_map != NULL) \
- _dl_mcount_wrapper (fctp); \
- (*fctp) args; \
- })
-
__END_DECLS
#endif /* ldsodefs.h */