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 | 6a1ed32789eaec6e1cd4345552e7342b5b18da5f (patch) | |
tree | cb2adb82af54f07d6d086d8b91c42d6d5fec23ac /dlfcn | |
parent | 77f876c0e3ac08a98daa60fbad44061d4e4c3d14 (diff) | |
download | glibc-6a1ed32789eaec6e1cd4345552e7342b5b18da5f.tar.gz glibc-6a1ed32789eaec6e1cd4345552e7342b5b18da5f.tar.xz glibc-6a1ed32789eaec6e1cd4345552e7342b5b18da5f.zip |
dlfcn: Move dlmopen 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/Makefile | 3 | ||||
-rw-r--r-- | dlfcn/Versions | 6 | ||||
-rw-r--r-- | dlfcn/dlfcn.c | 19 | ||||
-rw-r--r-- | dlfcn/dlmopen.c | 73 | ||||
-rw-r--r-- | dlfcn/sdlmopen.c | 1 |
5 files changed, 65 insertions, 37 deletions
diff --git a/dlfcn/Makefile b/dlfcn/Makefile index b0f2e8a986..f7ffd242dc 100644 --- a/dlfcn/Makefile +++ b/dlfcn/Makefile @@ -22,13 +22,14 @@ include ../Makeconfig headers := bits/dlfcn.h dlfcn.h extra-libs := libdl libdl-routines := dlopen dlvsym dladdr1 dlinfo \ - dlmopen dlfcn + dlfcn routines := $(patsubst %,s%,$(filter-out dlfcn,$(libdl-routines))) elide-routines.os := $(routines) routines += \ dladdr \ dlclose \ dlerror \ + dlmopen \ dlsym \ libc_dlerror_result \ diff --git a/dlfcn/Versions b/dlfcn/Versions index 7d6b51a4e3..584035e203 100644 --- a/dlfcn/Versions +++ b/dlfcn/Versions @@ -5,10 +5,14 @@ libc { dlerror; dlsym; } + GLIBC_2.3.4 { + dlmopen; + } GLIBC_2.34 { dladdr; dlclose; dlerror; + dlmopen; dlsym; } GLIBC_PRIVATE { @@ -28,6 +32,6 @@ libdl { dladdr1; dlinfo; } GLIBC_2.3.4 { - dlmopen; + __libdl_version_placeholder; } } diff --git a/dlfcn/dlfcn.c b/dlfcn/dlfcn.c index 8f85308b5f..90cdee0903 100644 --- a/dlfcn/dlfcn.c +++ b/dlfcn/dlfcn.c @@ -17,7 +17,7 @@ <https://www.gnu.org/licenses/>. */ #include <dlfcn.h> - +#include <shlib-compat.h> int __dlfcn_argc attribute_hidden; char **__dlfcn_argv attribute_hidden; @@ -36,3 +36,20 @@ static void (*const init_array []) (int argc, char *argv[]) { init }; + +/* The remainder of this file is used to keep specific symbol versions + occupied, so that ld does not generate weak symbol version + definitions. */ + +void +attribute_compat_text_section +__attribute_used__ +__libdl_version_placeholder_1 (void) +{ +} + +#if SHLIB_COMPAT (libdl, GLIBC_2_3_4, GLIBC_2_34) \ + && ABI_libdl_GLIBC_2_3_4 != ABI_libdl_GLIBC_2_1 +compat_symbol (libdl, __libdl_version_placeholder_1, + __libdl_version_placeholder, GLIBC_2_3_4); +#endif diff --git a/dlfcn/dlmopen.c b/dlfcn/dlmopen.c index 6c6e98cd0e..ae42814bbf 100644 --- a/dlfcn/dlmopen.c +++ b/dlfcn/dlmopen.c @@ -22,17 +22,7 @@ #include <stddef.h> #include <unistd.h> #include <ldsodefs.h> - -#if !defined SHARED && IS_IN (libdl) - -void * -dlmopen (Lmid_t nsid, const char *file, int mode) -{ - return __dlmopen (nsid, file, mode, RETURN_ADDRESS (0)); -} -static_link_warning (dlmopen) - -#else +#include <shlib-compat.h> struct dlmopen_args { @@ -70,38 +60,55 @@ dlmopen_doit (void *a) args->new = GLRO(dl_open) (args->file ?: "", args->mode | __RTLD_DLOPEN, args->caller, - args->nsid, __dlfcn_argc, __dlfcn_argv, - __environ); + args->nsid, __libc_argc, __libc_argv, __environ); } - -void * -__dlmopen (Lmid_t nsid, const char *file, int mode DL_CALLER_DECL) +static void * +dlmopen_implementation (Lmid_t nsid, const char *file, int mode, + void *dl_caller) { -# ifdef SHARED - if (!rtld_active ()) - return _dlfcn_hook->dlmopen (nsid, file, mode, RETURN_ADDRESS (0)); -# endif - struct dlmopen_args args; args.nsid = nsid; args.file = file; args.mode = mode; - args.caller = DL_CALLER; + args.caller = dl_caller; -# ifdef SHARED return _dlerror_run (dlmopen_doit, &args) ? NULL : args.new; -# else - if (_dlerror_run (dlmopen_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 * +___dlmopen (Lmid_t nsid, const char *file, int mode) +{ + if (!rtld_active ()) + return _dlfcn_hook->dlmopen (nsid, file, mode, RETURN_ADDRESS (0)); + else + return dlmopen_implementation (nsid, file, mode, RETURN_ADDRESS (0)); +} +versioned_symbol (libc, ___dlmopen, dlmopen, GLIBC_2_34); - return args.new; +# if OTHER_SHLIB_COMPAT (libdl, GLIBC_2_3_4, GLIBC_2_34) +compat_symbol (libdl, ___dlmopen, dlmopen, GLIBC_2_3_4); # endif +#else /* !SHARED */ +/* Also used with _dlfcn_hook. */ +void * +__dlmopen (Lmid_t nsid, const char *file, int mode, void *dl_caller) +{ + return dlmopen_implementation (nsid, file, mode, RETURN_ADDRESS (0)); } -# ifdef SHARED -strong_alias (__dlmopen, dlmopen) -# endif -#endif + +void * +___dlmopen (Lmid_t nsid, const char *file, int mode) +{ + struct link_map *l = __dlmopen (nsid, file, mode, RETURN_ADDRESS (0)); + if (l != NULL) + { + __libc_register_dl_open_hook (l); + __libc_register_dlfcn_hook (l); + } + return l; +} +weak_alias (___dlmopen, dlmopen) +static_link_warning (dlmopen) +#endif /* !SHARED */ diff --git a/dlfcn/sdlmopen.c b/dlfcn/sdlmopen.c deleted file mode 100644 index 9630c89a7f..0000000000 --- a/dlfcn/sdlmopen.c +++ /dev/null @@ -1 +0,0 @@ -#include "dlmopen.c" |