diff options
author | Florian Weimer <fweimer@redhat.com> | 2021-06-03 08:26:04 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2021-06-03 08:26:04 +0200 |
commit | 0c1c3a771eceec46e66ce1183cf988e2303bd373 (patch) | |
tree | addf888256dd2498bcc2f220339b981e7e096d87 /dlfcn/dlopen.c | |
parent | dlfcn: Move dlvsym into libc (diff) | |
download | glibc-0c1c3a771eceec46e66ce1183cf988e2303bd373.tar.gz glibc-0c1c3a771eceec46e66ce1183cf988e2303bd373.tar.bz2 glibc-0c1c3a771eceec46e66ce1183cf988e2303bd373.zip |
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/dlopen.c')
-rw-r--r-- | dlfcn/dlopen.c | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/dlfcn/dlopen.c b/dlfcn/dlopen.c index d51e006453..afdc113efb 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 */ |