From add8d7ea01d5a22c2d7d184240dda6a7767e54e8 Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Thu, 3 Jun 2021 08:26:04 +0200 Subject: dlfcn: Move dlvsym into libc The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella --- dlfcn/Makefile | 3 ++- dlfcn/Versions | 6 +++++- dlfcn/dlvsym.c | 66 +++++++++++++++++++++++++++++++++------------------------ dlfcn/sdlvsym.c | 1 - 4 files changed, 45 insertions(+), 31 deletions(-) delete mode 100644 dlfcn/sdlvsym.c (limited to 'dlfcn') diff --git a/dlfcn/Makefile b/dlfcn/Makefile index c65cdc2e2b..08d92f85fc 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 dlvsym \ +libdl-routines := dlopen \ dlfcn routines := $(patsubst %,s%,$(filter-out dlfcn,$(libdl-routines))) elide-routines.os := $(routines) @@ -33,6 +33,7 @@ routines += \ dlinfo \ dlmopen \ dlsym \ + dlvsym \ libc_dlerror_result \ extra-libs-others := libdl diff --git a/dlfcn/Versions b/dlfcn/Versions index ca9a3e5591..3c4fa2742e 100644 --- a/dlfcn/Versions +++ b/dlfcn/Versions @@ -5,6 +5,9 @@ libc { dlerror; dlsym; } + GLIBC_2.1 { + dlvsym; + } GLIBC_2.3.3 { dladdr1; dlinfo; @@ -20,6 +23,7 @@ libc { dlinfo; dlmopen; dlsym; + dlvsym; } GLIBC_PRIVATE { __libc_dlerror_result; @@ -32,7 +36,7 @@ libdl { dlopen; } GLIBC_2.1 { - dlopen; dlvsym; + dlopen; } GLIBC_2.3.3 { __libdl_version_placeholder; diff --git a/dlfcn/dlvsym.c b/dlfcn/dlvsym.c index 519e706ea1..de6b340647 100644 --- a/dlfcn/dlvsym.c +++ b/dlfcn/dlvsym.c @@ -17,20 +17,9 @@ . */ #include -#include - #include - -#if !defined SHARED && IS_IN (libdl) - -void * -weak_function -dlvsym (void *handle, const char *name, const char *version_str) -{ - return __dlvsym (handle, name, version_str, RETURN_ADDRESS (0)); -} - -#else +#include +#include struct dlvsym_args { @@ -44,29 +33,23 @@ struct dlvsym_args void *sym; }; - static void dlvsym_doit (void *a) { - struct dlvsym_args *args = (struct dlvsym_args *)a; + struct dlvsym_args *args = (struct dlvsym_args *) a; args->sym = _dl_vsym (args->handle, args->name, args->version, args->who); } -void * -__dlvsym (void *handle, const char *name, const char *version_str - DL_CALLER_DECL) +static void * +dlvsym_implementation (void *handle, const char *name, const char *version, + void *dl_caller) { -# ifdef SHARED - if (!rtld_active ()) - return _dlfcn_hook->dlvsym (handle, name, version_str, DL_CALLER); -# endif - struct dlvsym_args args; + args.who = dl_caller; args.handle = handle; args.name = name; - args.who = DL_CALLER; - args.version = version_str; + args.version = version; /* Protect against concurrent loads and unloads. */ __rtld_lock_lock_recursive (GL(dl_load_lock)); @@ -77,7 +60,34 @@ __dlvsym (void *handle, const char *name, const char *version_str return result; } -# ifdef SHARED -weak_alias (__dlvsym, dlvsym) + +#ifdef SHARED +void * +___dlvsym (void *handle, const char *name, const char *version) +{ + if (!rtld_active ()) + return _dlfcn_hook->dlvsym (handle, name, version, RETURN_ADDRESS (0)); + else + return dlvsym_implementation (handle, name, version, RETURN_ADDRESS (0)); +} +versioned_symbol (libc, ___dlvsym, dlvsym, GLIBC_2_34); + +# if OTHER_SHLIB_COMPAT (libdl, GLIBC_2_1, GLIBC_2_34) +compat_symbol (libdl, ___dlvsym, dlvsym, GLIBC_2_1); # endif -#endif + +#else /* !SHARED */ +/* Also used with _dlfcn_hook. */ +void * +__dlvsym (void *handle, const char *name, const char *version, void *dl_caller) +{ + return dlvsym_implementation (handle, name, version, dl_caller); +} + +void * +___dlvsym (void *handle, const char *name, const char *version) +{ + return __dlvsym (handle, name, version, RETURN_ADDRESS (0)); +} +weak_alias (___dlvsym, dlvsym) +#endif /* !SHARED */ diff --git a/dlfcn/sdlvsym.c b/dlfcn/sdlvsym.c deleted file mode 100644 index ec4286058c..0000000000 --- a/dlfcn/sdlvsym.c +++ /dev/null @@ -1 +0,0 @@ -#include "dlvsym.c" -- cgit 1.4.1