summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@intel.com>2018-01-08 08:22:29 -0800
committerLucas De Marchi <lucas.demarchi@intel.com>2018-01-08 13:32:38 -0800
commit7acc5daeecd033477737e780782aed475de72961 (patch)
tree8fd040eea1a5f0ee8bbb7a5774b07366ac6e9b9b
parent77d7bd9eca764d6870398b9c2e47345d6f0e4552 (diff)
downloadkmod-7acc5daeecd033477737e780782aed475de72961.tar.gz
kmod-7acc5daeecd033477737e780782aed475de72961.tar.bz2
kmod-7acc5daeecd033477737e780782aed475de72961.zip
testsuite: also wrap gettid in syscall()
Not a perfect solution for overriding syscall(), but at least it makes the testsuite to pass in a modified nsswitch.conf (one that has a module which calls syscall() to get the thread id).
-rw-r--r--testsuite/init_module.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/testsuite/init_module.c b/testsuite/init_module.c
index 199186b..503e703 100644
--- a/testsuite/init_module.c
+++ b/testsuite/init_module.c
@@ -355,6 +355,27 @@ TS_EXPORT long int syscall(long int __sysno, ...)
return ret;
}
+ 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");
+ if (nextlib_syscall == NULL) {
+ fprintf(stderr, "FIXME FIXME FIXME: could not load syscall symbol: %s\n",
+ dlerror());
+ abort();
+ }
+ }
+
+ return nextlib_syscall(__NR_gettid);
+ }
+
/*
* FIXME: no way to call the libc function due since this is a
* variadic argument function and we don't have a vsyscall() variant