From 1e8bdc3a2b3e8d6e26efd14d44ae71d21d8366fe Mon Sep 17 00:00:00 2001 From: Rafael Ávila de Espíndola Date: Fri, 23 Nov 2018 15:34:15 -0800 Subject: Enable VDSO on x86_64 statically linked programs [BZ #19767] All the required code already existed, and some of it was already running. AT_SYSINFO_EHDR is processed if NEED_DL_SYSINFO_DSO is defined, but it looks like it always is. The call to setup_vdso is also unconditional, so all that was left to do was setup the function pointers and use them. This patch just deletes some #ifdef to enable that. [BZ #19767] * nptl/Makefile (tests-static): Add tst-cond11-static. (tests): Likewise. * nptl/tst-cond11-static.c: New File. * sysdeps/unix/sysv/linux/Makefile (tests-static): Add tst-affinity-static. (tests): Likewise. * sysdeps/unix/sysv/linux/sysdep-vdso.h: Check USE_VSYSCALL instead of SHARED. * sysdeps/unix/sysv/linux/sysdep.h (ALWAYS_USE_VSYSCALL): New. (USE_VSYSCALL): Likewise. * sysdeps/unix/sysv/linux/tst-affinity-static.c: New file. * sysdeps/unix/sysv/linux/x86/libc-vdso.h: Check USE_VSYSCALL instead of SHARED. * sysdeps/unix/sysv/linux/x86_64/init-first.c: Don't check SHARED. * sysdeps/unix/sysv/linux/x86_64/sysdep.h (ALWAYS_USE_VSYSCALL): New. --- sysdeps/unix/sysv/linux/Makefile | 3 +++ sysdeps/unix/sysv/linux/sysdep-vdso.h | 4 ++-- sysdeps/unix/sysv/linux/sysdep.h | 7 +++++++ sysdeps/unix/sysv/linux/tst-affinity-static.c | 1 + sysdeps/unix/sysv/linux/x86/libc-vdso.h | 2 +- sysdeps/unix/sysv/linux/x86_64/init-first.c | 12 +++++------- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 3 +++ 7 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/tst-affinity-static.c (limited to 'sysdeps/unix/sysv') diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile index 72b6b641d5..362cf3b950 100644 --- a/sysdeps/unix/sysv/linux/Makefile +++ b/sysdeps/unix/sysv/linux/Makefile @@ -146,6 +146,9 @@ sysdep_routines += sched_getcpu oldglob tests += tst-affinity tst-affinity-pid +tests-static := tst-affinity-static +tests += $(tests-static) + CFLAGS-fork.c = $(libio-mtsafe) CFLAGS-getpid.o = -fomit-frame-pointer CFLAGS-getpid.os = -fomit-frame-pointer diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index 7f894c5e02..1ee0657ad3 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -26,7 +26,7 @@ funcptr (args) #endif -#if defined SHARED && defined HAVE_VSYSCALL +#if USE_VSYSCALL && defined HAVE_VSYSCALL # include @@ -84,6 +84,6 @@ # define INTERNAL_VSYSCALL(name, err, nr, args...) \ INTERNAL_SYSCALL (name, err, nr, ##args) -#endif /* defined SHARED && defined HAVE_VSYSCALL */ +#endif /* USE_VSYSCALL && defined HAVE_VSYSCALL */ #endif /* SYSDEP_VDSO_LINUX_H */ diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h index 4fd0a9bae3..9655436ee4 100644 --- a/sysdeps/unix/sysv/linux/sysdep.h +++ b/sysdeps/unix/sysv/linux/sysdep.h @@ -18,6 +18,13 @@ #include #include +/* By default only shared builds use vdso. */ +#ifndef ALWAYS_USE_VSYSCALL +#define ALWAYS_USE_VSYSCALL 0 +#endif + +#define USE_VSYSCALL (defined (SHARED) || ALWAYS_USE_VSYSCALL) + /* Set error number and return -1. A target may choose to return the internal function, __syscall_error, which sets errno and returns -1. We use -1l, instead of -1, so that it can be casted to (void *). */ diff --git a/sysdeps/unix/sysv/linux/tst-affinity-static.c b/sysdeps/unix/sysv/linux/tst-affinity-static.c new file mode 100644 index 0000000000..4022ea317a --- /dev/null +++ b/sysdeps/unix/sysv/linux/tst-affinity-static.c @@ -0,0 +1 @@ +#include "tst-affinity.c" diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h index 6f86073dae..b9b4b93011 100644 --- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h +++ b/sysdeps/unix/sysv/linux/x86/libc-vdso.h @@ -22,7 +22,7 @@ #include #include -#ifdef SHARED +#if USE_VSYSCALL # include diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c index 2320505804..ad19f4b055 100644 --- a/sysdeps/unix/sysv/linux/x86_64/init-first.c +++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c @@ -16,11 +16,10 @@ License along with the GNU C Library; if not, see . */ -#ifdef SHARED -# include -# include -# include -# include +#include +#include +#include +#include long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *) attribute_hidden; @@ -46,7 +45,6 @@ __vdso_platform_setup (void) VDSO_SYMBOL(getcpu) = p; } -# define VDSO_SETUP __vdso_platform_setup -#endif +#define VDSO_SETUP __vdso_platform_setup #include diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index f07eb04962..9f49347ce5 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -18,6 +18,9 @@ #ifndef _LINUX_X86_64_SYSDEP_H #define _LINUX_X86_64_SYSDEP_H 1 +/* Always enable vsyscalls on x86_64 */ +#define ALWAYS_USE_VSYSCALL 1 + /* There is some commonality. */ #include #include -- cgit 1.4.1