aboutsummaryrefslogtreecommitdiff
path: root/dlfcn/dlsym.c
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/dlsym.c
parent602252b553031d49c70467bfebcb1ba3bd264501 (diff)
downloadglibc-77f876c0e3ac08a98daa60fbad44061d4e4c3d14.tar.xz
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/dlsym.c')
-rw-r--r--dlfcn/dlsym.c59
1 files changed, 35 insertions, 24 deletions
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 */