aboutsummaryrefslogtreecommitdiff
path: root/dlfcn
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2021-06-03 08:26:04 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-06-03 08:26:04 +0200
commit77f876c0e3ac08a98daa60fbad44061d4e4c3d14 (patch)
tree307d7f376167350fa336c4f37d21ee63b62bf40e /dlfcn
parent602252b553031d49c70467bfebcb1ba3bd264501 (diff)
downloadglibc-77f876c0e3ac08a98daa60fbad44061d4e4c3d14.tar
glibc-77f876c0e3ac08a98daa60fbad44061d4e4c3d14.tar.gz
glibc-77f876c0e3ac08a98daa60fbad44061d4e4c3d14.tar.bz2
glibc-77f876c0e3ac08a98daa60fbad44061d4e4c3d14.zip
dlfcn: Move dlsym into libc
The symbol was moved using scripts/move-symbol-to-libc.py. In elf/Makefile, remove the $(libdl) dependency from testobj1.so because it the unused libdl DSO now causes elf/tst-unused-deps to fail. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'dlfcn')
-rw-r--r--dlfcn/Makefile3
-rw-r--r--dlfcn/Versions3
-rw-r--r--dlfcn/dlsym.c59
-rw-r--r--dlfcn/sdlsym.c1
4 files changed, 39 insertions, 27 deletions
diff --git a/dlfcn/Makefile b/dlfcn/Makefile
index f0793468c7..b0f2e8a986 100644
--- a/dlfcn/Makefile
+++ b/dlfcn/Makefile
@@ -21,7 +21,7 @@ include ../Makeconfig
headers := bits/dlfcn.h dlfcn.h
extra-libs := libdl
-libdl-routines := dlopen dlsym dlvsym dladdr1 dlinfo \
+libdl-routines := dlopen dlvsym dladdr1 dlinfo \
dlmopen dlfcn
routines := $(patsubst %,s%,$(filter-out dlfcn,$(libdl-routines)))
elide-routines.os := $(routines)
@@ -29,6 +29,7 @@ routines += \
dladdr \
dlclose \
dlerror \
+ dlsym \
libc_dlerror_result \
extra-libs-others := libdl
diff --git a/dlfcn/Versions b/dlfcn/Versions
index f801fffb87..7d6b51a4e3 100644
--- a/dlfcn/Versions
+++ b/dlfcn/Versions
@@ -3,11 +3,13 @@ libc {
dladdr;
dlclose;
dlerror;
+ dlsym;
}
GLIBC_2.34 {
dladdr;
dlclose;
dlerror;
+ dlsym;
}
GLIBC_PRIVATE {
__libc_dlerror_result;
@@ -18,7 +20,6 @@ libc {
libdl {
GLIBC_2.0 {
dlopen;
- dlsym;
}
GLIBC_2.1 {
dlopen; dlvsym;
diff --git a/dlfcn/dlsym.c b/dlfcn/dlsym.c
index 26cea4ba6d..6b03b7b7ab 100644
--- a/dlfcn/dlsym.c
+++ b/dlfcn/dlsym.c
@@ -17,19 +17,9 @@
<https://www.gnu.org/licenses/>. */
#include <dlfcn.h>
-#include <stddef.h>
-
#include <ldsodefs.h>
-
-#if !defined SHARED && IS_IN (libdl)
-
-void *
-dlsym (void *handle, const char *name)
-{
- return __dlsym (handle, name, RETURN_ADDRESS (0));
-}
-
-#else
+#include <shlib-compat.h>
+#include <stddef.h>
struct dlsym_args
{
@@ -50,17 +40,11 @@ dlsym_doit (void *a)
args->sym = _dl_sym (args->handle, args->name, args->who);
}
-
-void *
-__dlsym (void *handle, const char *name DL_CALLER_DECL)
+static void *
+dlsym_implementation (void *handle, const char *name, void *dl_caller)
{
-# ifdef SHARED
- if (!rtld_active ())
- return _dlfcn_hook->dlsym (handle, name, DL_CALLER);
-# endif
-
struct dlsym_args args;
- args.who = DL_CALLER;
+ args.who = dl_caller;
args.handle = handle;
args.name = name;
@@ -73,7 +57,34 @@ __dlsym (void *handle, const char *name DL_CALLER_DECL)
return result;
}
-# ifdef SHARED
-strong_alias (__dlsym, dlsym)
+
+#ifdef SHARED
+void *
+___dlsym (void *handle, const char *name)
+{
+ if (!rtld_active ())
+ return _dlfcn_hook->dlsym (handle, name, RETURN_ADDRESS (0));
+ else
+ return dlsym_implementation (handle, name, RETURN_ADDRESS (0));
+}
+versioned_symbol (libc, ___dlsym, dlsym, GLIBC_2_34);
+
+# if OTHER_SHLIB_COMPAT (libdl, GLIBC_2_0, GLIBC_2_34)
+compat_symbol (libdl, ___dlsym, dlsym, GLIBC_2_0);
# endif
-#endif
+
+#else /* !SHARED */
+/* Also used with _dlfcn_hook. */
+void *
+__dlsym (void *handle, const char *name, void *dl_caller)
+{
+ return dlsym_implementation (handle, name, dl_caller);
+}
+
+void *
+___dlsym (void *handle, const char *name)
+{
+ return __dlsym (handle, name, RETURN_ADDRESS (0));
+}
+weak_alias (___dlsym, dlsym)
+#endif /* !SHARED */
diff --git a/dlfcn/sdlsym.c b/dlfcn/sdlsym.c
deleted file mode 100644
index 0234f23f8f..0000000000
--- a/dlfcn/sdlsym.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "dlsym.c"