]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Enable VDSO on x86_64 statically linked programs [BZ #19767]
authorRafael Ávila de Espíndola <rafael@espindo.la>
Fri, 23 Nov 2018 23:34:15 +0000 (15:34 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 24 Nov 2018 00:50:29 +0000 (16:50 -0800)
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.

ChangeLog
nptl/Makefile
nptl/tst-cond11-static.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/Makefile
sysdeps/unix/sysv/linux/sysdep-vdso.h
sysdeps/unix/sysv/linux/sysdep.h
sysdeps/unix/sysv/linux/tst-affinity-static.c [new file with mode: 0644]
sysdeps/unix/sysv/linux/x86/libc-vdso.h
sysdeps/unix/sysv/linux/x86_64/init-first.c
sysdeps/unix/sysv/linux/x86_64/sysdep.h

index f8f7672c5bdd8a36805b1f401ec2a0f7abeb9a8b..04a507f2194bdbbb12aedcec3df7e64dd81f902d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2018-11-23  Rafael Ávila de Espíndola  <rafael@espindo.la>
+
+       [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.
+
 2018-11-23  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #23915]
index 49b6faa330c492e0b9587784660b352c72bb9f47..982e43adfacb29be25b63321c7884c0478153a8b 100644 (file)
@@ -449,9 +449,10 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
 tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
                tst-cancel21-static tst-cancel24-static tst-cond8-static \
                tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
-               tst-sem12-static
+               tst-sem12-static tst-cond11-static
+
 tests += tst-cancel21-static tst-cancel24-static \
-        tst-cond8-static
+        tst-cond8-static tst-cond11-static
 tests-internal += tst-sem11-static tst-sem12-static tst-stackguard1-static
 xtests-static += tst-setuid1-static
 
diff --git a/nptl/tst-cond11-static.c b/nptl/tst-cond11-static.c
new file mode 100644 (file)
index 0000000..9bccb8e
--- /dev/null
@@ -0,0 +1 @@
+#include "tst-cond11.c"
index 72b6b641d5c700460a866c5941a612a272faa581..362cf3b950324e52268016a66c12f427f556df38 100644 (file)
@@ -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
index 7f894c5e02c093bace9b3e490ebfeb393833d58d..1ee0657ad38e4042468d898ad42357c025a72de7 100644 (file)
@@ -26,7 +26,7 @@
      funcptr (args)
 #endif
 
-#if defined SHARED && defined HAVE_VSYSCALL
+#if USE_VSYSCALL && defined HAVE_VSYSCALL
 
 # include <libc-vdso.h>
 
@@ -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  */
index 4fd0a9bae3f61fb6133e0ff054bb095f4ecf2f9c..9655436ee4e719774ea7a13411dbbd4535286cb2 100644 (file)
 #include <bits/wordsize.h>
 #include <kernel-features.h>
 
+/* 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 (file)
index 0000000..4022ea3
--- /dev/null
@@ -0,0 +1 @@
+#include "tst-affinity.c"
index 6f86073dae87498e27fd14409a66cda22356d932..b9b4b93011bac39ef714cda552262d8733a147f7 100644 (file)
@@ -22,7 +22,7 @@
 #include <time.h>
 #include <sys/time.h>
 
-#ifdef SHARED
+#if USE_VSYSCALL
 
 # include <sysdep-vdso.h>
 
index 2320505804e3be55312a6891b7ec144b64749334..ad19f4b055a969ff50e947c6da831300a4543bde 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef SHARED
-# include <time.h>
-# include <sysdep.h>
-# include <dl-vdso.h>
-# include <libc-vdso.h>
+#include <time.h>
+#include <sysdep.h>
+#include <dl-vdso.h>
+#include <libc-vdso.h>
 
 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 <csu/init-first.c>
index f07eb04962e0c817ddcb1b5cb082e0eaba0333ea..9f49347ce5d1bff5f9af2c465d06c20031204f6f 100644 (file)
@@ -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 <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/x86_64/sysdep.h>