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
commit0c1c3a771eceec46e66ce1183cf988e2303bd373 (patch)
treeaddf888256dd2498bcc2f220339b981e7e096d87 /dlfcn
parentadd8d7ea01d5a22c2d7d184240dda6a7767e54e8 (diff)
downloadglibc-0c1c3a771eceec46e66ce1183cf988e2303bd373.zip
glibc-0c1c3a771eceec46e66ce1183cf988e2303bd373.tar.gz
glibc-0c1c3a771eceec46e66ce1183cf988e2303bd373.tar.bz2
dlfcn: Move dlopen into libc
The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'dlfcn')
-rw-r--r--dlfcn/Makefile8
-rw-r--r--dlfcn/Versions7
-rw-r--r--dlfcn/dlfcn.c16
-rw-r--r--dlfcn/dlopen.c82
-rw-r--r--dlfcn/dlopenold.c4
-rw-r--r--dlfcn/sdlopen.c1
6 files changed, 67 insertions, 51 deletions
diff --git a/dlfcn/Makefile b/dlfcn/Makefile
index 08d92f8..a471d86 100644
--- a/dlfcn/Makefile
+++ b/dlfcn/Makefile
@@ -21,8 +21,7 @@ include ../Makeconfig
headers := bits/dlfcn.h dlfcn.h
extra-libs := libdl
-libdl-routines := dlopen \
- dlfcn
+libdl-routines := dlfcn
routines := $(patsubst %,s%,$(filter-out dlfcn,$(libdl-routines)))
elide-routines.os := $(routines)
routines += \
@@ -32,6 +31,7 @@ routines += \
dlerror \
dlinfo \
dlmopen \
+ dlopen \
dlsym \
dlvsym \
libc_dlerror_result \
@@ -39,8 +39,8 @@ routines += \
extra-libs-others := libdl
ifeq ($(build-shared),yes)
-libdl-routines += dlopenold
-libdl-shared-only-routines := dlopenold dlfcn
+routines += dlopenold
+shared-only-routines := dlopenold dlfcn
endif
ifeq (yes,$(build-shared))
diff --git a/dlfcn/Versions b/dlfcn/Versions
index 3c4fa27..cc34eb8 100644
--- a/dlfcn/Versions
+++ b/dlfcn/Versions
@@ -3,9 +3,11 @@ libc {
dladdr;
dlclose;
dlerror;
+ dlopen;
dlsym;
}
GLIBC_2.1 {
+ dlopen;
dlvsym;
}
GLIBC_2.3.3 {
@@ -22,6 +24,7 @@ libc {
dlerror;
dlinfo;
dlmopen;
+ dlopen;
dlsym;
dlvsym;
}
@@ -33,10 +36,10 @@ libc {
}
libdl {
GLIBC_2.0 {
- dlopen;
+ __libdl_version_placeholder;
}
GLIBC_2.1 {
- dlopen;
+ __libdl_version_placeholder;
}
GLIBC_2.3.3 {
__libdl_version_placeholder;
diff --git a/dlfcn/dlfcn.c b/dlfcn/dlfcn.c
index 55ecfca..ef750bc 100644
--- a/dlfcn/dlfcn.c
+++ b/dlfcn/dlfcn.c
@@ -48,14 +48,22 @@ __libdl_version_placeholder_1 (void)
{
}
-#if SHLIB_COMPAT (libdl, GLIBC_2_3_3, GLIBC_2_34) \
- && ABI_libdl_GLIBC_2_3_3 != ABI_libdl_GLIBC_2_1
+#if SHLIB_COMPAT (libdl, GLIBC_2_0, GLIBC_2_34)
+compat_symbol (libdl, __libdl_version_placeholder_1,
+ __libdl_version_placeholder, GLIBC_2_0);
+#endif
+
+#if SHLIB_COMPAT (libdl, GLIBC_2_1, GLIBC_2_34)
+compat_symbol (libdl, __libdl_version_placeholder_1,
+ __libdl_version_placeholder, GLIBC_2_1);
+#endif
+
+#if SHLIB_COMPAT (libdl, GLIBC_2_3_3, GLIBC_2_34)
compat_symbol (libdl, __libdl_version_placeholder_1,
__libdl_version_placeholder, GLIBC_2_3_3);
#endif
-#if SHLIB_COMPAT (libdl, GLIBC_2_3_4, GLIBC_2_34) \
- && ABI_libdl_GLIBC_2_3_4 != ABI_libdl_GLIBC_2_1
+#if SHLIB_COMPAT (libdl, GLIBC_2_3_4, GLIBC_2_34)
compat_symbol (libdl, __libdl_version_placeholder_1,
__libdl_version_placeholder, GLIBC_2_3_4);
#endif
diff --git a/dlfcn/dlopen.c b/dlfcn/dlopen.c
index d51e006..afdc113 100644
--- a/dlfcn/dlopen.c
+++ b/dlfcn/dlopen.c
@@ -21,17 +21,7 @@
#include <stddef.h>
#include <unistd.h>
#include <ldsodefs.h>
-
-#if !defined SHARED && IS_IN (libdl)
-
-void *
-dlopen (const char *file, int mode)
-{
- return __dlopen (file, mode, RETURN_ADDRESS (0));
-}
-static_link_warning (dlopen)
-
-#else
+#include <shlib-compat.h>
struct dlopen_args
{
@@ -46,11 +36,11 @@ struct dlopen_args
/* Non-shared code has no support for multiple namespaces. */
-# ifdef SHARED
-# define NS __LM_ID_CALLER
-# else
-# define NS LM_ID_BASE
-# endif
+#ifdef SHARED
+# define NS __LM_ID_CALLER
+#else
+# define NS LM_ID_BASE
+#endif
static void
@@ -66,38 +56,54 @@ dlopen_doit (void *a)
args->new = GLRO(dl_open) (args->file ?: "", args->mode | __RTLD_DLOPEN,
args->caller,
args->file == NULL ? LM_ID_BASE : NS,
- __dlfcn_argc, __dlfcn_argv, __environ);
+ __libc_argc, __libc_argv, __environ);
}
-void *
-__dlopen (const char *file, int mode DL_CALLER_DECL)
+static void *
+dlopen_implementation (const char *file, int mode, void *dl_caller)
{
-# ifdef SHARED
- if (!rtld_active ())
- return _dlfcn_hook->dlopen (file, mode, DL_CALLER);
-# endif
-
struct dlopen_args args;
args.file = file;
args.mode = mode;
- args.caller = DL_CALLER;
+ args.caller = dl_caller;
-# ifdef SHARED
return _dlerror_run (dlopen_doit, &args) ? NULL : args.new;
-# else
- if (_dlerror_run (dlopen_doit, &args))
- return NULL;
+}
- __libc_register_dl_open_hook ((struct link_map *) args.new);
- __libc_register_dlfcn_hook ((struct link_map *) args.new);
+#ifdef SHARED
+void *
+___dlopen (const char *file, int mode)
+{
+ if (!rtld_active ())
+ return _dlfcn_hook->dlopen (file, mode, RETURN_ADDRESS (0));
+ else
+ return dlopen_implementation (file, mode, RETURN_ADDRESS (0));
+}
+versioned_symbol (libc, ___dlopen, dlopen, GLIBC_2_34);
- return args.new;
+# if OTHER_SHLIB_COMPAT (libdl, GLIBC_2_1, GLIBC_2_34)
+compat_symbol (libdl, ___dlopen, dlopen, GLIBC_2_1);
# endif
+#else /* !SHARED */
+/* Also used with _dlfcn_hook. */
+void *
+__dlopen (const char *file, int mode, void *dl_caller)
+{
+ return dlopen_implementation (file, mode, RETURN_ADDRESS (0));
}
-# ifdef SHARED
-# include <shlib-compat.h>
-strong_alias (__dlopen, __dlopen_check)
-versioned_symbol (libdl, __dlopen_check, dlopen, GLIBC_2_1);
-# endif
-#endif
+
+void *
+___dlopen (const char *file, int mode)
+{
+ struct link_map *l = __dlopen (file, mode, RETURN_ADDRESS (0));
+ if (l != NULL)
+ {
+ __libc_register_dl_open_hook (l);
+ __libc_register_dlfcn_hook (l);
+ }
+ return l;
+}
+weak_alias (___dlopen, dlopen)
+static_link_warning (dlopen)
+#endif /* !SHARED */
diff --git a/dlfcn/dlopenold.c b/dlfcn/dlopenold.c
index 6174dcb..0fe5f24 100644
--- a/dlfcn/dlopenold.c
+++ b/dlfcn/dlopenold.c
@@ -24,7 +24,7 @@
/* This file is for compatibility with glibc 2.0. Compile it only if
versioning is used. */
#include <shlib-compat.h>
-#if SHLIB_COMPAT (libdl, GLIBC_2_0, GLIBC_2_1)
+#if OTHER_SHLIB_COMPAT (libdl, GLIBC_2_0, GLIBC_2_1)
struct dlopen_args
{
@@ -54,7 +54,7 @@ dlopen_doit (void *a)
args->new = GLRO(dl_open) (args->file ?: "", args->mode | __RTLD_DLOPEN,
args->caller,
args->file == NULL ? LM_ID_BASE : NS,
- __dlfcn_argc, __dlfcn_argv, __environ);
+ __libc_argc, __libc_argv, __environ);
}
extern void *__dlopen_nocheck (const char *file, int mode);
diff --git a/dlfcn/sdlopen.c b/dlfcn/sdlopen.c
deleted file mode 100644
index 1ff2eb2..0000000
--- a/dlfcn/sdlopen.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "dlopen.c"