From: Emil Velikov Date: Sat, 24 May 2025 11:50:15 +0000 (+0100) Subject: testsuite: always use dlsym(RTLD_NEXT, ...) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ed7f71c243f72176db645d94382b6051f326fe7f;p=thirdparty%2Fkmod.git testsuite: always use dlsym(RTLD_NEXT, ...) It has been supported by glibc, musl and bionic for years - our supported platforms. Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/355 Signed-off-by: Lucas De Marchi --- diff --git a/testsuite/init_module.c b/testsuite/init_module.c index 35630d89..891df6b0 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -349,16 +349,10 @@ TS_EXPORT long int syscall(long int __sysno, ...) } if (__sysno == __NR_gettid) { - static void *nextlib = NULL; static long (*nextlib_syscall)(long number, ...); if (nextlib_syscall == NULL) { -#ifdef RTLD_NEXT - nextlib = RTLD_NEXT; -#else - nextlib = dlopen("libc.so.6", RTLD_LAZY); -#endif - nextlib_syscall = dlsym(nextlib, "syscall"); + nextlib_syscall = dlsym(RTLD_NEXT, "syscall"); if (nextlib_syscall == NULL) { fprintf(stderr, "FIXME FIXME FIXME: could not load syscall symbol: %s\n", diff --git a/testsuite/path.c b/testsuite/path.c index 5acc1fd4..947a3915 100644 --- a/testsuite/path.c +++ b/testsuite/path.c @@ -26,7 +26,6 @@ #include "testsuite.h" -static void *nextlib; static const char *rootpath; static size_t rootpathlen; @@ -84,15 +83,7 @@ static void *get_libc_func(const char *f) { void *fp; - if (nextlib == NULL) { -#ifdef RTLD_NEXT - nextlib = RTLD_NEXT; -#else - nextlib = dlopen("libc.so.6", RTLD_LAZY); -#endif - } - - fp = dlsym(nextlib, f); + fp = dlsym(RTLD_NEXT, f); assert(fp); return fp; diff --git a/testsuite/uname.c b/testsuite/uname.c index 293c625d..0333f7a9 100644 --- a/testsuite/uname.c +++ b/testsuite/uname.c @@ -15,20 +15,13 @@ TS_EXPORT int uname(struct utsname *u) { - static void *nextlib = NULL; static int (*nextlib_uname)(struct utsname *u); const char *release; int err; size_t sz; - if (nextlib == NULL) { -#ifdef RTLD_NEXT - nextlib = RTLD_NEXT; -#else - nextlib = dlopen("libc.so.6", RTLD_LAZY); -#endif - nextlib_uname = dlsym(nextlib, "uname"); - } + if (nextlib_uname == NULL) + nextlib_uname = dlsym(RTLD_NEXT, "uname"); err = nextlib_uname(u); if (err < 0)