unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW
@ 2019-09-05 20:56 Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH v2 2/8] Refactor vDSO initialization code Adhemerval Zanella
                   ` (7 more replies)
  0 siblings, 8 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

Changes from previous version:

  - Remove trailing whitespaces.

--

This patch removes the PREPARE_VERSION and PREPARE_VERSION_KNOW macro
and uses a static inline function instead, get_vdso_symbol.  Each
architecture that supports vDSO must define the Linux version and its
hash for symbol resolution (VDSO_NAME and VDSO_HASH macro respectively).

It also organizes the HAVE_*_VSYSCALL for mips, powerpc, and s390 to set
them on a common header.

The idea is to require less code to configure and enable vDSO support for
newer ports.  No semantic changes are expected.

Checked with a build against all affected architectures.

	* sysdeps/unix/make-syscalls.sh: Make vDSO call use get_vdso_symbol.
	* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c (__gettimeofday):
	Use get_vdso_symbol instead of _dl_vdso_vsym.
	* sysdeps/unix/sysv/linux/powerpc/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/riscv/flush-icache.c
	(__lookup_riscv_flush_icache): Likewise.
	* sysdeps/unix/sysv/linux/x86/gettimeofday.c (__gettimeofday):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (VDSO_NAME, VDSO_HASH):
	Define.
	* sysdeps/unix/sysv/linux/arm/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Remove
	definition.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep.h: New file.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/dl-vdso.h (PREPARE_VERSION,
	PREPARE_VERSION_KNOWN, VDSO_NAME_LINUX_2_6, VDSO_HASH_LINUX_2_6,
	VDSO_NAME_LINUX_2_6_15, VDSO_HASH_LINUX_2_6_15,
	VDSO_NAME_LINUX_2_6_29, VDSO_HASH_LINUX_2_6_29,
	VDSO_NAME_LINUX_4_15, VDSO_HASH_LINUX_4_15): Remove defines.
	(get_vdso_symbol): New function.
---
 sysdeps/unix/make-syscalls.sh                 |  5 +--
 .../unix/sysv/linux/aarch64/gettimeofday.c    | 27 ++++---------
 sysdeps/unix/sysv/linux/aarch64/init-first.c  | 12 ++----
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  7 ++++
 sysdeps/unix/sysv/linux/arm/init-first.c      |  6 +--
 sysdeps/unix/sysv/linux/arm/sysdep.h          |  3 ++
 sysdeps/unix/sysv/linux/dl-vdso.h             | 38 ++++---------------
 sysdeps/unix/sysv/linux/i386/init-first.c     |  4 +-
 sysdeps/unix/sysv/linux/i386/sysdep.h         |  3 ++
 sysdeps/unix/sysv/linux/mips/init-first.c     |  6 +--
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h  |  5 +--
 .../unix/sysv/linux/mips/mips64/n32/sysdep.h  |  5 +--
 .../unix/sysv/linux/mips/mips64/n64/sysdep.h  |  5 +--
 sysdeps/unix/sysv/linux/mips/sysdep.h         | 24 ++++++++++++
 .../unix/sysv/linux/powerpc/gettimeofday.c    |  7 ++--
 sysdeps/unix/sysv/linux/powerpc/init-first.c  | 22 +++++------
 .../sysv/linux/powerpc/powerpc32/sysdep.h     |  7 +---
 .../sysv/linux/powerpc/powerpc64/sysdep.h     |  6 +--
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 26 +++++++++++++
 sysdeps/unix/sysv/linux/powerpc/time.c        |  5 +--
 sysdeps/unix/sysv/linux/riscv/flush-icache.c  |  4 +-
 sysdeps/unix/sysv/linux/riscv/init-first.c    | 10 ++---
 sysdeps/unix/sysv/linux/riscv/sysdep.h        |  3 ++
 sysdeps/unix/sysv/linux/s390/init-first.c     | 10 ++---
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h |  7 +---
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h |  7 +---
 sysdeps/unix/sysv/linux/s390/sysdep.h         | 27 +++++++++++++
 sysdeps/unix/sysv/linux/sparc/init-first.c    |  6 +--
 sysdeps/unix/sysv/linux/sparc/sysdep.h        |  3 ++
 sysdeps/unix/sysv/linux/x86/gettimeofday.c    | 10 +++--
 sysdeps/unix/sysv/linux/x86/time.c            |  7 ++--
 sysdeps/unix/sysv/linux/x86_64/init-first.c   |  6 +--
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  3 ++
 33 files changed, 168 insertions(+), 158 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/mips/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/sysdep.h

diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh
index 6a5c10d54e..b49e6b6305 100644
--- a/sysdeps/unix/make-syscalls.sh
+++ b/sysdeps/unix/make-syscalls.sh
@@ -283,10 +283,9 @@ while read file srcfile caller syscall args strong weak; do
 	(echo '#define ${strong} __redirect_${strong}'; \\
 	 echo '#include <dl-vdso.h>'; \\
 	 echo '#undef ${strong}'; \\
-	 echo '#define vdso_ifunc_init() \\'; \\
-	 echo '  PREPARE_VERSION_KNOWN (symver, ${vdso_symver})'; \\
+	 echo '#define vdso_ifunc_init()'; \\
 	 echo '__ifunc (__redirect_${strong}, ${strong},'; \\
-	 echo '         _dl_vdso_vsym ("${vdso_symbol}", &symver), void,'; \\
+	 echo '         get_vdso_symbol ("${vdso_symbol}"), void,'; \\
 	 echo '         vdso_ifunc_init)'; \\
 EOF
     # This is doing "hidden_def (${strong})", but the compiler
diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
index 9180b50bf7..9499a11fda 100644
--- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
@@ -20,12 +20,10 @@
    putting it into *tv and *tz.  If tz is null, *tz is not filled.
    Returns 0 on success, -1 on errors.  */
 
+#include <sys/time.h>
+
 #ifdef SHARED
 
-# define __gettimeofday __redirect___gettimeofday
-# include <sys/time.h>
-# undef __gettimeofday
-# define HAVE_VSYSCALL
 # include <dl-vdso.h>
 # include <sysdep-vdso.h>
 
@@ -38,25 +36,14 @@ __gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
   return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
 }
 
-/* PREPARE_VERSION_KNOWN will need an __LP64__ ifdef when ILP32 support
-   goes in.  See _libc_vdso_platform_setup in
-   sysdeps/unix/sysv/linux/aarch64/init-first.c.  */
-
-# undef INIT_ARCH
-# define INIT_ARCH() \
-	   PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6_39); \
-	   void *vdso_gettimeofday = \
-	     _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version);
-
-libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
-		   vdso_gettimeofday ?: (void *) __gettimeofday_vsyscall)
-
-__hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday,
-	       __gettimeofday_vsyscall);
+# define INIT_ARCH()
+libc_ifunc_hidden (__gettimeofday, __gettimeofday,
+		   (get_vdso_symbol ("__vdso_gettimeofday")
+		    ?: __gettimeofday_vsyscall))
+libc_hidden_def (__gettimeofday)
 
 #else
 
-# include <sys/time.h>
 # include <sysdep.h>
 int
 __gettimeofday (struct timeval *tv, struct timezone *tz)
diff --git a/sysdeps/unix/sysv/linux/aarch64/init-first.c b/sysdeps/unix/sysv/linux/aarch64/init-first.c
index 80f7ed91ef..c3c27cfd4b 100644
--- a/sysdeps/unix/sysv/linux/aarch64/init-first.c
+++ b/sysdeps/unix/sysv/linux/aarch64/init-first.c
@@ -26,21 +26,15 @@ int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-#ifdef __LP64__
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6_39);
-#else
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_4_9);
-#endif
-
-  void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version);
+  void *p = get_vdso_symbol ("__kernel_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL(gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux_version);
+  p = get_vdso_symbol ("__kernel_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL(clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_getres", &linux_version);
+  p = get_vdso_symbol ("__kernel_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL(clock_getres) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index a2f4061b58..662d321235 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -151,6 +151,13 @@
 
 #else /* not __ASSEMBLER__ */
 
+# ifdef __LP64__
+#  define VDSO_NAME  "LINUX_2_6_39"
+#  define VDSO_HASH  123718537
+# else
+#  define VDSO_NAME  "LINUX_4.9"
+#  define VDSO_HASH  61765625
+# endif
 
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETRES_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/arm/init-first.c b/sysdeps/unix/sysv/linux/arm/init-first.c
index e1846df661..2852ab135c 100644
--- a/sysdeps/unix/sysv/linux/arm/init-first.c
+++ b/sysdeps/unix/sysv/linux/arm/init-first.c
@@ -27,13 +27,11 @@ int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
+  void *p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index 6d8d9a47f9..467ccf2631 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -388,6 +388,9 @@ __local_syscall_error:						\
 #undef INTERNAL_SYSCALL_ERRNO
 #define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
+#define VDSO_NAME  "LINUX_2_6"
+#define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 #define HAVE_CLOCK_GETTIME_VSYSCALL	1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h
index d83afe130e..bab3779615 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso.h
@@ -22,40 +22,18 @@
 #include <assert.h>
 #include <ldsodefs.h>
 #include <dl-hash.h>
-
-/* Create version number record for lookup.  */
-static inline struct r_found_version
-prepare_version_base (const char *name, ElfW(Word) hash)
-{
-  assert (hash == _dl_elf_hash (name));
-  return (struct r_found_version) { name, hash, 1, NULL };
-}
-#define prepare_version(vname) \
-  prepare_version_base (VDSO_NAME_##vname, VDSO_HASH_##vname)
-
-/* Use this for the known version sets defined below, where we
-   record their precomputed hash values only once, in this file.  */
-#define PREPARE_VERSION_KNOWN(var, vname) \
-  struct r_found_version var = prepare_version (vname);
-
-#define VDSO_NAME_LINUX_2_6	"LINUX_2.6"
-#define VDSO_HASH_LINUX_2_6	61765110
-#define VDSO_NAME_LINUX_2_6_15	"LINUX_2.6.15"
-#define VDSO_HASH_LINUX_2_6_15	123718565
-#define VDSO_NAME_LINUX_2_6_29	"LINUX_2.6.29"
-#define VDSO_HASH_LINUX_2_6_29	123718585
-#define VDSO_NAME_LINUX_2_6_39	"LINUX_2.6.39"
-#define VDSO_HASH_LINUX_2_6_39	123718537
-#define VDSO_NAME_LINUX_4	"LINUX_4"
-#define VDSO_HASH_LINUX_4	14921332
-#define VDSO_NAME_LINUX_4_9	"LINUX_4.9"
-#define VDSO_HASH_LINUX_4_9	61765625
-#define VDSO_NAME_LINUX_4_15	"LINUX_4.15"
-#define VDSO_HASH_LINUX_4_15	182943605
+#include <libc-vdso.h>
 
 /* Functions for resolving symbols in the VDSO link map.  */
 extern void *_dl_vdso_vsym (const char *name,
 			    const struct r_found_version *version)
       attribute_hidden;
 
+static inline void *
+get_vdso_symbol (const char *symbol)
+{
+  struct r_found_version rfv = { VDSO_NAME, VDSO_HASH, 1, NULL };
+  return _dl_vdso_vsym (symbol, &rfv);
+}
+
 #endif /* dl-vdso.h */
diff --git a/sysdeps/unix/sysv/linux/i386/init-first.c b/sysdeps/unix/sysv/linux/i386/init-first.c
index 60d69777cd..9c03f87b67 100644
--- a/sysdeps/unix/sysv/linux/i386/init-first.c
+++ b/sysdeps/unix/sysv/linux/i386/init-first.c
@@ -34,9 +34,7 @@ clock_gettime_syscall (clockid_t id, struct timespec *tp)
 static inline void
 __vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  void *p = get_vdso_symbol ("__vdso_clock_gettime");
   if (p == NULL)
     p = clock_gettime_syscall;
   PTR_MANGLE (p);
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 77154b904a..278028f52e 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -309,6 +309,9 @@ struct libc_do_syscall_args
 #define INLINE_SYSCALL_ERROR_RETURN_VALUE(resultvar) \
   __syscall_error (-(resultvar))
 
+# define VDSO_NAME  "LINUX_2.6"
+# define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    1
 # define HAVE_GETTIMEOFDAY_VSYSCALL     1
diff --git a/sysdeps/unix/sysv/linux/mips/init-first.c b/sysdeps/unix/sysv/linux/mips/init-first.c
index 25884ffd80..2a43bdc8b0 100644
--- a/sysdeps/unix/sysv/linux/mips/init-first.c
+++ b/sysdeps/unix/sysv/linux/mips/init-first.c
@@ -26,13 +26,11 @@ int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
+  void *p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index a310a0acbc..ebe397b701 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -19,6 +19,7 @@
 #define _LINUX_MIPS_MIPS32_SYSDEP_H 1
 
 /* There is some commonality.  */
+#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips32/sysdep.h>
 
@@ -360,10 +361,6 @@ libc_hidden_proto (__mips_syscall7, nomips16)
     _ret;								\
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index d83e08f96a..bb49429c30 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -19,6 +19,7 @@
 #define _LINUX_MIPS_SYSDEP_H 1
 
 /* There is some commonality.  */
+#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n32/sysdep.h>
 
@@ -308,10 +309,6 @@
     _ret;								\
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index bcfaf561a1..84a1ff186b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -19,6 +19,7 @@
 #define _LINUX_MIPS_SYSDEP_H 1
 
 /* There is some commonality.  */
+#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n64/sysdep.h>
 
@@ -304,10 +305,6 @@
     _ret;								\
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
new file mode 100644
index 0000000000..cabc590961
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -0,0 +1,24 @@
+/* Syscall definitions, Linux MIPS generic version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define VDSO_NAME  "LINUX_2_6"
+#define VDSO_HASH  61765110
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETTIME_VSYSCALL     1
+#define HAVE_GETTIMEOFDAY_VSYSCALL      1
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
index 463b678ad9..c59d5ddc10 100644
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
@@ -57,10 +57,9 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
   return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
 }
 
-# define INIT_ARCH()						\
-  PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15);		\
-  void *vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
-
+# define INIT_ARCH() \
+  void *vdso_gettimeofday = get_vdso_symbol ("__kernel_gettimeofday")
+  
 /* If the vDSO is not available we fall back syscall.  */
 libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
 		   vdso_gettimeofday
diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c
index 831f910788..0d46563ce3 100644
--- a/sysdeps/unix/sysv/linux/powerpc/init-first.c
+++ b/sysdeps/unix/sysv/linux/powerpc/init-first.c
@@ -37,29 +37,27 @@ void *VDSO_SYMBOL(sigtramp_rt32);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15);
-
-  void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
+  void *p = get_vdso_symbol ("__kernel_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2615);
+  p = get_vdso_symbol ("__kernel_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_getres", &linux2615);
+  p = get_vdso_symbol ("__kernel_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_getres) = p;
 
-  p = _dl_vdso_vsym ("__kernel_get_tbfreq", &linux2615);
+  p = get_vdso_symbol ("__kernel_get_tbfreq");
   PTR_MANGLE (p);
   VDSO_SYMBOL (get_tbfreq) = p;
 
-  p = _dl_vdso_vsym ("__kernel_getcpu", &linux2615);
+  p = get_vdso_symbol ("__kernel_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL (getcpu) = p;
 
-  p = _dl_vdso_vsym ("__kernel_time", &linux2615);
+  p = get_vdso_symbol ("__kernel_time");
   PTR_MANGLE (p);
   VDSO_SYMBOL (time) = p;
 
@@ -69,12 +67,10 @@ _libc_vdso_platform_setup (void)
      There is no need to pointer mangle these symbol because they will
      used only for pointer comparison.  */
 #if defined(__PPC64__) || defined(__powerpc64__)
-  VDSO_SYMBOL(sigtramp_rt64) = _dl_vdso_vsym ("__kernel_sigtramp_rt64",
-					      &linux2615);
+  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol ("__kernel_sigtramp_rt64");
 #else
-  VDSO_SYMBOL(sigtramp32) = _dl_vdso_vsym ("__kernel_sigtramp32", &linux2615);
-  VDSO_SYMBOL(sigtramp_rt32) = _dl_vdso_vsym ("__kernel_sigtramp_rt32",
-					      &linux2615);
+  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol ("__kernel_sigtramp32");
+  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol ("__kernel_sigtramp_rt32");
 #endif
 }
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index 62caa265d7..f459543fcd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -18,6 +18,7 @@
 #ifndef _LINUX_POWERPC_SYSDEP_H
 #define _LINUX_POWERPC_SYSDEP_H 1
 
+#include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
 #include <tls.h>
@@ -144,12 +145,6 @@
     sc_ret;								      \
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	1
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETCPU_VSYSCALL		1
-
-
 # define LOADARGS_0(name, dummy)					      \
 	r0 = name
 # define LOADARGS_1(name, __arg1) \
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 4122e5c4a9..06222f52e6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -20,6 +20,7 @@
 #ifndef _LINUX_POWERPC_SYSDEP_H
 #define _LINUX_POWERPC_SYSDEP_H 1
 
+#include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
 #include <tls.h>
@@ -60,11 +61,6 @@
     sc_ret;								      \
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
-
 /* Define a macro which expands inline into the wrapper code for a system
    call. This use is for internal calls that do not need to handle errors
    normally. It will never touch errno. This returns just what the kernel
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
new file mode 100644
index 0000000000..5b411d0e8e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -0,0 +1,26 @@
+/* Syscall definitions, Linux PowerPC generic version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define VDSO_NAME  "LINUX_2.6.15"
+#define VDSO_HASH  123718565
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETRES_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	1
+#define HAVE_GETCPU_VSYSCALL		1
+
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
index cb3e8b9a73..38477bce8b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ b/sysdeps/unix/sysv/linux/powerpc/time.c
@@ -66,9 +66,8 @@ time_syscall (time_t *t)
   return result;
 }
 
-# define INIT_ARCH()						\
-  PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15);		\
-  void *vdso_time = _dl_vdso_vsym ("__kernel_time", &linux2615);
+# define INIT_ARCH() \
+  void *vdso_time = get_vdso_symbol ("__kernel_time");
 
 /* If the vDSO is not available we fall back to the syscall.  */
 libc_ifunc_hidden (__redirect_time, time,
diff --git a/sysdeps/unix/sysv/linux/riscv/flush-icache.c b/sysdeps/unix/sysv/linux/riscv/flush-icache.c
index f2dfcc50d0..6fbda9a088 100644
--- a/sysdeps/unix/sysv/linux/riscv/flush-icache.c
+++ b/sysdeps/unix/sysv/linux/riscv/flush-icache.c
@@ -38,9 +38,7 @@ __riscv_flush_icache_syscall (void *start, void *end, unsigned long int flags)
 static func_type
 __lookup_riscv_flush_icache (void)
 {
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_4_15);
-
-  func_type func = _dl_vdso_vsym ("__vdso_flush_icache", &linux_version);
+  func_type func = get_vdso_symbol ("__vdso_flush_icache");
 
   /* If there is no vDSO entry then call the system call directly.  All Linux
      versions provide the vDSO entry, but QEMU's user-mode emulation doesn't
diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
index 98a8ce33ad..f3d243a192 100644
--- a/sysdeps/unix/sysv/linux/riscv/init-first.c
+++ b/sysdeps/unix/sysv/linux/riscv/init-first.c
@@ -32,21 +32,19 @@ long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_4_15);
-
-  void *p = _dl_vdso_vsym ("__vdso_getcpu", &linux_version);
+  void *p = get_vdso_symbol ("__vdso_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL (getcpu) = p;
 
-  p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
+  p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_getres", &linux_version);
+  p = get_vdso_symbol ("__vdso_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_getres) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 5470ea3d2a..5de773744c 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -121,6 +121,9 @@
 
 #ifndef __ASSEMBLER__
 
+# define VDSO_NAME  "LINUX_4.15"
+# define VDSO_HASH  182943605
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETRES_VSYSCALL	1
 # define HAVE_CLOCK_GETTIME_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
index a1ad9458e3..3e36270eac 100644
--- a/sysdeps/unix/sysv/linux/s390/init-first.c
+++ b/sysdeps/unix/sysv/linux/s390/init-first.c
@@ -34,21 +34,19 @@ long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux2629, LINUX_2_6_29);
-
-  void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2629);
+  void *p = get_vdso_symbol ("__kernel_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2629);
+  p = get_vdso_symbol ("__kernel_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_getres", &linux2629);
+  p = get_vdso_symbol ("__kernel_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_getres) = p;
 
-  p = _dl_vdso_vsym ("__kernel_getcpu", &linux2629);
+  p = get_vdso_symbol ("__kernel_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL (getcpu) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index 640fb52de1..b780d22d8f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -21,6 +21,7 @@
 
 #include <sysdeps/s390/s390-32/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/s390/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
@@ -271,12 +272,6 @@
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
-
 /* Pointer mangling support.  */
 #if IS_IN (rtld)
 /* We cannot use the thread descriptor because in ld.so we use setjmp
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 9a9834c750..07cfa64cab 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -22,6 +22,7 @@
 
 #include <sysdeps/s390/s390-64/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/s390/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
@@ -277,12 +278,6 @@
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
-
 #define SINGLE_THREAD_BY_GLOBAL		1
 
 /* Pointer mangling support.  */
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
new file mode 100644
index 0000000000..eefbd8f007
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -0,0 +1,27 @@
+/* Syscall definitions, Linux PowerPC generic version.
+   Copyright (C) 2000-2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define VDSO_NAME  "LINUX_2_6_29"
+#define VDSO_HASH  123718585
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETRES_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	1
+#define HAVE_GETTIMEOFDAY_VSYSCALL	1
+#define HAVE_GETCPU_VSYSCALL		1
+
diff --git a/sysdeps/unix/sysv/linux/sparc/init-first.c b/sysdeps/unix/sysv/linux/sparc/init-first.c
index 643d6c7c88..bdaa78fd32 100644
--- a/sysdeps/unix/sysv/linux/sparc/init-first.c
+++ b/sysdeps/unix/sysv/linux/sparc/init-first.c
@@ -28,13 +28,11 @@ long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
+  void *p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 981b2a26b7..3bfb1fc60e 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -41,6 +41,9 @@
     _ret;								\
   })
 
+# define VDSO_NAME  "LINUX_2_6"
+# define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL	1
 # define HAVE_GETTIMEOFDAY_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
index 8886ccd707..3ceab633e5 100644
--- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
@@ -22,6 +22,8 @@
 
 # include <dl-vdso.h>
 # include <errno.h>
+# include <sysdep-vdso.h>
+# include <sysdep-vdso.h>
 
 static int
 __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
@@ -36,12 +38,12 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
 #  define __gettimeofday_type __gettimeofday
 # endif
 
-# undef INIT_ARCH
-# define INIT_ARCH() PREPARE_VERSION_KNOWN (linux26, LINUX_2_6)
+# define INIT_ARCH()
+
 /* If the vDSO is not available we fall back to syscall.  */
 libc_ifunc_hidden (__gettimeofday_type, __gettimeofday,
-		   (_dl_vdso_vsym ("__vdso_gettimeofday", &linux26)
-		    ?: &__gettimeofday_syscall))
+		   (get_vdso_symbol ("__vdso_gettimeofday")
+		    ?: __gettimeofday_syscall));
 libc_hidden_def (__gettimeofday)
 
 #else
diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c
index 3d72488500..60e6d1b7c0 100644
--- a/sysdeps/unix/sysv/linux/x86/time.c
+++ b/sysdeps/unix/sysv/linux/x86/time.c
@@ -22,6 +22,7 @@
 
 #include <dl-vdso.h>
 #include <errno.h>
+#include <sysdep-vdso.h>
 
 static time_t
 __time_syscall (time_t *t)
@@ -38,11 +39,11 @@ __time_syscall (time_t *t)
 # endif
 
 #undef INIT_ARCH
-#define INIT_ARCH() PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
+#define INIT_ARCH()
+
 /* If the vDSO is not available we fall back on the syscall.  */
 libc_ifunc_hidden (time_type, time,
-		   (_dl_vdso_vsym ("__vdso_time", &linux26)
-		    ?:  &__time_syscall))
+		   (get_vdso_symbol ("__vdso_time") ?: __time_syscall))
 libc_hidden_def (time)
 
 #else
diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c
index 85333e5ff3..aede1c858d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/init-first.c
+++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c
@@ -32,15 +32,13 @@ extern __typeof (clock_gettime) __syscall_clock_gettime attribute_hidden;
 static inline void
 __vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  void *p = get_vdso_symbol ("__vdso_clock_gettime");
   if (p == NULL)
     p = __syscall_clock_gettime;
   PTR_MANGLE (p);
   VDSO_SYMBOL(clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__vdso_getcpu", &linux26);
+  p = get_vdso_symbol ("__vdso_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL(getcpu) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 0a3ddd37e1..197329f4dc 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -370,6 +370,9 @@
 # undef INTERNAL_SYSCALL_ERRNO
 # define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
+# define VDSO_NAME  "LINUX_2.6"
+# define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    1
 # define HAVE_GETTIMEOFDAY_VSYSCALL     1
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 2/8] Refactor vDSO initialization code
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
@ 2019-09-05 20:56 ` Adhemerval Zanella
  2019-09-17 14:23   ` Adhemerval Zanella
  2019-09-24 11:41   ` [PATCH] Fix vDSO initialization on arm and mips Andreas Schwab
  2019-09-05 20:56 ` [PATCH 3/8] Enable vDSO on interposed malloc linked statically Adhemerval Zanella
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

Linux vDSO initialization code the internal function pointers require a lot
of duplicated boilerplate over different architectures.  This patch aims to
simplify not only the code but the required definition to enable a vDSO
symbol.

The changes are:

  1. Consolidate all init-first.c on only one implementation and enable
     the symbol based on HAVE_*_VSYSCALL existence.

  2. Set the HAVE_*_VSYSCALL to the architecture expected names string.

  3. Add a new internal implementation, get_vdso_mangle_symbol, which
     returns a mangled function pointer.

Currently the clock_gettime, clock_getres, gettimeofday, getcpu, and time
are handled in an arch-independent way, powerpc still uses some arch-specific
vDSO symbol handled in a specific init-first implementation.

Checked on aarch64-linux-gnu, arm-linux-gnueabihf, i386-linux-gnu,
mips64-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gnu, sparc64-linux-gnu,
and x86_64-linux-gnu.

	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address,
	is_sigtramp_address_rt): Use HAVE_SIGTRAMP_{RT}32 instead of SHARED.
	* sysdeps/powerpc/powerpc64/backtrace.c (is_sigtramp_address):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove file.
	* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Define value based on kernel exported
	name.
	* sysdeps/unix/sysv/linux/arm/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETCPU_VSYSCALL, HAVE_TIME_VSYSCALL, HAVE_GET_TBFREQ,
	HAVE_SIGTRAMP_RT64, HAVE_SIGTRAMP_32, HAVE_SIGTRAMP_RT32): Likewise.
	* sysdeps/unix/sysv/linux/riscv/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
	HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
	HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
	HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
	HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
	HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/dl-vdso.h (VDSO_NAME, VDSO_HASH): Define to
	invalid names if architecture does not define them.
	(get_vdso_mangle_symbol): New symbol.
	* sysdeps/unix/sysv/linux/init-first.c: New file.
	* sysdeps/unix/sysv/linux/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/init-first.c (gettimeofday,
	clock_gettime, clock_getres, getcpu, time): Remove declaration.
	(__libc_vdso_platform_setup_arch): Likewise and use
	get_vdso_mangle_symbol to setup vDSO symbols.
	(sigtramp_rt64, sigtramp32, sigtramp_rt32, get_tbfreq): Add
	attribute_hidden.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/sysdep-vdso.h (VDSO_SYMBOL): Remove
	definition.
---
 sysdeps/powerpc/powerpc32/backtrace.c         |  4 +-
 sysdeps/powerpc/powerpc64/backtrace.c         |  2 +-
 sysdeps/unix/sysv/linux/aarch64/init-first.c  | 44 ----------
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  6 +-
 sysdeps/unix/sysv/linux/arm/init-first.c      | 41 ----------
 sysdeps/unix/sysv/linux/arm/libc-vdso.h       | 29 -------
 sysdeps/unix/sysv/linux/arm/sysdep.h          |  4 +-
 sysdeps/unix/sysv/linux/dl-vdso.h             | 21 ++++-
 sysdeps/unix/sysv/linux/i386/init-first.c     | 46 -----------
 sysdeps/unix/sysv/linux/i386/sysdep.h         |  4 +-
 sysdeps/unix/sysv/linux/init-first.c          | 80 +++++++++++++++++++
 .../unix/sysv/linux/{aarch64 => }/libc-vdso.h | 18 ++++-
 sysdeps/unix/sysv/linux/mips/init-first.c     | 40 ----------
 sysdeps/unix/sysv/linux/mips/libc-vdso.h      | 29 -------
 sysdeps/unix/sysv/linux/mips/sysdep.h         |  4 +-
 sysdeps/unix/sysv/linux/powerpc/init-first.c  | 51 +++---------
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h   | 12 +--
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 14 +++-
 sysdeps/unix/sysv/linux/riscv/init-first.c    | 54 -------------
 sysdeps/unix/sysv/linux/riscv/libc-vdso.h     | 34 --------
 sysdeps/unix/sysv/linux/riscv/sysdep.h        |  8 +-
 sysdeps/unix/sysv/linux/s390/init-first.c     | 56 -------------
 sysdeps/unix/sysv/linux/s390/libc-vdso.h      | 35 --------
 sysdeps/unix/sysv/linux/s390/sysdep.h         |  8 +-
 sysdeps/unix/sysv/linux/sparc/init-first.c    | 42 ----------
 sysdeps/unix/sysv/linux/sparc/libc-vdso.h     | 29 -------
 sysdeps/unix/sysv/linux/sparc/sysdep.h        |  4 +-
 sysdeps/unix/sysv/linux/sysdep-vdso.h         |  2 +-
 sysdeps/unix/sysv/linux/x86/libc-vdso.h       | 33 --------
 sysdeps/unix/sysv/linux/x86_64/init-first.c   | 48 -----------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  6 +-
 31 files changed, 164 insertions(+), 644 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/i386/init-first.c
 create mode 100644 sysdeps/unix/sysv/linux/init-first.c
 rename sysdeps/unix/sysv/linux/{aarch64 => }/libc-vdso.h (70%)
 delete mode 100644 sysdeps/unix/sysv/linux/mips/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/riscv/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/riscv/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/init-first.c

diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c
index 857a8aad7b..2978632017 100644
--- a/sysdeps/powerpc/powerpc32/backtrace.c
+++ b/sysdeps/powerpc/powerpc32/backtrace.c
@@ -54,7 +54,7 @@ struct signal_frame_32 {
 static inline int
 is_sigtramp_address (void *nip)
 {
-#ifdef SHARED
+#ifdef HAVE_SIGTRAMP_RT32
   if (nip == VDSO_SYMBOL (sigtramp32))
     return 1;
 #endif
@@ -71,7 +71,7 @@ struct rt_signal_frame_32 {
 static inline int
 is_sigtramp_address_rt (void * nip)
 {
-#ifdef SHARED
+#ifdef HAVE_SIGTRAMP_32
   if (nip == VDSO_SYMBOL (sigtramp_rt32))
     return 1;
 #endif
diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c
index 7a167838d9..0fa7e9c403 100644
--- a/sysdeps/powerpc/powerpc64/backtrace.c
+++ b/sysdeps/powerpc/powerpc64/backtrace.c
@@ -57,7 +57,7 @@ struct signal_frame_64 {
 static inline int
 is_sigtramp_address (void *nip)
 {
-#ifdef SHARED
+#ifdef HAVE_SIGTRAMP_RT64
   if (nip == VDSO_SYMBOL (sigtramp_rt64))
     return 1;
 #endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/init-first.c b/sysdeps/unix/sysv/linux/aarch64/init-first.c
deleted file mode 100644
index c3c27cfd4b..0000000000
--- a/sysdeps/unix/sysv/linux/aarch64/init-first.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__kernel_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(gettimeofday) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(clock_gettime) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(clock_getres) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index 662d321235..d57f7232e2 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -160,9 +160,9 @@
 # endif
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	1
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETTIMEOFDAY_VSYSCALL	1
+# define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
+# define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 
 /* Previously AArch64 used the generic version without the libc_hidden_def
    which lead in a non existent __send symbol in libc.so.  */
diff --git a/sysdeps/unix/sysv/linux/arm/init-first.c b/sysdeps/unix/sysv/linux/arm/init-first.c
deleted file mode 100644
index 2852ab135c..0000000000
--- a/sysdeps/unix/sysv/linux/arm/init-first.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/ARM.
-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-#include <sysdep-vdso.h>
-
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/arm/libc-vdso.h b/sysdeps/unix/sysv/linux/arm/libc-vdso.h
deleted file mode 100644
index 8702165c6b..0000000000
--- a/sysdeps/unix/sysv/linux/arm/libc-vdso.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* VDSO function pointer declarations.  Linux/ARM.
-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index 467ccf2631..634aa2bc6b 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -392,8 +392,8 @@ __local_syscall_error:						\
 #define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_gettimeofday"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_clock_gettime"
 
 #define LOAD_ARGS_0()
 #define ASM_ARGS_0
diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h
index bab3779615..dcf065ef23 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso.h
@@ -19,16 +19,25 @@
 #ifndef _DL_VDSO_H
 #define _DL_VDSO_H	1
 
-#include <assert.h>
 #include <ldsodefs.h>
 #include <dl-hash.h>
-#include <libc-vdso.h>
 
 /* Functions for resolving symbols in the VDSO link map.  */
 extern void *_dl_vdso_vsym (const char *name,
 			    const struct r_found_version *version)
       attribute_hidden;
 
+/* If the architecture support vDSO it should define which is the expected
+   kernel version and hash value through both VDSO_NAME and VDSO_HASH
+   (usually defined at architecture sysdep.h).  */
+
+#ifndef VDSO_NAME
+# define VDSO_NAME "LINUX_0.0"
+#endif
+#ifndef VDSO_HASH
+# define VDSO_HASH 0
+#endif
+
 static inline void *
 get_vdso_symbol (const char *symbol)
 {
@@ -36,4 +45,12 @@ get_vdso_symbol (const char *symbol)
   return _dl_vdso_vsym (symbol, &rfv);
 }
 
+static inline void *
+get_vdso_mangle_symbol (const char *symbol)
+{
+  void *vdsop = get_vdso_symbol (symbol);
+  PTR_MANGLE (vdsop);
+  return vdsop;
+}
+
 #endif /* dl-vdso.h */
diff --git a/sysdeps/unix/sysv/linux/i386/init-first.c b/sysdeps/unix/sysv/linux/i386/init-first.c
deleted file mode 100644
index 9c03f87b67..0000000000
--- a/sysdeps/unix/sysv/linux/i386/init-first.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/i386.
-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <time.h>
-#include <sysdep.h>
-#include <dl-vdso.h>
-#include <sysdep-vdso.h>
-
-long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-  attribute_hidden;
-
-static long int
-clock_gettime_syscall (clockid_t id, struct timespec *tp)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (clock_gettime, err, 2, id, tp);
-}
-
-static inline void
-__vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_clock_gettime");
-  if (p == NULL)
-    p = clock_gettime_syscall;
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP __vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 278028f52e..e793fdc936 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -313,8 +313,8 @@ struct libc_do_syscall_args
 # define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETTIME_VSYSCALL    1
-# define HAVE_GETTIMEOFDAY_VSYSCALL     1
+# define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
 
 /* Define a macro which expands inline into the wrapper code for a system
    call.  This use is for internal calls that do not need to handle errors
diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
new file mode 100644
index 0000000000..d90ca820be
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -0,0 +1,80 @@
+/* vDSO internal symbols.  Linux generic version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <dl-vdso.h>
+#include <libc-vdso.h>
+
+/* vDSO symbol used on clock_gettime implementation.  */
+#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
+int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
+  attribute_hidden;
+#endif
+/* vDSO symbol used on clock_getres implementation.  */
+#ifdef HAVE_CLOCK_GETRES_VSYSCALL
+int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *)
+  attribute_hidden;
+#endif
+/* vDSO symbol used on gettimeofday implementation.  */
+#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
+int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
+  attribute_hidden;
+#endif
+/* vDSO symbol used on GNU extension getcpu implementation.  */
+#ifdef HAVE_GETCPU_VSYSCALL
+long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
+   attribute_hidden;
+#endif
+/* vDSO symbol used on time implementation.  */
+#ifdef HAVE_TIME_VSYSCALL
+time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden;
+#endif
+
+static inline void
+__libc_vdso_platform_setup (void)
+{
+#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
+  VDSO_SYMBOL(clock_gettime)
+    = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL);
+#endif
+
+#ifdef HAVE_CLOCK_GETRES_VSYSCALL
+  VDSO_SYMBOL(clock_getres)
+    = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL);
+#endif
+
+#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
+  VDSO_SYMBOL(gettimeofday)
+    = get_vdso_mangle_symbol (HAVE_GETTIMEOFDAY_VSYSCALL);
+#endif
+
+#ifdef HAVE_GETCPU_VSYSCALL
+  VDSO_SYMBOL(getcpu) = get_vdso_mangle_symbol (HAVE_GETCPU_VSYSCALL);
+#endif
+
+#ifdef HAVE_TIME_VSYSCALL
+  VDSO_SYMBOL(time) = get_vdso_mangle_symbol (HAVE_TIME_VSYSCALL);
+#endif
+
+#ifdef VDSO_SETUP_ARCH
+  VDSO_SETUP_ARCH ();
+#endif
+}
+
+#define VDSO_SETUP __libc_vdso_platform_setup
+
+#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc-vdso.h b/sysdeps/unix/sysv/linux/libc-vdso.h
similarity index 70%
rename from sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
rename to sysdeps/unix/sysv/linux/libc-vdso.h
index 3fcbaa9fce..f681868137 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/libc-vdso.h
@@ -19,12 +19,22 @@
 #ifndef _LIBC_VDSO_H
 #define _LIBC_VDSO_H
 
-#include <sysdep.h>
-#include <sysdep-vdso.h>
+#define VDSO_SYMBOL(__name) __vdso_##__name
 
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
+#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
 extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
+#endif
+#ifdef HAVE_CLOCK_GETRES_VSYSCALL
 extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
+#endif
+#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
+extern int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *);
+#endif
+#ifdef HAVE_GETCPU_VSYSCALL
+extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *);
+#endif
+#ifdef HAVE_TIME_VSYSCALL
+extern time_t (*VDSO_SYMBOL(time)) (time_t *);
+#endif
 
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/mips/init-first.c b/sysdeps/unix/sysv/linux/mips/init-first.c
deleted file mode 100644
index 2a43bdc8b0..0000000000
--- a/sysdeps/unix/sysv/linux/mips/init-first.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/mips/libc-vdso.h b/sysdeps/unix/sysv/linux/mips/libc-vdso.h
deleted file mode 100644
index 344ea2d750..0000000000
--- a/sysdeps/unix/sysv/linux/mips/libc-vdso.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* VDSO function pointer declarations.
-   Copyright (C) 2016-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
index cabc590961..58a7244581 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -20,5 +20,5 @@
 #define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL     1
-#define HAVE_GETTIMEOFDAY_VSYSCALL      1
+#define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
+#define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c
index 0d46563ce3..6e72d9ca84 100644
--- a/sysdeps/unix/sysv/linux/powerpc/init-first.c
+++ b/sysdeps/unix/sysv/linux/powerpc/init-first.c
@@ -19,47 +19,18 @@
 #include <dl-vdso.h>
 #include <libc-vdso.h>
 
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-  attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
-unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
-int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
-time_t (*VDSO_SYMBOL(time)) (time_t *);
-
+unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void) attribute_hidden;
 #if defined(__PPC64__) || defined(__powerpc64__)
-void *VDSO_SYMBOL(sigtramp_rt64);
+void *VDSO_SYMBOL(sigtramp_rt64) attribute_hidden;
 #else
-void *VDSO_SYMBOL(sigtramp32);
-void *VDSO_SYMBOL(sigtramp_rt32);
+void *VDSO_SYMBOL(sigtramp32) attribute_hidden;
+void *VDSO_SYMBOL(sigtramp_rt32) attribute_hidden;
 #endif
 
 static inline void
-_libc_vdso_platform_setup (void)
+__libc_vdso_platform_setup_arch (void)
 {
-  void *p = get_vdso_symbol ("__kernel_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_getres) = p;
-
-  p = get_vdso_symbol ("__kernel_get_tbfreq");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (get_tbfreq) = p;
-
-  p = get_vdso_symbol ("__kernel_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (getcpu) = p;
-
-  p = get_vdso_symbol ("__kernel_time");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (time) = p;
+  VDSO_SYMBOL (get_tbfreq) = get_vdso_mangle_symbol (HAVE_GET_TBFREQ);
 
   /* PPC64 uses only one signal trampoline symbol, while PPC32 will use
      two depending if SA_SIGINFO is used (__kernel_sigtramp_rt32) or not
@@ -67,13 +38,13 @@ _libc_vdso_platform_setup (void)
      There is no need to pointer mangle these symbol because they will
      used only for pointer comparison.  */
 #if defined(__PPC64__) || defined(__powerpc64__)
-  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol ("__kernel_sigtramp_rt64");
+  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol (HAVE_SIGTRAMP_RT64);
 #else
-  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol ("__kernel_sigtramp32");
-  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol ("__kernel_sigtramp_rt32");
+  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol (HAVE_SIGTRAMP_32);
+  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol (HAVE_SIGTRAMP_RT32);
 #endif
 }
 
-#define VDSO_SETUP _libc_vdso_platform_setup
+#define VDSO_SETUP_ARCH __libc_vdso_platform_setup_arch
 
-#include <csu/init-first.c>
+#include <sysdeps/unix/sysv/linux/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index f8184061c0..47e925493b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -17,20 +17,14 @@
    <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
+#ifndef _LIBC_POWERPC_VDSO_H
+#define _LIBC_POWERPC_VDSO_H
 
 #include <sysdep.h>
 #include <sysdep-vdso.h>
+#include_next <libc-vdso.h>
 
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-  attribute_hidden;
-extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
 extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
-extern int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
-extern time_t (*VDSO_SYMBOL(time)) (time_t *);
-
 #if defined(__PPC64__) || defined(__powerpc64__)
 extern void *VDSO_SYMBOL(sigtramp_rt64);
 #else
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 5b411d0e8e..20167615c8 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -20,7 +20,15 @@
 #define VDSO_HASH  123718565
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
+#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
+#define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
+#define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
+#define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
+#if defined(__PPC64__) || defined(__powerpc64__)
+# define HAVE_SIGTRAMP_RT64		"__kernel_sigtramp_rt64"
+#else
+# define HAVE_SIGTRAMP_32		"__kernel_sigtramp32"
+# define HAVE_SIGTRAMP_RT32		"__kernel_sigtramp_rt32"
+#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
deleted file mode 100644
index f3d243a192..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/init-first.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* RISC-V VDSO initialization
-   Copyright (C) 2017-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
-    attribute_hidden;
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (getcpu) = p;
-
-  p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_getres) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
deleted file mode 100644
index 2373292ab9..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* RISC-V VDSO function declarations
-   Copyright (C) 2017-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
-    attribute_hidden;
-extern long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-extern long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-    attribute_hidden;
-extern long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
-    attribute_hidden;
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 5de773744c..22835aa12f 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -125,10 +125,10 @@
 # define VDSO_HASH  182943605
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	1
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETTIMEOFDAY_VSYSCALL	1
-# define HAVE_GETCPU_VSYSCALL		1
+# define HAVE_CLOCK_GETRES_VSYSCALL	"__vdso_clock_getres"
+# define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
+# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
deleted file mode 100644
index 3e36270eac..0000000000
--- a/sysdeps/unix/sysv/linux/s390/init-first.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/s390.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-
-long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
-  __attribute__ ((nocommon));
-
-long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *)
-  __attribute__ ((nocommon));
-
-long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-   attribute_hidden;
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__kernel_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_getres) = p;
-
-  p = get_vdso_symbol ("__kernel_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (getcpu) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/s390/libc-vdso.h b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
deleted file mode 100644
index cc97601383..0000000000
--- a/sysdeps/unix/sysv/linux/s390/libc-vdso.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Resolve function pointers to VDSO functions.
-   Copyright (C) 2008-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-
-extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-extern long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
-
-extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-   attribute_hidden;
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
index eefbd8f007..386efb1896 100644
--- a/sysdeps/unix/sysv/linux/s390/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -20,8 +20,8 @@
 #define VDSO_HASH  123718585
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
+#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
+#define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+#define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 
diff --git a/sysdeps/unix/sysv/linux/sparc/init-first.c b/sysdeps/unix/sysv/linux/sparc/init-first.c
deleted file mode 100644
index bdaa78fd32..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/init-first.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* SPARC VDSO initialization
-   Copyright (C) 2018-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-    attribute_hidden;
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h b/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
deleted file mode 100644
index d20afcdf04..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* VDSO function pointer declarations.
-   Copyright (C) 2018-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library.  If not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 3bfb1fc60e..925b57082d 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -45,8 +45,8 @@
 # define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETTIMEOFDAY_VSYSCALL	1
+# define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 
 #undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...) 				\
diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index 5fec208380..3da5417fff 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -19,7 +19,7 @@
 #ifndef SYSDEP_VDSO_LINUX_H
 # define SYSDEP_VDSO_LINUX_H
 
-#define VDSO_SYMBOL(__name) __vdso_##__name
+#include <dl-vdso.h>
 
 #ifndef INTERNAL_VSYSCALL_CALL
 # define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		      \
diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
deleted file mode 100644
index c9aa1c8a72..0000000000
--- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Resolve function pointers to VDSO functions.
-   Copyright (C) 2005-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <time.h>
-#include <sys/time.h>
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
-  attribute_hidden;
-
-extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-  attribute_hidden;
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c
deleted file mode 100644
index aede1c858d..0000000000
--- a/sysdeps/unix/sysv/linux/x86_64/init-first.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/x86-64.
-   Copyright (C) 2007-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#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;
-long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-  attribute_hidden;
-
-extern __typeof (clock_gettime) __syscall_clock_gettime attribute_hidden;
-
-
-static inline void
-__vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_clock_gettime");
-  if (p == NULL)
-    p = __syscall_clock_gettime;
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(clock_gettime) = p;
-
-  p = get_vdso_symbol ("__vdso_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(getcpu) = p;
-}
-
-#define VDSO_SETUP __vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 197329f4dc..4541c0d492 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -374,9 +374,9 @@
 # define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETTIME_VSYSCALL    1
-# define HAVE_GETTIMEOFDAY_VSYSCALL     1
-# define HAVE_GETCPU_VSYSCALL		1
+# define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
+# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
 # define SINGLE_THREAD_BY_GLOBAL		1
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH 3/8] Enable vDSO on interposed malloc linked statically
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH v2 2/8] Refactor vDSO initialization code Adhemerval Zanella
@ 2019-09-05 20:56 ` Adhemerval Zanella
  2019-10-08 18:35   ` Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros Adhemerval Zanella
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

For statically linked binaries, _dl_non_dynamic_init (csu/init-first.c:74)
calls malloc before the vDSO is properly initialized (it will fully usable
only after VDSO_SETUP call).  The bug is triggered for the cases where an
interposed malloc calls clock_gettime or any other implementation that may
call a vDSO symbol.

It is because PTR_DEMANDLE at {INLINE,INTERNAL}_VSYSCALL is called with
uninitialized __vdso_* pointer value, which should be done by PTR_MANGLE
(zero-initialized value in this case is invalid).  The patch fixes by adding
an extra hook before _dl_non_dynamic_init which setup the initial __vdso_*
pointer symbol to an mangled NULL value.

For NULL mangled values {INLINE,INTERNAL}_VSYSCALL issues the syscall
directly in fallback code path.  Once the __vdso_* is setup the vsyscall
branches to vDSO.

Checked on x86_64-linux-gnu.

	[BZ #24967]
	* sysdeps/unix/sysv/linux/init-first.c (libc_vdso_mangled_symbol):
	New symbol.
	(__libc_vdso_platform_setup): Add an option to call it to initialize
	the hooks to null values.
	(VDSO_PRE_SETUP): Define.
	* csu/init-first.c (_init): Add a pre-hook to initialize the vDSO
	internal pointer.
	* malloc/tst-interpose-aux.c (allocation_header): Add ts member.
	(malloc_internal): Call clock_gettime.
---
 csu/init-first.c                     |  8 ++++++
 malloc/tst-interpose-aux.c           |  5 ++++
 sysdeps/unix/sysv/linux/init-first.c | 37 +++++++++++++++++++---------
 3 files changed, 39 insertions(+), 11 deletions(-)

diff --git a/csu/init-first.c b/csu/init-first.c
index 10762b61f5..d984419554 100644
--- a/csu/init-first.c
+++ b/csu/init-first.c
@@ -69,6 +69,14 @@ _init (int argc, char **argv, char **envp)
   __environ = envp;
 
 #ifndef SHARED
+  /* Initialize the vDSO internal pointers to mangled zero value.  It makes
+     the {INTERNAL,INLINE}_VSYSCALL macro to fallback to direct syscall
+     and allows call the symbol that might the vDSO on _dl_non_dynamic_init
+     (for instance clock_gettime on an interposed malloc).  */
+# ifdef VDSO_PRE_SETUP
+  VDSO_PRE_SETUP ();
+# endif
+
   /* First the initialization which normally would be done by the
      dynamic linker.  */
   _dl_non_dynamic_init ();
diff --git a/malloc/tst-interpose-aux.c b/malloc/tst-interpose-aux.c
index bf86224401..de62d436bc 100644
--- a/malloc/tst-interpose-aux.c
+++ b/malloc/tst-interpose-aux.c
@@ -28,6 +28,7 @@
 #include <sys/mman.h>
 #include <sys/uio.h>
 #include <unistd.h>
+#include <time.h>
 
 #if INTERPOSE_THREADS
 #include <pthread.h>
@@ -96,6 +97,7 @@ struct __attribute__ ((aligned (__alignof__ (max_align_t)))) allocation_header
 {
   size_t allocation_index;
   size_t allocation_size;
+  struct timespec ts;
 };
 
 /* Array of known allocations, to track invalid frees.  */
@@ -166,6 +168,9 @@ malloc_internal (size_t size)
       .allocation_index = index,
       .allocation_size = allocation_size
     };
+  /* Check if calling a symbol which may use the vDSO does not fail.
+     The CLOCK_REALTIME should be supported on all systems.  */
+  clock_gettime (CLOCK_REALTIME, &allocations[index]->ts);
   return allocations[index] + 1;
 }
 
diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
index d90ca820be..a23e5d9f6e 100644
--- a/sysdeps/unix/sysv/linux/init-first.c
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -44,37 +44,52 @@ long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
 time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden;
 #endif
 
+static inline void *
+__libc_vdso_mangled_symbol (const char *symbol)
+{
+  void *vdsop = NULL;
+  if (symbol != NULL)
+    vdsop = get_vdso_mangle_symbol (symbol);
+  else
+    PTR_MANGLE (vdsop);
+  return vdsop;
+}
+
 static inline void
-__libc_vdso_platform_setup (void)
+__libc_vdso_platform_setup (bool initial)
 {
 #ifdef HAVE_CLOCK_GETTIME_VSYSCALL
-  VDSO_SYMBOL(clock_gettime)
-    = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL);
+  VDSO_SYMBOL(clock_gettime) =
+    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_CLOCK_GETTIME_VSYSCALL);
 #endif
 
 #ifdef HAVE_CLOCK_GETRES_VSYSCALL
-  VDSO_SYMBOL(clock_getres)
-    = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL);
+  VDSO_SYMBOL(clock_getres) =
+    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_CLOCK_GETRES_VSYSCALL);
 #endif
 
 #ifdef HAVE_GETTIMEOFDAY_VSYSCALL
-  VDSO_SYMBOL(gettimeofday)
-    = get_vdso_mangle_symbol (HAVE_GETTIMEOFDAY_VSYSCALL);
+  VDSO_SYMBOL(gettimeofday) =
+    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_GETTIMEOFDAY_VSYSCALL);
 #endif
 
 #ifdef HAVE_GETCPU_VSYSCALL
-  VDSO_SYMBOL(getcpu) = get_vdso_mangle_symbol (HAVE_GETCPU_VSYSCALL);
+  VDSO_SYMBOL(getcpu) =
+    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_GETCPU_VSYSCALL);
 #endif
 
 #ifdef HAVE_TIME_VSYSCALL
-  VDSO_SYMBOL(time) = get_vdso_mangle_symbol (HAVE_TIME_VSYSCALL);
+  VDSO_SYMBOL(time) =
+    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_TIME_VSYSCALL);
 #endif
 
 #ifdef VDSO_SETUP_ARCH
-  VDSO_SETUP_ARCH ();
+  if (!initial)
+    VDSO_SETUP_ARCH ();
 #endif
 }
 
-#define VDSO_SETUP __libc_vdso_platform_setup
+#define VDSO_PRE_SETUP() ({ __libc_vdso_platform_setup (true); })
+#define VDSO_SETUP()     ({ __libc_vdso_platform_setup (false); })
 
 #include <csu/init-first.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH v2 2/8] Refactor vDSO initialization code Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH 3/8] Enable vDSO on interposed malloc linked statically Adhemerval Zanella
@ 2019-09-05 20:56 ` Adhemerval Zanella
  2019-09-05 22:05   ` cseo
  2019-09-05 20:56 ` [PATCH v2 5/8] mips: Consolidate INTERNAL_VSYSCALL_CALL Adhemerval Zanella
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

Changes from previous version:

  - Fixed the issue with the removal of the CR0.SO check on
    INTERNAL_VSYSCALL_CALL.

--

This patch simplifies the powerpc internal macros for vDSO calls
by:

  - Removing INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK, used solely on
    get_timebase_freq.

  - Adjust INTERNAL_VSYSCALL_CALL_TYPE powerpc32 to follow powerpc64
    argument ordering.

  - Use HAVE_*_VSYSCALL instead of explicit strings.

  - Make powerpc libc-vdso.h include generic implementation.

No semantic change expected, checked on powerpc-linux-gnu-power4,
powerpc64-linux-gnu, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/libc-vdso.h (VDSO_IFUNC_RET): Define if not
	defined.
	* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
	(__get_timebase_freq): Remove use of
	INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK.
	(get_timebase_freq_fallback): New symbol.
	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c (time): Use
	HAVE_GETTIMEOFDAY_VSYSCALL.
	* sysdeps/unix/sysv/linux/powerpc/time.c (gettimeofday): Use
	HAVE_TIME_VSYSCALL.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Include generic
	implementation.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	(INTERNAL_VSYSCALL_CALL_TYPE): Make calling convention similar to
	powerpc64.
	(INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Remove macro.
	* .../sysv/linux/powerpc/powerpc64/sysdep.h
	(INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
	(HAVE_GETTIMEOFDAY_VSYSCALL): Define.
---
 sysdeps/unix/sysv/linux/libc-vdso.h           |  7 ++++++
 .../sysv/linux/powerpc/get_timebase_freq.c    | 24 ++++++++++++-------
 .../unix/sysv/linux/powerpc/gettimeofday.c    |  2 +-
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h   | 24 ++++++++++---------
 .../sysv/linux/powerpc/powerpc32/sysdep.h     | 18 ++------------
 .../sysv/linux/powerpc/powerpc64/sysdep.h     | 19 +--------------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/powerpc/time.c        |  2 +-
 8 files changed, 41 insertions(+), 56 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/libc-vdso.h b/sysdeps/unix/sysv/linux/libc-vdso.h
index f681868137..199ae9a033 100644
--- a/sysdeps/unix/sysv/linux/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/libc-vdso.h
@@ -21,6 +21,13 @@
 
 #define VDSO_SYMBOL(__name) __vdso_##__name
 
+/* Adjust the return IFUNC value from a vDSO symbol accordingly required
+   architecture ABI.  It is used for powerpc64 elfv1 to create a ODP
+   entry since kernvel vDSO does not provide it.  */
+#ifndef VDSO_IFUNC_RET
+# define VDSO_IFUNC_RET(__value) (__value)
+#endif
+
 #ifdef HAVE_CLOCK_GETTIME_VSYSCALL
 extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
 #endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index c245e97526..61ff6e2b2a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -23,17 +23,11 @@
 #include <not-cancel.h>
 #include <libc-vdso.h>
 
-uint64_t
-__get_timebase_freq (void)
+static uint64_t
+get_timebase_freq_fallback (void)
 {
   hp_timing_t result = 0L;
 
-#ifdef SHARED
-  /* The vDSO does not return an error (it clear cr0.so on returning).  */
-  INTERNAL_SYSCALL_DECL (err);
-  result =
-    INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, uint64_t, 0);
-#else
   /* We read the information from the /proc filesystem.  /proc/cpuinfo
      contains at least one line like:
      timebase        : 33333333
@@ -99,8 +93,20 @@ __get_timebase_freq (void)
 	    }
 	}
     }
-#endif
 
   return result;
 }
+
+uint64_t
+__get_timebase_freq (void)
+{
+  /* The vDSO does not have a fallback mechanism (such calling a syscall).  */
+  __typeof (VDSO_SYMBOL (get_tbfreq)) vdsop = VDSO_SYMBOL (get_tbfreq);
+  PTR_DEMANGLE (vdsop);
+  if (vdsop == NULL)
+    return get_timebase_freq_fallback ();
+
+  INTERNAL_SYSCALL_DECL (err);
+  return INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, uint64_t, 0);
+}
 weak_alias (__get_timebase_freq, __ppc_get_timebase_freq)
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
index c59d5ddc10..e046594d40 100644
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
@@ -58,7 +58,7 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
 }
 
 # define INIT_ARCH() \
-  void *vdso_gettimeofday = get_vdso_symbol ("__kernel_gettimeofday")
+  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
   
 /* If the vDSO is not available we fall back syscall.  */
 libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index 47e925493b..170adcc964 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -22,17 +22,9 @@
 
 #include <sysdep.h>
 #include <sysdep-vdso.h>
-#include_next <libc-vdso.h>
-
-extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
-#if defined(__PPC64__) || defined(__powerpc64__)
-extern void *VDSO_SYMBOL(sigtramp_rt64);
-#else
-extern void *VDSO_SYMBOL(sigtramp32);
-extern void *VDSO_SYMBOL(sigtramp_rt32);
-#endif
 
 #if (defined(__PPC64__) || defined(__powerpc64__)) && _CALL_ELF != 2
+# include <dl-machine.h>
 /* The correct solution is for _dl_vdso_vsym to return the address of the OPD
    for the kernel VDSO function.  That address would then be stored in the
    __vdso_* variables and returned as the result of the IFUNC resolver function.
@@ -51,7 +43,7 @@ extern void *VDSO_SYMBOL(sigtramp_rt32);
    are processed immediately at startup the resolver functions and this code need
    not be thread-safe, but if the caller writes to a PLT slot it must do so in a
    thread-safe manner with all the required barriers.  */
-#define VDSO_IFUNC_RET(value)                            \
+# define VDSO_IFUNC_RET(value)                           \
   ({                                                     \
     static Elf64_FuncDesc vdso_opd = { .fd_toc = ~0x0 }; \
     vdso_opd.fd_func = (Elf64_Addr)value;                \
@@ -59,7 +51,17 @@ extern void *VDSO_SYMBOL(sigtramp_rt32);
   })
 
 #else
-#define VDSO_IFUNC_RET(value)  ((void *) (value))
+# define VDSO_IFUNC_RET(value)  ((void *) (value))
+#endif
+
+#include_next <libc-vdso.h>
+
+extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
+#if defined(__PPC64__) || defined(__powerpc64__)
+extern void *VDSO_SYMBOL(sigtramp_rt64);
+#else
+extern void *VDSO_SYMBOL(sigtramp32);
+extern void *VDSO_SYMBOL(sigtramp_rt32);
 #endif
 
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index f459543fcd..703c668a92 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -41,7 +41,7 @@
    function call, with the exception of LR (which is needed for the
    "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
    an error return status).  */
-# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, type, args...)	      \
+# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...)	      \
   ({									      \
     register void *r0  __asm__ ("r0");					      \
     register long int r3  __asm__ ("r3");				      \
@@ -69,7 +69,7 @@
   })
 
 #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
-  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, long int, args)
+  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
 
 # undef INLINE_SYSCALL
 # define INLINE_SYSCALL(name, nr, args...)				\
@@ -131,20 +131,6 @@
 # undef INTERNAL_SYSCALL_ERRNO
 # define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
 
-# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)  \
-  ({									      \
-    type sc_ret = ENOSYS;						      \
-									      \
-    __typeof (__vdso_##name) vdsop = __vdso_##name;			      \
-    PTR_DEMANGLE (vdsop);						      \
-    if (vdsop != NULL)							      \
-      sc_ret = 								      \
-        INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, nr, type, ##args);	      \
-    else								      \
-      err = 1 << 28;							      \
-    sc_ret;								      \
-  })
-
 # define LOADARGS_0(name, dummy)					      \
 	r0 = name
 # define LOADARGS_1(name, __arg1) \
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 06222f52e6..e7b2fce05f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -45,22 +45,6 @@
 
 #endif /* __ASSEMBLER__ */
 
-/* This version is for internal uses when there is no desire
-   to set errno */
-#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)   \
-  ({									      \
-    type sc_ret = ENOSYS;						      \
-									      \
-    __typeof (__vdso_##name) vdsop = __vdso_##name;			      \
-    PTR_DEMANGLE (vdsop);						      \
-    if (vdsop != NULL)							      \
-      sc_ret =								      \
-        INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, type, nr, ##args);	      \
-    else								      \
-      err = 1 << 28;							      \
-    sc_ret;								      \
-  })
-
 /* Define a macro which expands inline into the wrapper code for a system
    call. This use is for internal calls that do not need to handle errors
    normally. It will never touch errno. This returns just what the kernel
@@ -94,10 +78,9 @@
 #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
   INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
 
-#undef INLINE_SYSCALL
-
 /* This version is for kernels that implement system calls that
    behave like function calls as far as register saving.  */
+#undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)				\
   ({									\
     INTERNAL_SYSCALL_DECL (sc_err);					\
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 20167615c8..357d1b5243 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -24,6 +24,7 @@
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
 #if defined(__PPC64__) || defined(__powerpc64__)
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
index 38477bce8b..f0537a2307 100644
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ b/sysdeps/unix/sysv/linux/powerpc/time.c
@@ -67,7 +67,7 @@ time_syscall (time_t *t)
 }
 
 # define INIT_ARCH() \
-  void *vdso_time = get_vdso_symbol ("__kernel_time");
+  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
 
 /* If the vDSO is not available we fall back to the syscall.  */
 libc_ifunc_hidden (__redirect_time, time,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 5/8] mips: Consolidate INTERNAL_VSYSCALL_CALL
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2019-09-05 20:56 ` [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros Adhemerval Zanella
@ 2019-09-05 20:56 ` Adhemerval Zanella
  2019-09-17 14:24   ` Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH v2 6/8] sparc64: Use linux generic time implementation Adhemerval Zanella
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the mips, mips64, and mips64-n32
INTERNAL_VSYSCALL_CALL on a single implementation.

No semantic changes. I checked against a build for mips-linux-gnu,
mips64-linux-gnu, and mips64-n32-linux-gnu.

	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
	(INTERNAL_VSYSCALL_CALL): Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
	(INTERNAL_VSYSCALL_CALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
	(INTERNAL_VSYSCALL_CALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep.h (INTERNAL_VSYSCALL_CALL):
	New macro.
---
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h     | 12 ------------
 sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h | 12 ------------
 sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h | 12 ------------
 sysdeps/unix/sysv/linux/mips/sysdep.h            | 16 ++++++++++++++++
 4 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index ebe397b701..bfcb916f15 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -349,18 +349,6 @@ libc_hidden_proto (__mips_syscall7, nomips16)
 #define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
 	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
 
-/* Standard MIPS syscalls have an error flag, and return a positive errno
-   when the error flag is set. Emulate this behaviour for vsyscalls so that
-   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    if (err)								\
-      _ret = -_ret;							\
-    _ret;								\
-  })
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index bb49429c30..49e94a1706 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -297,18 +297,6 @@
 #define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
 	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
 
-/* Standard MIPS syscalls have an error flag, and return a positive errno
-   when the error flag is set. Emulate this behaviour for vsyscalls so that
-   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    if (err)								\
-      _ret = -_ret;							\
-    _ret;								\
-  })
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index 84a1ff186b..5911a62e5b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -293,18 +293,6 @@
 #define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
 	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
 
-/* Standard MIPS syscalls have an error flag, and return a positive errno
-   when the error flag is set. Emulate this behaviour for vsyscalls so that
-   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    if (err)								\
-      _ret = -_ret;							\
-    _ret;								\
-  })
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
index 58a7244581..77b1f9c2fb 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -22,3 +22,19 @@
 /* List of system calls which are supported as vsyscalls.  */
 #define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
 #define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
+
+#ifndef __ASSEMBLER__
+
+/* Standard MIPS syscalls have an error flag, and return a positive errno
+   when the error flag is set. Emulate this behaviour for vsyscalls so that
+   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
+#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
+  ({									\
+    long _ret = funcptr (args);						\
+    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
+    if (err)								\
+      _ret = -_ret;							\
+    _ret;								\
+  })
+
+#endif /* __ASSEMBLER__  */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 6/8] sparc64: Use linux generic time implementation
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2019-09-05 20:56 ` [PATCH v2 5/8] mips: Consolidate INTERNAL_VSYSCALL_CALL Adhemerval Zanella
@ 2019-09-05 20:56 ` Adhemerval Zanella
  2019-09-17 14:26   ` Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH v2 7/8] linux: Consolidate " Adhemerval Zanella
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

There is no need to sparc64 provide an arch-specific implementation to
route to POSIX one (which uses gettimeofday).  Linux one already handles
the case for architecture that does not have __NR_time.

No semantic changes, checked against a build for sparc64-linux-gnu.

	* sysdeps/unix/sysv/linux/sparc/sparc64/time.c: Remove file.
---
 sysdeps/unix/sysv/linux/sparc/sparc64/time.c | 1 -
 1 file changed, 1 deletion(-)
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/time.c

diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c b/sysdeps/unix/sysv/linux/sparc/sparc64/time.c
deleted file mode 100644
index 509b580c55..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/posix/time.c>
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 7/8] linux: Consolidate time implementation
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2019-09-05 20:56 ` [PATCH v2 6/8] sparc64: Use linux generic time implementation Adhemerval Zanella
@ 2019-09-05 20:56 ` Adhemerval Zanella
  2019-09-05 20:56 ` [PATCH v2 8/8] linux: Consolidate gettimeofday implementation Adhemerval Zanella
  2019-09-11 14:10 ` [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Andreas Schwab
  7 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

Changes from previous version:

  - Improve comment about hidden_def_redir.
  - Update due powerpc64 fixes.

--

The time syscall has currently 3 possible implementations:

   1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
      powerpc).
   2. Wire-up __NR_time (hppa, i686, m68k, microblaze, mips, powerpc,
      powerpc64, s390, sh4, sparcv9, x86_64).
   3. Using internal gettimeofday (aarch64, alpha, arm, mips64, mips64-n32,
      nios2, s390x, sparc64).

This patch consolidates all implementation on Linux generic
sysdeps/unix/sysv/linux/time.c.  To simplify the code, some changes are
made:

   * The wire-up with vDSO implementation route external calls directly
     to vDSO through IFUNC.  To enable it the architecture need to
     explicit define USE_TIME_VSYSCALL_IFUNC.

   * Also, powerpc and x86 tries to route internal time usages to
     IFUNC mechanism, which is problematic since powerpc32 and i686 does
     not really support it.  Instead, all internal calls are routed to
     a default internal symbol which in turn calls INTERNAL_VSYSCALL.

   * Static linking also uses the fallback mechanism which calls
     INTERNAL_VSYSCALL, so vDSO is used for this case as well.

The generic implementation issues a syscall as default, calls the
vDSO if the architecture defines HAVE_TIME_VSYSCALL, and route the external
calls to iFUNC if the architecture also defines USE_TIME_VSYSCALL_IFUNC.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.

	* include/libc-symbols.h (hidden_def_redir): New macro.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_TIME_VSYSCALL,
	USE_TIME_VSYSCALL_IFUNC): Define.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (HAVE_TIME_VSYSCALL,
	USE_TIME_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h (USE_TIME_VSYSCALL_IFUNC):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/time.c: Remove file.
	* sysdeps/unix/sysv/linux/x86/time.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/time.c: Likewise.
	* sysdeps/unix/sysv/linux/time.c (time): Handle all possible Linux
	implementations (wire-up syscall, vDSO implementation, iFUNC).
	(time_syscall): New function.
---
 include/libc-symbols.h                   | 11 ++++
 sysdeps/unix/sysv/linux/i386/sysdep.h    |  2 +
 sysdeps/unix/sysv/linux/i386/time.c      | 34 ----------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h |  1 +
 sysdeps/unix/sysv/linux/powerpc/time.c   | 83 ------------------------
 sysdeps/unix/sysv/linux/time.c           | 57 +++++++++++++---
 sysdeps/unix/sysv/linux/x86/time.c       | 60 -----------------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h  |  2 +
 8 files changed, 65 insertions(+), 185 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/i386/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/time.c

diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index b68ec4b7f5..a585a04e63 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -491,6 +491,12 @@ for linking")
    int foo = INITIAL_FOO_VALUE;
    libc_hidden_data_weak (foo)
 
+   If the internal foo should use a different internal symbol (for instance
+   if the symbol is exported as an IFUNC, but internal calls should use a
+   default version) then you may use:
+
+   libc_hidden_def_redir (foo_internal, foo)
+
    If foo is normally just an alias (strong or weak) to some other function,
    you should use the normal strong_alias first, then add libc_hidden_def
    or libc_hidden_weak:
@@ -548,6 +554,7 @@ for linking")
 #  define hidden_ver(local, name)	__hidden_ver1(local, __GI_##name, name);
 #  define hidden_data_ver(local, name)	hidden_ver(local, name)
 #  define hidden_def(name)		__hidden_ver1(__GI_##name, name, name);
+#  define hidden_def_redir(redir, name)	__hidden_ver1(redir, __GI_##name, redir);
 #  define hidden_data_def(name)		hidden_def(name)
 #  define hidden_tls_def(name)				\
   __hidden_ver2 (__thread, __GI_##name, name, name);
@@ -575,6 +582,7 @@ for linking")
    hidden_proto doesn't make sense for assembly but the equivalent
    is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET.  */
 #  define hidden_def(name)	strong_alias (name, __GI_##name)
+#  define hidden_def_redir(redir, name)	strong_alias(redir, __GI_##name);
 #  define hidden_weak(name)	hidden_def (name)
 #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
 #  define hidden_data_def(name)	strong_data_alias (name, __GI_##name)
@@ -605,6 +613,7 @@ for linking")
 # endif /* Not  __ASSEMBLER__ */
 # define hidden_weak(name)
 # define hidden_def(name)
+# define hidden_def_redir(redir, name)
 # define hidden_ver(local, name)
 # define hidden_data_weak(name)
 # define hidden_data_def(name)
@@ -617,6 +626,7 @@ for linking")
 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
 # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
 # define libc_hidden_def(name) hidden_def (name)
+# define libc_hidden_def_redir(redir, name) hidden_def_redir (redir, name)
 # define libc_hidden_weak(name) hidden_weak (name)
 # ifdef LINK_OBSOLETE_RPC
    /* libc_hidden_nolink_sunrpc should only get used in sunrpc code.  */
@@ -633,6 +643,7 @@ for linking")
 # define libc_hidden_proto(name, attrs...)
 # define libc_hidden_tls_proto(name, attrs...)
 # define libc_hidden_def(name)
+# define libc_hidden_def_redir(redir, name)
 # define libc_hidden_weak(name)
 # define libc_hidden_ver(local, name)
 # define libc_hidden_data_def(name)
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index e793fdc936..4f79f25989 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -315,6 +315,8 @@ struct libc_do_syscall_args
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
+# define HAVE_TIME_VSYSCALL             "__vdso_time"
+# define USE_TIME_VSYSCALL_IFUNC	1
 
 /* Define a macro which expands inline into the wrapper code for a system
    call.  This use is for internal calls that do not need to handle errors
diff --git a/sysdeps/unix/sysv/linux/i386/time.c b/sysdeps/unix/sysv/linux/i386/time.c
deleted file mode 100644
index 440e3e6ab4..0000000000
--- a/sysdeps/unix/sysv/linux/i386/time.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* time -- Get number of seconds since Epoch.  Linux/i386 version.
-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# define time __redirect_time
-#endif
-
-#include <time.h>
-
-#ifdef SHARED
-# undef time
-# define time_type __redirect_time
-
-# undef libc_hidden_def
-# define libc_hidden_def(name)  \
-  __hidden_ver1 (__time_syscall, __GI_time, __time_syscall);
-#endif
-
-#include <sysdeps/unix/sysv/linux/x86/time.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 357d1b5243..084b6525ca 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -24,6 +24,7 @@
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define USE_TIME_VSYSCALL_IFUNC		1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
deleted file mode 100644
index f0537a2307..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* time system call for Linux/PowerPC.
-   Copyright (C) 2013-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# ifndef __powerpc64__
-#  define time __redirect_time
-# else
-#  define __redirect_time time
-# endif
-
-# include <time.h>
-# include <sysdep.h>
-# include <dl-vdso.h>
-# include <libc-vdso.h>
-# include <dl-machine.h>
-
-# ifndef __powerpc64__
-#  undef time
-
-time_t
-__time_vsyscall (time_t *t)
-{
-  return INLINE_VSYSCALL (time, 1, t);
-}
-
-/* __GI_time is defined as hidden and for ppc32 it enables the
-   compiler make a local call (symbol@local) for internal GLIBC usage. It
-   means the PLT won't be used and the ifunc resolver will be called directly.
-   For ppc64 a call to a function in another translation unit might use a
-   different toc pointer thus disallowing direct branchess and making internal
-   ifuncs calls safe.  */
-#  undef libc_hidden_def
-#  define libc_hidden_def(name)					\
-  __hidden_ver1 (__time_vsyscall, __GI_time, __time_vsyscall);
-
-# endif /* !__powerpc64__  */
-
-static time_t
-time_syscall (time_t *t)
-{
-  struct timeval tv;
-  time_t result;
-
-  if (INLINE_VSYSCALL (gettimeofday, 2, &tv, NULL) < 0)
-    result = (time_t) -1;
-  else
-    result = (time_t) tv.tv_sec;
-
-  if (t != NULL)
-    *t = result;
-  return result;
-}
-
-# define INIT_ARCH() \
-  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
-
-/* If the vDSO is not available we fall back to the syscall.  */
-libc_ifunc_hidden (__redirect_time, time,
-		   vdso_time
-		   ? VDSO_IFUNC_RET (vdso_time)
-		   : (void *) time_syscall);
-libc_hidden_def (time)
-
-#else
-
-#include <sysdeps/posix/time.c>
-
-#endif /* !SHARED */
diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c
index 1978f6d817..9176fe6ed7 100644
--- a/sysdeps/unix/sysv/linux/time.c
+++ b/sysdeps/unix/sysv/linux/time.c
@@ -15,27 +15,68 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <stddef.h>
+/* Currently we have 3 possible time implementations, which is also selected
+   in the order:
+
+   1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
+      powerpc).
+   2. Only wire-up __NR_time (usually old kABIs).
+   3. Using internal gettimeofday (which may call a vDSO as well).  */
+
+#define time __redirect_time
 #include <time.h>
+#undef time
+#include <sys/time.h>
 
 #include <sysdep.h>
+#ifdef HAVE_TIME_VSYSCALL
+# define HAVE_VSYSCALL
+#endif
+#include <sysdep-vdso.h>
+#include <libc-vdso.h>
 
-#ifdef __NR_time
-
-time_t
-time (time_t *t)
+static time_t
+time_syscall (time_t *t)
 {
+  time_t res;
+#ifdef __NR_time
   INTERNAL_SYSCALL_DECL (err);
-  time_t res = INTERNAL_SYSCALL (time, err, 1, NULL);
+  res = INTERNAL_VSYSCALL (time, err, 1, NULL);
   /* There cannot be any error.  */
+#else
+  struct timeval tv;
+  /* gettimeofday does not fail with valid 'tv' and null timezone.  */
+  __gettimeofday (&tv, NULL);
+  res = tv.tv_sec;
+#endif
   if (t != NULL)
     *t = res;
   return res;
 }
-libc_hidden_def (time)
 
+#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
+/* Route externals calls direct to vDSO and static and internal calls to
+   fallback implementation (which also might call the vDSO).  */
+# ifdef SHARED
+#  undef INIT_ARCH
+#  define INIT_ARCH() \
+  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
+
+libc_ifunc_redirected (__redirect_time, time,
+		       vdso_time
+		       ? VDSO_IFUNC_RET (vdso_time)
+		       : (void *) time_syscall);
+libc_hidden_def_redir (time_syscall, time)
+#  else
+strong_alias (time_syscall, time)
+#  endif /* SHARED  */
 #else
 
-# include <sysdeps/posix/time.c>
+time_t
+time (time_t *t)
+{
+  return time_syscall (t);
+}
+libc_hidden_def_redir (time, time)
 
 #endif
diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c
deleted file mode 100644
index 60e6d1b7c0..0000000000
--- a/sysdeps/unix/sysv/linux/x86/time.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* time -- Get number of seconds since Epoch.  Linux/x86 version.
-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <time.h>
-
-#ifdef SHARED
-
-#include <dl-vdso.h>
-#include <errno.h>
-#include <sysdep-vdso.h>
-
-static time_t
-__time_syscall (time_t *t)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (time, err, 1, t);
-}
-
-# ifndef time_type
-/* The i386 time.c includes this file with a defined time_type macro.
-   For x86_64 we have to define it to time as the internal symbol is the
-   ifunc'ed one.  */
-#  define time_type time
-# endif
-
-#undef INIT_ARCH
-#define INIT_ARCH()
-
-/* If the vDSO is not available we fall back on the syscall.  */
-libc_ifunc_hidden (time_type, time,
-		   (get_vdso_symbol ("__vdso_time") ?: __time_syscall))
-libc_hidden_def (time)
-
-#else
-
-# include <sysdep.h>
-
-time_t
-time (time_t *t)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (time, err, 1, t);
-}
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 4541c0d492..c64fbd1e26 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -376,6 +376,8 @@
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
+# define HAVE_TIME_VSYSCALL		"__vdso_time"
+# define USE_TIME_VSYSCALL_IFUNC	1
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
 # define SINGLE_THREAD_BY_GLOBAL		1
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 8/8] linux: Consolidate gettimeofday implementation
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2019-09-05 20:56 ` [PATCH v2 7/8] linux: Consolidate " Adhemerval Zanella
@ 2019-09-05 20:56 ` Adhemerval Zanella
  2019-09-11 14:10 ` [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Andreas Schwab
  7 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-05 20:56 UTC (permalink / raw)
  To: libc-alpha

Changes from previous version:

  - Update due powerpc64 fixes.

--

The gettimeofday syscall has currently 3 possible implementations:

  1. Wire-up __NR_gettimeofday with a VDSO implementation accessed
     directly through IFUNC (aarch64, x86, and powerpc*).

  2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc).

  3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze,
     nios, sh4).

This patch consolidates all implementation on Linux generic
sysdeps/unix/sysv/linux/gettimeofday.c.  To simplify the code, some changes
are made:

   * The wire-up with vDSO implementation may route external calls directly
     to vDSO through IFUNC.  To enable it the architecture need to
     explicit define USE_GETTIMEOFDAY_VSYSCALL_IFUNC.

   * Also, powerpc and x86 tries to route internal time usages to
     IFUNC mechanism, which is problematic since powerpc32 and i686 does
     not really support it.  Instead, all internal calls are routed to
     a default internal symbol which in turn calls INTERNAL_VSYSCALL.

   * Static linking also uses the fallback mechanism which calls
     INTERNAL_VSYSCALL, so vDSO is used for this case as well.

The generic implementation issues a syscall as default, calls the
vDSO if the architecture defines HAVE_GETTIMEOFDAY_VSYSCALL, and
route the external calls to iFUNC if the architecture also defines
USE_GETTIMEOFDAY_VSYSCALL_IFUNC.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.

	* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: Remove file.
	* sysdeps/unix/sysv/linux/i386/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Define.
	* sysdeps/unix/sysv/linux/i386/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/gettimeofday.c (gettimeofday): Handle all
	possible Linux implementations (wire-up syscall, vDSO implementation,
	and iFUNC).
        (gettimeofday_syscall): New function.
---
 .../unix/sysv/linux/aarch64/gettimeofday.c    | 58 -------------
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/gettimeofday.c        | 51 +++++++++--
 sysdeps/unix/sysv/linux/i386/gettimeofday.c   | 35 --------
 sysdeps/unix/sysv/linux/i386/sysdep.h         |  1 +
 .../unix/sysv/linux/powerpc/gettimeofday.c    | 84 -------------------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/x86/gettimeofday.c    | 63 --------------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  1 +
 9 files changed, 48 insertions(+), 247 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/gettimeofday.c

diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
deleted file mode 100644
index 9499a11fda..0000000000
--- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Copyright (C) 2018-2019 Free Software Foundation, Inc.
-
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public License as
-   published by the Free Software Foundation; either version 2.1 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* Get the current time of day and timezone information,
-   putting it into *tv and *tz.  If tz is null, *tz is not filled.
-   Returns 0 on success, -1 on errors.  */
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <sysdep-vdso.h>
-
-/* Used as a fallback in the ifunc resolver if VDSO is not available
-   and for libc.so internal __gettimeofday calls.  */
-
-static int
-__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# define INIT_ARCH()
-libc_ifunc_hidden (__gettimeofday, __gettimeofday,
-		   (get_vdso_symbol ("__vdso_gettimeofday")
-		    ?: __gettimeofday_vsyscall))
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index d57f7232e2..526741ed82 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -163,6 +163,7 @@
 # define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
 # define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 
 /* Previously AArch64 used the generic version without the libc_hidden_def
    which lead in a non existent __send symbol in libc.so.  */
diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c
index a74f03825a..833e97ca7d 100644
--- a/sysdeps/unix/sysv/linux/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/gettimeofday.c
@@ -16,24 +16,61 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <sys/time.h>
+/* Currently we have 3 possible gettimeofday implementations, which is also
+   selected in the order:
+
+   1. Wire-up __NR_gettimeofday with a vDSO implementation (currently aarch64,
+      x86, and powerpc).
+
+   2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc).
+
+   3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze,
+      nios, sh4).  */
 
+#define __gettimeofday __redirect___gettimeofday
+#include <sys/time.h>
 #undef __gettimeofday
 
+#include <sysdep.h>
 #ifdef HAVE_GETTIMEOFDAY_VSYSCALL
 # define HAVE_VSYSCALL
 #endif
 #include <sysdep-vdso.h>
+#include <libc-vdso.h>
+
+/* Get the current time of day and timezone information, putting it into *tv
+   and *tz.  If tz is null, *tz is not filled. Returns 0 on success, -1 on
+   errors.  */
+static int
+gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
+{
+  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
+}
+
+#if HAVE_IFUNC && defined USE_GETTIMEOFDAY_VSYSCALL_IFUNC
+/* Route externals calls direct to vDSO and static and internal calls to
+   fallback implementation (which also might call the vDSO).  */
+# ifdef SHARED
+#  undef INIT_ARCH
+#  define INIT_ARCH() \
+  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
+
+libc_ifunc_redirected (__redirect___gettimeofday, __gettimeofday,
+		       vdso_gettimeofday
+		       ? VDSO_IFUNC_RET (vdso_gettimeofday)
+		       : (void *) gettimeofday_syscall);
+libc_hidden_def_redir (gettimeofday_syscall, __gettimeofday)
+#  else
+strong_alias (gettimeofday_syscall, __gettimeofday)
+#  endif /* SHARED  */
+#else
 
-/* Get the current time of day and timezone information,
-   putting it into *tv and *tz.  If tz is null, *tz is not filled.
-   Returns 0 on success, -1 on errors.  */
 int
 __gettimeofday (struct timeval *tv, struct timezone *tz)
 {
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
+  return gettimeofday_syscall (tv, tz);
 }
-libc_hidden_def (__gettimeofday)
+libc_hidden_def_redir (__gettimeofday, __gettimeofday)
+#endif
 weak_alias (__gettimeofday, gettimeofday)
 libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/i386/gettimeofday.c b/sysdeps/unix/sysv/linux/i386/gettimeofday.c
deleted file mode 100644
index 185450ece6..0000000000
--- a/sysdeps/unix/sysv/linux/i386/gettimeofday.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* gettimeofday - get the time.  Linux/i386 version.
-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# define __gettimeofday __redirect___gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-# undef __gettimeofday
-# define __gettimeofday_type __redirect___gettimeofday
-
-# undef libc_hidden_def
-# define libc_hidden_def(name) \
-  __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \
-	       __gettimeofday_syscall);
-#endif
-
-#include <sysdeps/unix/sysv/linux/x86/gettimeofday.c>
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 4f79f25989..076e4393d3 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -315,6 +315,7 @@ struct libc_do_syscall_args
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
+# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 # define HAVE_TIME_VSYSCALL             "__vdso_time"
 # define USE_TIME_VSYSCALL_IFUNC	1
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
deleted file mode 100644
index e046594d40..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (C) 2005-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#if defined SHARED && !defined __powerpc64__
-# define __gettimeofday __redirect___gettimeofday
-#else
-# define __redirect___gettimeofday __gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <libc-vdso.h>
-# include <dl-machine.h>
-
-# ifndef __powerpc64__
-#  undef __gettimeofday
-
-int
-__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-/* __GI___gettimeofday is defined as hidden and for ppc32 it enables the
-   compiler make a local call (symbol@local) for internal GLIBC usage. It
-   means the PLT won't be used and the ifunc resolver will be called directly.
-   For ppc64 a call to a function in another translation unit might use a
-   different toc pointer thus disallowing direct branchess and making internal
-   ifuncs calls safe.  */
-#  undef libc_hidden_def
-#  define libc_hidden_def(name)					\
-  __hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday,	\
-	       __gettimeofday_vsyscall);
-
-# endif /* !__powerpc64__  */
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# define INIT_ARCH() \
-  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
-  
-/* If the vDSO is not available we fall back syscall.  */
-libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
-		   vdso_gettimeofday
-		   ? VDSO_IFUNC_RET (vdso_gettimeofday)
-		   : (void *) __gettimeofday_syscall);
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 084b6525ca..743eb67557 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -26,6 +26,7 @@
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
 #define USE_TIME_VSYSCALL_IFUNC		1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+#define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
 #if defined(__PPC64__) || defined(__powerpc64__)
diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
deleted file mode 100644
index 3ceab633e5..0000000000
--- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* gettimeofday - get the time.  Linux/x86 version.
-   Copyright (C) 2015-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <errno.h>
-# include <sysdep-vdso.h>
-# include <sysdep-vdso.h>
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# ifndef __gettimeofday_type
-/* The i386 gettimeofday.c includes this file with a defined
-   __gettimeofday_type macro.  For x86_64 we have to define it to __gettimeofday
-   as the internal symbol is the ifunc'ed one.  */
-#  define __gettimeofday_type __gettimeofday
-# endif
-
-# define INIT_ARCH()
-
-/* If the vDSO is not available we fall back to syscall.  */
-libc_ifunc_hidden (__gettimeofday_type, __gettimeofday,
-		   (get_vdso_symbol ("__vdso_gettimeofday")
-		    ?: __gettimeofday_syscall));
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index c64fbd1e26..4ea9c4fa31 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -376,6 +376,7 @@
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
+# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 # define HAVE_TIME_VSYSCALL		"__vdso_time"
 # define USE_TIME_VSYSCALL_IFUNC	1
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros
  2019-09-05 20:56 ` [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros Adhemerval Zanella
@ 2019-09-05 22:05   ` cseo
  2019-09-17 14:23     ` Adhemerval Zanella
  0 siblings, 1 reply; 20+ messages in thread
From: cseo @ 2019-09-05 22:05 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On 2019-09-05 17:56, Adhemerval Zanella wrote:
> diff --git a/sysdeps/unix/sysv/linux/libc-vdso.h
> b/sysdeps/unix/sysv/linux/libc-vdso.h
> index f681868137..199ae9a033 100644
> --- a/sysdeps/unix/sysv/linux/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/libc-vdso.h
> @@ -21,6 +21,13 @@
> 
>  #define VDSO_SYMBOL(__name) __vdso_##__name
> 
> +/* Adjust the return IFUNC value from a vDSO symbol accordingly 
> required
> +   architecture ABI.  It is used for powerpc64 elfv1 to create a ODP
> +   entry since kernvel vDSO does not provide it.  */

'required by the', 'ELFv1'

Typo - 'kernel'

The rest LGTM.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW
  2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2019-09-05 20:56 ` [PATCH v2 8/8] linux: Consolidate gettimeofday implementation Adhemerval Zanella
@ 2019-09-11 14:10 ` Andreas Schwab
  2019-09-17 14:22   ` Adhemerval Zanella
  7 siblings, 1 reply; 20+ messages in thread
From: Andreas Schwab @ 2019-09-11 14:10 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Sep 05 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> index a2f4061b58..662d321235 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> @@ -151,6 +151,13 @@
>  
>  #else /* not __ASSEMBLER__ */
>  
> +# ifdef __LP64__
> +#  define VDSO_NAME  "LINUX_2_6_39"

That should be "LINUX_2.6.39", similar for other occurrences.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW
  2019-09-11 14:10 ` [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Andreas Schwab
@ 2019-09-17 14:22   ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-17 14:22 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha



On 11/09/2019 11:10, Andreas Schwab wrote:
> On Sep 05 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> 
>> diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
>> index a2f4061b58..662d321235 100644
>> --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
>> @@ -151,6 +151,13 @@
>>  
>>  #else /* not __ASSEMBLER__ */
>>  
>> +# ifdef __LP64__
>> +#  define VDSO_NAME  "LINUX_2_6_39"
> 
> That should be "LINUX_2.6.39", similar for other occurrences.
> 
> Andreas.
> 

Ack, I fixed the aarch, arm, and mips as well.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 2/8] Refactor vDSO initialization code
  2019-09-05 20:56 ` [PATCH v2 2/8] Refactor vDSO initialization code Adhemerval Zanella
@ 2019-09-17 14:23   ` Adhemerval Zanella
  2019-09-24 11:41   ` [PATCH] Fix vDSO initialization on arm and mips Andreas Schwab
  1 sibling, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-17 14:23 UTC (permalink / raw)
  To: libc-alpha

I will commit this shortly if no one opposes, after I tested on the affected
architectures.

On 05/09/2019 17:56, Adhemerval Zanella wrote:
> Linux vDSO initialization code the internal function pointers require a lot
> of duplicated boilerplate over different architectures.  This patch aims to
> simplify not only the code but the required definition to enable a vDSO
> symbol.
> 
> The changes are:
> 
>   1. Consolidate all init-first.c on only one implementation and enable
>      the symbol based on HAVE_*_VSYSCALL existence.
> 
>   2. Set the HAVE_*_VSYSCALL to the architecture expected names string.
> 
>   3. Add a new internal implementation, get_vdso_mangle_symbol, which
>      returns a mangled function pointer.
> 
> Currently the clock_gettime, clock_getres, gettimeofday, getcpu, and time
> are handled in an arch-independent way, powerpc still uses some arch-specific
> vDSO symbol handled in a specific init-first implementation.
> 
> Checked on aarch64-linux-gnu, arm-linux-gnueabihf, i386-linux-gnu,
> mips64-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gnu, sparc64-linux-gnu,
> and x86_64-linux-gnu.
> 
> 	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address,
> 	is_sigtramp_address_rt): Use HAVE_SIGTRAMP_{RT}32 instead of SHARED.
> 	* sysdeps/powerpc/powerpc64/backtrace.c (is_sigtramp_address):
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove file.
> 	* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
> 	* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
> 	* sysdeps/unix/sysv/linux/mips/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
> 	* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
> 	* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
> 	* sysdeps/unix/sysv/linux/s390/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
> 	* sysdeps/unix/sysv/linux/aarch64/sysdep.h
> 	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
> 	HAVE_GETTIMEOFDAY_VSYSCALL): Define value based on kernel exported
> 	name.
> 	* sysdeps/unix/sysv/linux/arm/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
> 	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
> 	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/mips/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
> 	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
> 	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
> 	HAVE_GETCPU_VSYSCALL, HAVE_TIME_VSYSCALL, HAVE_GET_TBFREQ,
> 	HAVE_SIGTRAMP_RT64, HAVE_SIGTRAMP_32, HAVE_SIGTRAMP_RT32): Likewise.
> 	* sysdeps/unix/sysv/linux/riscv/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
> 	HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
> 	HAVE_GETCPU_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/s390/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
> 	HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
> 	HAVE_GETCPU_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
> 	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
> 	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
> 	HAVE_GETCPU_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/dl-vdso.h (VDSO_NAME, VDSO_HASH): Define to
> 	invalid names if architecture does not define them.
> 	(get_vdso_mangle_symbol): New symbol.
> 	* sysdeps/unix/sysv/linux/init-first.c: New file.
> 	* sysdeps/unix/sysv/linux/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/init-first.c (gettimeofday,
> 	clock_gettime, clock_getres, getcpu, time): Remove declaration.
> 	(__libc_vdso_platform_setup_arch): Likewise and use
> 	get_vdso_mangle_symbol to setup vDSO symbols.
> 	(sigtramp_rt64, sigtramp32, sigtramp_rt32, get_tbfreq): Add
> 	attribute_hidden.
> 	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/sysdep-vdso.h (VDSO_SYMBOL): Remove
> 	definition.
> ---
>  sysdeps/powerpc/powerpc32/backtrace.c         |  4 +-
>  sysdeps/powerpc/powerpc64/backtrace.c         |  2 +-
>  sysdeps/unix/sysv/linux/aarch64/init-first.c  | 44 ----------
>  sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  6 +-
>  sysdeps/unix/sysv/linux/arm/init-first.c      | 41 ----------
>  sysdeps/unix/sysv/linux/arm/libc-vdso.h       | 29 -------
>  sysdeps/unix/sysv/linux/arm/sysdep.h          |  4 +-
>  sysdeps/unix/sysv/linux/dl-vdso.h             | 21 ++++-
>  sysdeps/unix/sysv/linux/i386/init-first.c     | 46 -----------
>  sysdeps/unix/sysv/linux/i386/sysdep.h         |  4 +-
>  sysdeps/unix/sysv/linux/init-first.c          | 80 +++++++++++++++++++
>  .../unix/sysv/linux/{aarch64 => }/libc-vdso.h | 18 ++++-
>  sysdeps/unix/sysv/linux/mips/init-first.c     | 40 ----------
>  sysdeps/unix/sysv/linux/mips/libc-vdso.h      | 29 -------
>  sysdeps/unix/sysv/linux/mips/sysdep.h         |  4 +-
>  sysdeps/unix/sysv/linux/powerpc/init-first.c  | 51 +++---------
>  sysdeps/unix/sysv/linux/powerpc/libc-vdso.h   | 12 +--
>  sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 14 +++-
>  sysdeps/unix/sysv/linux/riscv/init-first.c    | 54 -------------
>  sysdeps/unix/sysv/linux/riscv/libc-vdso.h     | 34 --------
>  sysdeps/unix/sysv/linux/riscv/sysdep.h        |  8 +-
>  sysdeps/unix/sysv/linux/s390/init-first.c     | 56 -------------
>  sysdeps/unix/sysv/linux/s390/libc-vdso.h      | 35 --------
>  sysdeps/unix/sysv/linux/s390/sysdep.h         |  8 +-
>  sysdeps/unix/sysv/linux/sparc/init-first.c    | 42 ----------
>  sysdeps/unix/sysv/linux/sparc/libc-vdso.h     | 29 -------
>  sysdeps/unix/sysv/linux/sparc/sysdep.h        |  4 +-
>  sysdeps/unix/sysv/linux/sysdep-vdso.h         |  2 +-
>  sysdeps/unix/sysv/linux/x86/libc-vdso.h       | 33 --------
>  sysdeps/unix/sysv/linux/x86_64/init-first.c   | 48 -----------
>  sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  6 +-
>  31 files changed, 164 insertions(+), 644 deletions(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/aarch64/init-first.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/init-first.c
>  delete mode 100644 sysdeps/unix/sysv/linux/arm/libc-vdso.h
>  delete mode 100644 sysdeps/unix/sysv/linux/i386/init-first.c
>  create mode 100644 sysdeps/unix/sysv/linux/init-first.c
>  rename sysdeps/unix/sysv/linux/{aarch64 => }/libc-vdso.h (70%)
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/init-first.c
>  delete mode 100644 sysdeps/unix/sysv/linux/mips/libc-vdso.h
>  delete mode 100644 sysdeps/unix/sysv/linux/riscv/init-first.c
>  delete mode 100644 sysdeps/unix/sysv/linux/riscv/libc-vdso.h
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/init-first.c
>  delete mode 100644 sysdeps/unix/sysv/linux/s390/libc-vdso.h
>  delete mode 100644 sysdeps/unix/sysv/linux/sparc/init-first.c
>  delete mode 100644 sysdeps/unix/sysv/linux/sparc/libc-vdso.h
>  delete mode 100644 sysdeps/unix/sysv/linux/x86/libc-vdso.h
>  delete mode 100644 sysdeps/unix/sysv/linux/x86_64/init-first.c
> 
> diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c
> index 857a8aad7b..2978632017 100644
> --- a/sysdeps/powerpc/powerpc32/backtrace.c
> +++ b/sysdeps/powerpc/powerpc32/backtrace.c
> @@ -54,7 +54,7 @@ struct signal_frame_32 {
>  static inline int
>  is_sigtramp_address (void *nip)
>  {
> -#ifdef SHARED
> +#ifdef HAVE_SIGTRAMP_RT32
>    if (nip == VDSO_SYMBOL (sigtramp32))
>      return 1;
>  #endif
> @@ -71,7 +71,7 @@ struct rt_signal_frame_32 {
>  static inline int
>  is_sigtramp_address_rt (void * nip)
>  {
> -#ifdef SHARED
> +#ifdef HAVE_SIGTRAMP_32
>    if (nip == VDSO_SYMBOL (sigtramp_rt32))
>      return 1;
>  #endif
> diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c
> index 7a167838d9..0fa7e9c403 100644
> --- a/sysdeps/powerpc/powerpc64/backtrace.c
> +++ b/sysdeps/powerpc/powerpc64/backtrace.c
> @@ -57,7 +57,7 @@ struct signal_frame_64 {
>  static inline int
>  is_sigtramp_address (void *nip)
>  {
> -#ifdef SHARED
> +#ifdef HAVE_SIGTRAMP_RT64
>    if (nip == VDSO_SYMBOL (sigtramp_rt64))
>      return 1;
>  #endif
> diff --git a/sysdeps/unix/sysv/linux/aarch64/init-first.c b/sysdeps/unix/sysv/linux/aarch64/init-first.c
> deleted file mode 100644
> index c3c27cfd4b..0000000000
> --- a/sysdeps/unix/sysv/linux/aarch64/init-first.c
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/* Copyright (C) 2007-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#include <dl-vdso.h>
> -#include <libc-vdso.h>
> -
> -int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
> -int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
> -
> -static inline void
> -_libc_vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__kernel_gettimeofday");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL(gettimeofday) = p;
> -
> -  p = get_vdso_symbol ("__kernel_clock_gettime");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL(clock_gettime) = p;
> -
> -  p = get_vdso_symbol ("__kernel_clock_getres");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL(clock_getres) = p;
> -}
> -
> -#define VDSO_SETUP _libc_vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> index 662d321235..d57f7232e2 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> @@ -160,9 +160,9 @@
>  # endif
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -# define HAVE_CLOCK_GETRES_VSYSCALL	1
> -# define HAVE_CLOCK_GETTIME_VSYSCALL	1
> -# define HAVE_GETTIMEOFDAY_VSYSCALL	1
> +# define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
> +# define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
> +# define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
>  
>  /* Previously AArch64 used the generic version without the libc_hidden_def
>     which lead in a non existent __send symbol in libc.so.  */
> diff --git a/sysdeps/unix/sysv/linux/arm/init-first.c b/sysdeps/unix/sysv/linux/arm/init-first.c
> deleted file mode 100644
> index 2852ab135c..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/init-first.c
> +++ /dev/null
> @@ -1,41 +0,0 @@
> -/* Initialization code run first thing by the ELF startup code.  Linux/ARM.
> -   Copyright (C) 2015-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#include <dl-vdso.h>
> -#include <libc-vdso.h>
> -#include <sysdep-vdso.h>
> -
> -int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
> -int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -
> -static inline void
> -_libc_vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__vdso_gettimeofday");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (gettimeofday) = p;
> -
> -  p = get_vdso_symbol ("__vdso_clock_gettime");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_gettime) = p;
> -}
> -
> -#define VDSO_SETUP _libc_vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/arm/libc-vdso.h b/sysdeps/unix/sysv/linux/arm/libc-vdso.h
> deleted file mode 100644
> index 8702165c6b..0000000000
> --- a/sysdeps/unix/sysv/linux/arm/libc-vdso.h
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* VDSO function pointer declarations.  Linux/ARM.
> -   Copyright (C) 2015-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#ifndef _LIBC_VDSO_H
> -#define _LIBC_VDSO_H
> -
> -#include <sysdep-vdso.h>
> -
> -extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -   attribute_hidden;
> -extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -
> -#endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
> index 467ccf2631..634aa2bc6b 100644
> --- a/sysdeps/unix/sysv/linux/arm/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
> @@ -392,8 +392,8 @@ __local_syscall_error:						\
>  #define VDSO_HASH  61765110
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -#define HAVE_CLOCK_GETTIME_VSYSCALL	1
> -#define HAVE_GETTIMEOFDAY_VSYSCALL	1
> +#define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_gettimeofday"
> +#define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_clock_gettime"
>  
>  #define LOAD_ARGS_0()
>  #define ASM_ARGS_0
> diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h
> index bab3779615..dcf065ef23 100644
> --- a/sysdeps/unix/sysv/linux/dl-vdso.h
> +++ b/sysdeps/unix/sysv/linux/dl-vdso.h
> @@ -19,16 +19,25 @@
>  #ifndef _DL_VDSO_H
>  #define _DL_VDSO_H	1
>  
> -#include <assert.h>
>  #include <ldsodefs.h>
>  #include <dl-hash.h>
> -#include <libc-vdso.h>
>  
>  /* Functions for resolving symbols in the VDSO link map.  */
>  extern void *_dl_vdso_vsym (const char *name,
>  			    const struct r_found_version *version)
>        attribute_hidden;
>  
> +/* If the architecture support vDSO it should define which is the expected
> +   kernel version and hash value through both VDSO_NAME and VDSO_HASH
> +   (usually defined at architecture sysdep.h).  */
> +
> +#ifndef VDSO_NAME
> +# define VDSO_NAME "LINUX_0.0"
> +#endif
> +#ifndef VDSO_HASH
> +# define VDSO_HASH 0
> +#endif
> +
>  static inline void *
>  get_vdso_symbol (const char *symbol)
>  {
> @@ -36,4 +45,12 @@ get_vdso_symbol (const char *symbol)
>    return _dl_vdso_vsym (symbol, &rfv);
>  }
>  
> +static inline void *
> +get_vdso_mangle_symbol (const char *symbol)
> +{
> +  void *vdsop = get_vdso_symbol (symbol);
> +  PTR_MANGLE (vdsop);
> +  return vdsop;
> +}
> +
>  #endif /* dl-vdso.h */
> diff --git a/sysdeps/unix/sysv/linux/i386/init-first.c b/sysdeps/unix/sysv/linux/i386/init-first.c
> deleted file mode 100644
> index 9c03f87b67..0000000000
> --- a/sysdeps/unix/sysv/linux/i386/init-first.c
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/* Initialization code run first thing by the ELF startup code.  Linux/i386.
> -   Copyright (C) 2015-2019 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#include <time.h>
> -#include <sysdep.h>
> -#include <dl-vdso.h>
> -#include <sysdep-vdso.h>
> -
> -long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
> -  attribute_hidden;
> -
> -static long int
> -clock_gettime_syscall (clockid_t id, struct timespec *tp)
> -{
> -  INTERNAL_SYSCALL_DECL (err);
> -  return INTERNAL_SYSCALL (clock_gettime, err, 2, id, tp);
> -}
> -
> -static inline void
> -__vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__vdso_clock_gettime");
> -  if (p == NULL)
> -    p = clock_gettime_syscall;
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_gettime) = p;
> -}
> -
> -#define VDSO_SETUP __vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
> index 278028f52e..e793fdc936 100644
> --- a/sysdeps/unix/sysv/linux/i386/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
> @@ -313,8 +313,8 @@ struct libc_do_syscall_args
>  # define VDSO_HASH  61765110
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -# define HAVE_CLOCK_GETTIME_VSYSCALL    1
> -# define HAVE_GETTIMEOFDAY_VSYSCALL     1
> +# define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
> +# define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
>  
>  /* Define a macro which expands inline into the wrapper code for a system
>     call.  This use is for internal calls that do not need to handle errors
> diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
> new file mode 100644
> index 0000000000..d90ca820be
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/init-first.c
> @@ -0,0 +1,80 @@
> +/* vDSO internal symbols.  Linux generic version.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public License as
> +   published by the Free Software Foundation; either version 2.1 of the
> +   License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <dl-vdso.h>
> +#include <libc-vdso.h>
> +
> +/* vDSO symbol used on clock_gettime implementation.  */
> +#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
> +int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
> +  attribute_hidden;
> +#endif
> +/* vDSO symbol used on clock_getres implementation.  */
> +#ifdef HAVE_CLOCK_GETRES_VSYSCALL
> +int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *)
> +  attribute_hidden;
> +#endif
> +/* vDSO symbol used on gettimeofday implementation.  */
> +#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
> +int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
> +  attribute_hidden;
> +#endif
> +/* vDSO symbol used on GNU extension getcpu implementation.  */
> +#ifdef HAVE_GETCPU_VSYSCALL
> +long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
> +   attribute_hidden;
> +#endif
> +/* vDSO symbol used on time implementation.  */
> +#ifdef HAVE_TIME_VSYSCALL
> +time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden;
> +#endif
> +
> +static inline void
> +__libc_vdso_platform_setup (void)
> +{
> +#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
> +  VDSO_SYMBOL(clock_gettime)
> +    = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL);
> +#endif
> +
> +#ifdef HAVE_CLOCK_GETRES_VSYSCALL
> +  VDSO_SYMBOL(clock_getres)
> +    = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL);
> +#endif
> +
> +#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
> +  VDSO_SYMBOL(gettimeofday)
> +    = get_vdso_mangle_symbol (HAVE_GETTIMEOFDAY_VSYSCALL);
> +#endif
> +
> +#ifdef HAVE_GETCPU_VSYSCALL
> +  VDSO_SYMBOL(getcpu) = get_vdso_mangle_symbol (HAVE_GETCPU_VSYSCALL);
> +#endif
> +
> +#ifdef HAVE_TIME_VSYSCALL
> +  VDSO_SYMBOL(time) = get_vdso_mangle_symbol (HAVE_TIME_VSYSCALL);
> +#endif
> +
> +#ifdef VDSO_SETUP_ARCH
> +  VDSO_SETUP_ARCH ();
> +#endif
> +}
> +
> +#define VDSO_SETUP __libc_vdso_platform_setup
> +
> +#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc-vdso.h b/sysdeps/unix/sysv/linux/libc-vdso.h
> similarity index 70%
> rename from sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
> rename to sysdeps/unix/sysv/linux/libc-vdso.h
> index 3fcbaa9fce..f681868137 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/libc-vdso.h
> @@ -19,12 +19,22 @@
>  #ifndef _LIBC_VDSO_H
>  #define _LIBC_VDSO_H
>  
> -#include <sysdep.h>
> -#include <sysdep-vdso.h>
> +#define VDSO_SYMBOL(__name) __vdso_##__name
>  
> -extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -   attribute_hidden;
> +#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
>  extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> +#endif
> +#ifdef HAVE_CLOCK_GETRES_VSYSCALL
>  extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
> +#endif
> +#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
> +extern int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *);
> +#endif
> +#ifdef HAVE_GETCPU_VSYSCALL
> +extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *);
> +#endif
> +#ifdef HAVE_TIME_VSYSCALL
> +extern time_t (*VDSO_SYMBOL(time)) (time_t *);
> +#endif
>  
>  #endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/mips/init-first.c b/sysdeps/unix/sysv/linux/mips/init-first.c
> deleted file mode 100644
> index 2a43bdc8b0..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/init-first.c
> +++ /dev/null
> @@ -1,40 +0,0 @@
> -/* Initialization code run first thing by the ELF startup code.
> -   Copyright (C) 2016-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#include <dl-vdso.h>
> -#include <libc-vdso.h>
> -
> -int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
> -int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -
> -static inline void
> -_libc_vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__vdso_gettimeofday");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (gettimeofday) = p;
> -
> -  p = get_vdso_symbol ("__vdso_clock_gettime");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_gettime) = p;
> -}
> -
> -#define VDSO_SETUP _libc_vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/mips/libc-vdso.h b/sysdeps/unix/sysv/linux/mips/libc-vdso.h
> deleted file mode 100644
> index 344ea2d750..0000000000
> --- a/sysdeps/unix/sysv/linux/mips/libc-vdso.h
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* VDSO function pointer declarations.
> -   Copyright (C) 2016-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#ifndef _LIBC_VDSO_H
> -#define _LIBC_VDSO_H
> -
> -#include <sysdep-vdso.h>
> -
> -extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -   attribute_hidden;
> -extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -
> -#endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
> index cabc590961..58a7244581 100644
> --- a/sysdeps/unix/sysv/linux/mips/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
> @@ -20,5 +20,5 @@
>  #define VDSO_HASH  61765110
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -#define HAVE_CLOCK_GETTIME_VSYSCALL     1
> -#define HAVE_GETTIMEOFDAY_VSYSCALL      1
> +#define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
> +#define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
> diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c
> index 0d46563ce3..6e72d9ca84 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/init-first.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/init-first.c
> @@ -19,47 +19,18 @@
>  #include <dl-vdso.h>
>  #include <libc-vdso.h>
>  
> -int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -  attribute_hidden;
> -int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
> -unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
> -int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
> -time_t (*VDSO_SYMBOL(time)) (time_t *);
> -
> +unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void) attribute_hidden;
>  #if defined(__PPC64__) || defined(__powerpc64__)
> -void *VDSO_SYMBOL(sigtramp_rt64);
> +void *VDSO_SYMBOL(sigtramp_rt64) attribute_hidden;
>  #else
> -void *VDSO_SYMBOL(sigtramp32);
> -void *VDSO_SYMBOL(sigtramp_rt32);
> +void *VDSO_SYMBOL(sigtramp32) attribute_hidden;
> +void *VDSO_SYMBOL(sigtramp_rt32) attribute_hidden;
>  #endif
>  
>  static inline void
> -_libc_vdso_platform_setup (void)
> +__libc_vdso_platform_setup_arch (void)
>  {
> -  void *p = get_vdso_symbol ("__kernel_gettimeofday");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (gettimeofday) = p;
> -
> -  p = get_vdso_symbol ("__kernel_clock_gettime");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_gettime) = p;
> -
> -  p = get_vdso_symbol ("__kernel_clock_getres");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_getres) = p;
> -
> -  p = get_vdso_symbol ("__kernel_get_tbfreq");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (get_tbfreq) = p;
> -
> -  p = get_vdso_symbol ("__kernel_getcpu");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (getcpu) = p;
> -
> -  p = get_vdso_symbol ("__kernel_time");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (time) = p;
> +  VDSO_SYMBOL (get_tbfreq) = get_vdso_mangle_symbol (HAVE_GET_TBFREQ);
>  
>    /* PPC64 uses only one signal trampoline symbol, while PPC32 will use
>       two depending if SA_SIGINFO is used (__kernel_sigtramp_rt32) or not
> @@ -67,13 +38,13 @@ _libc_vdso_platform_setup (void)
>       There is no need to pointer mangle these symbol because they will
>       used only for pointer comparison.  */
>  #if defined(__PPC64__) || defined(__powerpc64__)
> -  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol ("__kernel_sigtramp_rt64");
> +  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol (HAVE_SIGTRAMP_RT64);
>  #else
> -  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol ("__kernel_sigtramp32");
> -  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol ("__kernel_sigtramp_rt32");
> +  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol (HAVE_SIGTRAMP_32);
> +  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol (HAVE_SIGTRAMP_RT32);
>  #endif
>  }
>  
> -#define VDSO_SETUP _libc_vdso_platform_setup
> +#define VDSO_SETUP_ARCH __libc_vdso_platform_setup_arch
>  
> -#include <csu/init-first.c>
> +#include <sysdeps/unix/sysv/linux/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
> index f8184061c0..47e925493b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
> @@ -17,20 +17,14 @@
>     <http://www.gnu.org/licenses/>.  */
>  
>  
> -#ifndef _LIBC_VDSO_H
> -#define _LIBC_VDSO_H
> +#ifndef _LIBC_POWERPC_VDSO_H
> +#define _LIBC_POWERPC_VDSO_H
>  
>  #include <sysdep.h>
>  #include <sysdep-vdso.h>
> +#include_next <libc-vdso.h>
>  
> -extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -  attribute_hidden;
> -extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
>  extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
> -extern int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
> -extern time_t (*VDSO_SYMBOL(time)) (time_t *);
> -
>  #if defined(__PPC64__) || defined(__powerpc64__)
>  extern void *VDSO_SYMBOL(sigtramp_rt64);
>  #else
> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> index 5b411d0e8e..20167615c8 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> @@ -20,7 +20,15 @@
>  #define VDSO_HASH  123718565
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -#define HAVE_CLOCK_GETRES_VSYSCALL	1
> -#define HAVE_CLOCK_GETTIME_VSYSCALL	1
> -#define HAVE_GETCPU_VSYSCALL		1
> +#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
> +#define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
> +#define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
> +#define HAVE_TIME_VSYSCALL		"__kernel_time"
> +#define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
>  
> +#if defined(__PPC64__) || defined(__powerpc64__)
> +# define HAVE_SIGTRAMP_RT64		"__kernel_sigtramp_rt64"
> +#else
> +# define HAVE_SIGTRAMP_32		"__kernel_sigtramp32"
> +# define HAVE_SIGTRAMP_RT32		"__kernel_sigtramp_rt32"
> +#endif
> diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
> deleted file mode 100644
> index f3d243a192..0000000000
> --- a/sysdeps/unix/sysv/linux/riscv/init-first.c
> +++ /dev/null
> @@ -1,54 +0,0 @@
> -/* RISC-V VDSO initialization
> -   Copyright (C) 2017-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#include <dl-vdso.h>
> -#include <libc-vdso.h>
> -
> -long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
> -    attribute_hidden;
> -long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
> -    attribute_hidden;
> -long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
> -    attribute_hidden;
> -long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
> -    attribute_hidden;
> -
> -static inline void
> -_libc_vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__vdso_getcpu");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (getcpu) = p;
> -
> -  p = get_vdso_symbol ("__vdso_gettimeofday");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (gettimeofday) = p;
> -
> -  p = get_vdso_symbol ("__vdso_clock_gettime");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_gettime) = p;
> -
> -  p = get_vdso_symbol ("__vdso_clock_getres");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_getres) = p;
> -}
> -
> -#define VDSO_SETUP _libc_vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
> deleted file mode 100644
> index 2373292ab9..0000000000
> --- a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -/* RISC-V VDSO function declarations
> -   Copyright (C) 2017-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#ifndef _LIBC_VDSO_H
> -#define _LIBC_VDSO_H
> -
> -#include <sysdep-vdso.h>
> -
> -extern long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
> -    attribute_hidden;
> -extern long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
> -    attribute_hidden;
> -extern long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
> -    attribute_hidden;
> -extern long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
> -    attribute_hidden;
> -
> -#endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> index 5de773744c..22835aa12f 100644
> --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> @@ -125,10 +125,10 @@
>  # define VDSO_HASH  182943605
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -# define HAVE_CLOCK_GETRES_VSYSCALL	1
> -# define HAVE_CLOCK_GETTIME_VSYSCALL	1
> -# define HAVE_GETTIMEOFDAY_VSYSCALL	1
> -# define HAVE_GETCPU_VSYSCALL		1
> +# define HAVE_CLOCK_GETRES_VSYSCALL	"__vdso_clock_getres"
> +# define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
> +# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
> +# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
>  
>  /* Define a macro which expands into the inline wrapper code for a system
>     call.  */
> diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
> deleted file mode 100644
> index 3e36270eac..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/init-first.c
> +++ /dev/null
> @@ -1,56 +0,0 @@
> -/* Initialization code run first thing by the ELF startup code.  Linux/s390.
> -   Copyright (C) 2008-2019 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#include <dl-vdso.h>
> -#include <libc-vdso.h>
> -
> -long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -   attribute_hidden;
> -
> -long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
> -  __attribute__ ((nocommon));
> -
> -long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *)
> -  __attribute__ ((nocommon));
> -
> -long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
> -   attribute_hidden;
> -
> -static inline void
> -_libc_vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__kernel_gettimeofday");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (gettimeofday) = p;
> -
> -  p = get_vdso_symbol ("__kernel_clock_gettime");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_gettime) = p;
> -
> -  p = get_vdso_symbol ("__kernel_clock_getres");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_getres) = p;
> -
> -  p = get_vdso_symbol ("__kernel_getcpu");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (getcpu) = p;
> -}
> -
> -#define VDSO_SETUP _libc_vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/s390/libc-vdso.h b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
> deleted file mode 100644
> index cc97601383..0000000000
> --- a/sysdeps/unix/sysv/linux/s390/libc-vdso.h
> +++ /dev/null
> @@ -1,35 +0,0 @@
> -/* Resolve function pointers to VDSO functions.
> -   Copyright (C) 2008-2019 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -
> -#ifndef _LIBC_VDSO_H
> -#define _LIBC_VDSO_H
> -
> -#include <sysdep-vdso.h>
> -
> -extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -   attribute_hidden;
> -
> -extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -
> -extern long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
> -
> -extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
> -   attribute_hidden;
> -
> -#endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
> index eefbd8f007..386efb1896 100644
> --- a/sysdeps/unix/sysv/linux/s390/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
> @@ -20,8 +20,8 @@
>  #define VDSO_HASH  123718585
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -#define HAVE_CLOCK_GETRES_VSYSCALL	1
> -#define HAVE_CLOCK_GETTIME_VSYSCALL	1
> -#define HAVE_GETTIMEOFDAY_VSYSCALL	1
> -#define HAVE_GETCPU_VSYSCALL		1
> +#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
> +#define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
> +#define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
> +#define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
>  
> diff --git a/sysdeps/unix/sysv/linux/sparc/init-first.c b/sysdeps/unix/sysv/linux/sparc/init-first.c
> deleted file mode 100644
> index bdaa78fd32..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/init-first.c
> +++ /dev/null
> @@ -1,42 +0,0 @@
> -/* SPARC VDSO initialization
> -   Copyright (C) 2018-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public License as
> -   published by the Free Software Foundation; either version 2.1 of the
> -   License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#include <dl-vdso.h>
> -#include <libc-vdso.h>
> -
> -long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
> -    attribute_hidden;
> -long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
> -    attribute_hidden;
> -
> -static inline void
> -_libc_vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__vdso_gettimeofday");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (gettimeofday) = p;
> -
> -  p = get_vdso_symbol ("__vdso_clock_gettime");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL (clock_gettime) = p;
> -}
> -
> -#define VDSO_SETUP _libc_vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h b/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
> deleted file mode 100644
> index d20afcdf04..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
> +++ /dev/null
> @@ -1,29 +0,0 @@
> -/* VDSO function pointer declarations.
> -   Copyright (C) 2018-2019 Free Software Foundation, Inc.
> -
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library.  If not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#ifndef _LIBC_VDSO_H
> -#define _LIBC_VDSO_H
> -
> -#include <sysdep-vdso.h>
> -
> -extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> -   attribute_hidden;
> -extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
> -
> -#endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
> index 3bfb1fc60e..925b57082d 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
> @@ -45,8 +45,8 @@
>  # define VDSO_HASH  61765110
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -# define HAVE_CLOCK_GETTIME_VSYSCALL	1
> -# define HAVE_GETTIMEOFDAY_VSYSCALL	1
> +# define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
> +# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
>  
>  #undef INLINE_SYSCALL
>  #define INLINE_SYSCALL(name, nr, args...) 				\
> diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
> index 5fec208380..3da5417fff 100644
> --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
> +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
> @@ -19,7 +19,7 @@
>  #ifndef SYSDEP_VDSO_LINUX_H
>  # define SYSDEP_VDSO_LINUX_H
>  
> -#define VDSO_SYMBOL(__name) __vdso_##__name
> +#include <dl-vdso.h>
>  
>  #ifndef INTERNAL_VSYSCALL_CALL
>  # define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		      \
> diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> deleted file mode 100644
> index c9aa1c8a72..0000000000
> --- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> +++ /dev/null
> @@ -1,33 +0,0 @@
> -/* Resolve function pointers to VDSO functions.
> -   Copyright (C) 2005-2019 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#ifndef _LIBC_VDSO_H
> -#define _LIBC_VDSO_H
> -
> -#include <time.h>
> -#include <sys/time.h>
> -
> -#include <sysdep-vdso.h>
> -
> -extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
> -  attribute_hidden;
> -
> -extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
> -  attribute_hidden;
> -
> -#endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c
> deleted file mode 100644
> index aede1c858d..0000000000
> --- a/sysdeps/unix/sysv/linux/x86_64/init-first.c
> +++ /dev/null
> @@ -1,48 +0,0 @@
> -/* Initialization code run first thing by the ELF startup code.  Linux/x86-64.
> -   Copyright (C) 2007-2019 Free Software Foundation, Inc.
> -   This file is part of the GNU C Library.
> -
> -   The GNU C Library is free software; you can redistribute it and/or
> -   modify it under the terms of the GNU Lesser General Public
> -   License as published by the Free Software Foundation; either
> -   version 2.1 of the License, or (at your option) any later version.
> -
> -   The GNU C Library is distributed in the hope that it will be useful,
> -   but WITHOUT ANY WARRANTY; without even the implied warranty of
> -   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> -   Lesser General Public License for more details.
> -
> -   You should have received a copy of the GNU Lesser General Public
> -   License along with the GNU C Library; if not, see
> -   <http://www.gnu.org/licenses/>.  */
> -
> -#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;
> -long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
> -  attribute_hidden;
> -
> -extern __typeof (clock_gettime) __syscall_clock_gettime attribute_hidden;
> -
> -
> -static inline void
> -__vdso_platform_setup (void)
> -{
> -  void *p = get_vdso_symbol ("__vdso_clock_gettime");
> -  if (p == NULL)
> -    p = __syscall_clock_gettime;
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL(clock_gettime) = p;
> -
> -  p = get_vdso_symbol ("__vdso_getcpu");
> -  PTR_MANGLE (p);
> -  VDSO_SYMBOL(getcpu) = p;
> -}
> -
> -#define VDSO_SETUP __vdso_platform_setup
> -
> -#include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> index 197329f4dc..4541c0d492 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> @@ -374,9 +374,9 @@
>  # define VDSO_HASH  61765110
>  
>  /* List of system calls which are supported as vsyscalls.  */
> -# define HAVE_CLOCK_GETTIME_VSYSCALL    1
> -# define HAVE_GETTIMEOFDAY_VSYSCALL     1
> -# define HAVE_GETCPU_VSYSCALL		1
> +# define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
> +# define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
> +# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
>  
>  # define SINGLE_THREAD_BY_GLOBAL		1
>  
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros
  2019-09-05 22:05   ` cseo
@ 2019-09-17 14:23     ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-17 14:23 UTC (permalink / raw)
  To: cseo; +Cc: libc-alpha

Ack. I will commit this shortly if no one opposes, after I tested on the affected
architectures.

On 05/09/2019 19:05, cseo wrote:
> On 2019-09-05 17:56, Adhemerval Zanella wrote:
>> diff --git a/sysdeps/unix/sysv/linux/libc-vdso.h
>> b/sysdeps/unix/sysv/linux/libc-vdso.h
>> index f681868137..199ae9a033 100644
>> --- a/sysdeps/unix/sysv/linux/libc-vdso.h
>> +++ b/sysdeps/unix/sysv/linux/libc-vdso.h
>> @@ -21,6 +21,13 @@
>>
>>  #define VDSO_SYMBOL(__name) __vdso_##__name
>>
>> +/* Adjust the return IFUNC value from a vDSO symbol accordingly required
>> +   architecture ABI.  It is used for powerpc64 elfv1 to create a ODP
>> +   entry since kernvel vDSO does not provide it.  */
> 
> 'required by the', 'ELFv1'
> 
> Typo - 'kernel'
> 
> The rest LGTM.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 5/8] mips: Consolidate INTERNAL_VSYSCALL_CALL
  2019-09-05 20:56 ` [PATCH v2 5/8] mips: Consolidate INTERNAL_VSYSCALL_CALL Adhemerval Zanella
@ 2019-09-17 14:24   ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-17 14:24 UTC (permalink / raw)
  To: libc-alpha

I will commit this shortly if no one opposes, after I tested on the affected
architectures.

On 05/09/2019 17:56, Adhemerval Zanella wrote:
> This patch consolidates the mips, mips64, and mips64-n32
> INTERNAL_VSYSCALL_CALL on a single implementation.
> 
> No semantic changes. I checked against a build for mips-linux-gnu,
> mips64-linux-gnu, and mips64-n32-linux-gnu.
> 
> 	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> 	(INTERNAL_VSYSCALL_CALL): Remove.
> 	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> 	(INTERNAL_VSYSCALL_CALL): Likewise.
> 	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> 	(INTERNAL_VSYSCALL_CALL): Likewise.
> 	* sysdeps/unix/sysv/linux/mips/sysdep.h (INTERNAL_VSYSCALL_CALL):
> 	New macro.
> ---
>  sysdeps/unix/sysv/linux/mips/mips32/sysdep.h     | 12 ------------
>  sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h | 12 ------------
>  sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h | 12 ------------
>  sysdeps/unix/sysv/linux/mips/sysdep.h            | 16 ++++++++++++++++
>  4 files changed, 16 insertions(+), 36 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> index ebe397b701..bfcb916f15 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> @@ -349,18 +349,6 @@ libc_hidden_proto (__mips_syscall7, nomips16)
>  #define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
>  	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
>  
> -/* Standard MIPS syscalls have an error flag, and return a positive errno
> -   when the error flag is set. Emulate this behaviour for vsyscalls so that
> -   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
> -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
> -  ({									\
> -    long _ret = funcptr (args);						\
> -    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
> -    if (err)								\
> -      _ret = -_ret;							\
> -    _ret;								\
> -  })
> -
>  #endif /* __ASSEMBLER__ */
>  
>  /* Pointer mangling is not yet supported for MIPS.  */
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> index bb49429c30..49e94a1706 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> @@ -297,18 +297,6 @@
>  #define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
>  	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
>  
> -/* Standard MIPS syscalls have an error flag, and return a positive errno
> -   when the error flag is set. Emulate this behaviour for vsyscalls so that
> -   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
> -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
> -  ({									\
> -    long _ret = funcptr (args);						\
> -    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
> -    if (err)								\
> -      _ret = -_ret;							\
> -    _ret;								\
> -  })
> -
>  #endif /* __ASSEMBLER__ */
>  
>  /* Pointer mangling is not yet supported for MIPS.  */
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> index 84a1ff186b..5911a62e5b 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> @@ -293,18 +293,6 @@
>  #define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
>  	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
>  
> -/* Standard MIPS syscalls have an error flag, and return a positive errno
> -   when the error flag is set. Emulate this behaviour for vsyscalls so that
> -   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
> -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
> -  ({									\
> -    long _ret = funcptr (args);						\
> -    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
> -    if (err)								\
> -      _ret = -_ret;							\
> -    _ret;								\
> -  })
> -
>  #endif /* __ASSEMBLER__ */
>  
>  /* Pointer mangling is not yet supported for MIPS.  */
> diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
> index 58a7244581..77b1f9c2fb 100644
> --- a/sysdeps/unix/sysv/linux/mips/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
> @@ -22,3 +22,19 @@
>  /* List of system calls which are supported as vsyscalls.  */
>  #define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
>  #define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
> +
> +#ifndef __ASSEMBLER__
> +
> +/* Standard MIPS syscalls have an error flag, and return a positive errno
> +   when the error flag is set. Emulate this behaviour for vsyscalls so that
> +   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
> +#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
> +  ({									\
> +    long _ret = funcptr (args);						\
> +    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
> +    if (err)								\
> +      _ret = -_ret;							\
> +    _ret;								\
> +  })
> +
> +#endif /* __ASSEMBLER__  */
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 6/8] sparc64: Use linux generic time implementation
  2019-09-05 20:56 ` [PATCH v2 6/8] sparc64: Use linux generic time implementation Adhemerval Zanella
@ 2019-09-17 14:26   ` Adhemerval Zanella
  0 siblings, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-17 14:26 UTC (permalink / raw)
  To: libc-alpha

I will commit this shortly if no one opposes, after I tested on the affected
architectures.

On 05/09/2019 17:56, Adhemerval Zanella wrote:
> There is no need to sparc64 provide an arch-specific implementation to
> route to POSIX one (which uses gettimeofday).  Linux one already handles
> the case for architecture that does not have __NR_time.
> 
> No semantic changes, checked against a build for sparc64-linux-gnu.
> 
> 	* sysdeps/unix/sysv/linux/sparc/sparc64/time.c: Remove file.
> ---
>  sysdeps/unix/sysv/linux/sparc/sparc64/time.c | 1 -
>  1 file changed, 1 deletion(-)
>  delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/time.c
> 
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c b/sysdeps/unix/sysv/linux/sparc/sparc64/time.c
> deleted file mode 100644
> index 509b580c55..0000000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/posix/time.c>
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH] Fix vDSO initialization on arm and mips
  2019-09-05 20:56 ` [PATCH v2 2/8] Refactor vDSO initialization code Adhemerval Zanella
  2019-09-17 14:23   ` Adhemerval Zanella
@ 2019-09-24 11:41   ` Andreas Schwab
  2019-09-24 11:51     ` Florian Weimer
  2019-09-24 14:08     ` Adhemerval Zanella
  1 sibling, 2 replies; 20+ messages in thread
From: Andreas Schwab @ 2019-09-24 11:41 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

	* sysdeps/unix/sysv/linux/arm/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL): Define to "__vdso_clock_gettime",
	not "__vdso_gettimeofday".
	(HAVE_GETTIMEOFDAY_VSYSCALL): Define to "__vdso_gettimeofday", not
	"__vdso_clock_gettime".
	* sysdeps/unix/sysv/linux/mips/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL): Define to "__vdso_clock_gettime",
	not "__vdso_gettimeofday".
	(HAVE_GETTIMEOFDAY_VSYSCALL): Define to "__vdso_gettimeofday", not
	"__vdso_clock_gettime".

diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index f9cc9335f5..e9e022e037 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -392,8 +392,8 @@ __local_syscall_error:						\
 #define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_gettimeofday"
-#define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_clock_gettime"
+#define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 
 #define LOAD_ARGS_0()
 #define ASM_ARGS_0
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
index b2045fcc55..82a3cf9f3d 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -20,8 +20,8 @@
 #define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
-#define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
+#define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_clock_gettime"
+#define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_gettimeofday"
 
 #ifndef __ASSEMBLER__
 
-- 
2.23.0

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH] Fix vDSO initialization on arm and mips
  2019-09-24 11:41   ` [PATCH] Fix vDSO initialization on arm and mips Andreas Schwab
@ 2019-09-24 11:51     ` Florian Weimer
  2019-09-24 14:08     ` Adhemerval Zanella
  1 sibling, 0 replies; 20+ messages in thread
From: Florian Weimer @ 2019-09-24 11:51 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Adhemerval Zanella, libc-alpha

* Andreas Schwab:

> 	* sysdeps/unix/sysv/linux/arm/sysdep.h
> 	(HAVE_CLOCK_GETTIME_VSYSCALL): Define to "__vdso_clock_gettime",
> 	not "__vdso_gettimeofday".
> 	(HAVE_GETTIMEOFDAY_VSYSCALL): Define to "__vdso_gettimeofday", not
> 	"__vdso_clock_gettime".
> 	* sysdeps/unix/sysv/linux/mips/sysdep.h
> 	(HAVE_CLOCK_GETTIME_VSYSCALL): Define to "__vdso_clock_gettime",
> 	not "__vdso_gettimeofday".
> 	(HAVE_GETTIMEOFDAY_VSYSCALL): Define to "__vdso_gettimeofday", not
> 	"__vdso_clock_gettime".

It would be nice if you could note in the commit message the commit
that is fixed by this change.

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] Fix vDSO initialization on arm and mips
  2019-09-24 11:41   ` [PATCH] Fix vDSO initialization on arm and mips Andreas Schwab
  2019-09-24 11:51     ` Florian Weimer
@ 2019-09-24 14:08     ` Adhemerval Zanella
  1 sibling, 0 replies; 20+ messages in thread
From: Adhemerval Zanella @ 2019-09-24 14:08 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: libc-alpha

Thanks to check on this and sorry for the trouble.

> Il giorno 24 set 2019, alle ore 04:41, Andreas Schwab <schwab@suse.de> ha scritto:
> 
>    * sysdeps/unix/sysv/linux/arm/sysdep.h
>    (HAVE_CLOCK_GETTIME_VSYSCALL): Define to "__vdso_clock_gettime",
>    not "__vdso_gettimeofday".
>    (HAVE_GETTIMEOFDAY_VSYSCALL): Define to "__vdso_gettimeofday", not
>    "__vdso_clock_gettime".
>    * sysdeps/unix/sysv/linux/mips/sysdep.h
>    (HAVE_CLOCK_GETTIME_VSYSCALL): Define to "__vdso_clock_gettime",
>    not "__vdso_gettimeofday".
>    (HAVE_GETTIMEOFDAY_VSYSCALL): Define to "__vdso_gettimeofday", not
>    "__vdso_clock_gettime".
> 
> diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
> index f9cc9335f5..e9e022e037 100644
> --- a/sysdeps/unix/sysv/linux/arm/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
> @@ -392,8 +392,8 @@ __local_syscall_error:                        \
> #define VDSO_HASH  61765110
> 
> /* List of system calls which are supported as vsyscalls.  */
> -#define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_gettimeofday"
> -#define HAVE_GETTIMEOFDAY_VSYSCALL    "__vdso_clock_gettime"
> +#define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
> +#define HAVE_GETTIMEOFDAY_VSYSCALL    "__vdso_gettimeofday"
> 
> #define LOAD_ARGS_0()
> #define ASM_ARGS_0
> diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
> index b2045fcc55..82a3cf9f3d 100644
> --- a/sysdeps/unix/sysv/linux/mips/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
> @@ -20,8 +20,8 @@
> #define VDSO_HASH  61765110
> 
> /* List of system calls which are supported as vsyscalls.  */
> -#define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
> -#define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
> +#define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_clock_gettime"
> +#define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_gettimeofday"
> 
> #ifndef __ASSEMBLER__
> 
> -- 
> 2.23.0
> 
> -- 
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/8] Enable vDSO on interposed malloc linked statically
  2019-09-05 20:56 ` [PATCH 3/8] Enable vDSO on interposed malloc linked statically Adhemerval Zanella
@ 2019-10-08 18:35   ` Adhemerval Zanella
  2019-10-08 19:04     ` DJ Delorie
  0 siblings, 1 reply; 20+ messages in thread
From: Adhemerval Zanella @ 2019-10-08 18:35 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 05/09/2019 17:56, Adhemerval Zanella wrote:
> For statically linked binaries, _dl_non_dynamic_init (csu/init-first.c:74)
> calls malloc before the vDSO is properly initialized (it will fully usable
> only after VDSO_SETUP call).  The bug is triggered for the cases where an
> interposed malloc calls clock_gettime or any other implementation that may
> call a vDSO symbol.
> 
> It is because PTR_DEMANDLE at {INLINE,INTERNAL}_VSYSCALL is called with
> uninitialized __vdso_* pointer value, which should be done by PTR_MANGLE
> (zero-initialized value in this case is invalid).  The patch fixes by adding
> an extra hook before _dl_non_dynamic_init which setup the initial __vdso_*
> pointer symbol to an mangled NULL value.
> 
> For NULL mangled values {INLINE,INTERNAL}_VSYSCALL issues the syscall
> directly in fallback code path.  Once the __vdso_* is setup the vsyscall
> branches to vDSO.
> 
> Checked on x86_64-linux-gnu.
> 
> 	[BZ #24967]
> 	* sysdeps/unix/sysv/linux/init-first.c (libc_vdso_mangled_symbol):
> 	New symbol.
> 	(__libc_vdso_platform_setup): Add an option to call it to initialize
> 	the hooks to null values.
> 	(VDSO_PRE_SETUP): Define.
> 	* csu/init-first.c (_init): Add a pre-hook to initialize the vDSO
> 	internal pointer.
> 	* malloc/tst-interpose-aux.c (allocation_header): Add ts member.
> 	(malloc_internal): Call clock_gettime.
> ---
>  csu/init-first.c                     |  8 ++++++
>  malloc/tst-interpose-aux.c           |  5 ++++
>  sysdeps/unix/sysv/linux/init-first.c | 37 +++++++++++++++++++---------
>  3 files changed, 39 insertions(+), 11 deletions(-)
> 
> diff --git a/csu/init-first.c b/csu/init-first.c
> index 10762b61f5..d984419554 100644
> --- a/csu/init-first.c
> +++ b/csu/init-first.c
> @@ -69,6 +69,14 @@ _init (int argc, char **argv, char **envp)
>    __environ = envp;
>  
>  #ifndef SHARED
> +  /* Initialize the vDSO internal pointers to mangled zero value.  It makes
> +     the {INTERNAL,INLINE}_VSYSCALL macro to fallback to direct syscall
> +     and allows call the symbol that might the vDSO on _dl_non_dynamic_init
> +     (for instance clock_gettime on an interposed malloc).  */
> +# ifdef VDSO_PRE_SETUP
> +  VDSO_PRE_SETUP ();
> +# endif
> +
>    /* First the initialization which normally would be done by the
>       dynamic linker.  */
>    _dl_non_dynamic_init ();
> diff --git a/malloc/tst-interpose-aux.c b/malloc/tst-interpose-aux.c
> index bf86224401..de62d436bc 100644
> --- a/malloc/tst-interpose-aux.c
> +++ b/malloc/tst-interpose-aux.c
> @@ -28,6 +28,7 @@
>  #include <sys/mman.h>
>  #include <sys/uio.h>
>  #include <unistd.h>
> +#include <time.h>
>  
>  #if INTERPOSE_THREADS
>  #include <pthread.h>
> @@ -96,6 +97,7 @@ struct __attribute__ ((aligned (__alignof__ (max_align_t)))) allocation_header
>  {
>    size_t allocation_index;
>    size_t allocation_size;
> +  struct timespec ts;
>  };
>  
>  /* Array of known allocations, to track invalid frees.  */
> @@ -166,6 +168,9 @@ malloc_internal (size_t size)
>        .allocation_index = index,
>        .allocation_size = allocation_size
>      };
> +  /* Check if calling a symbol which may use the vDSO does not fail.
> +     The CLOCK_REALTIME should be supported on all systems.  */
> +  clock_gettime (CLOCK_REALTIME, &allocations[index]->ts);
>    return allocations[index] + 1;
>  }
>  
> diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
> index d90ca820be..a23e5d9f6e 100644
> --- a/sysdeps/unix/sysv/linux/init-first.c
> +++ b/sysdeps/unix/sysv/linux/init-first.c
> @@ -44,37 +44,52 @@ long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
>  time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden;
>  #endif
>  
> +static inline void *
> +__libc_vdso_mangled_symbol (const char *symbol)
> +{
> +  void *vdsop = NULL;
> +  if (symbol != NULL)
> +    vdsop = get_vdso_mangle_symbol (symbol);
> +  else
> +    PTR_MANGLE (vdsop);
> +  return vdsop;
> +}
> +
>  static inline void
> -__libc_vdso_platform_setup (void)
> +__libc_vdso_platform_setup (bool initial)
>  {
>  #ifdef HAVE_CLOCK_GETTIME_VSYSCALL
> -  VDSO_SYMBOL(clock_gettime)
> -    = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL);
> +  VDSO_SYMBOL(clock_gettime) =
> +    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_CLOCK_GETTIME_VSYSCALL);
>  #endif
>  
>  #ifdef HAVE_CLOCK_GETRES_VSYSCALL
> -  VDSO_SYMBOL(clock_getres)
> -    = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL);
> +  VDSO_SYMBOL(clock_getres) =
> +    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_CLOCK_GETRES_VSYSCALL);
>  #endif
>  
>  #ifdef HAVE_GETTIMEOFDAY_VSYSCALL
> -  VDSO_SYMBOL(gettimeofday)
> -    = get_vdso_mangle_symbol (HAVE_GETTIMEOFDAY_VSYSCALL);
> +  VDSO_SYMBOL(gettimeofday) =
> +    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_GETTIMEOFDAY_VSYSCALL);
>  #endif
>  
>  #ifdef HAVE_GETCPU_VSYSCALL
> -  VDSO_SYMBOL(getcpu) = get_vdso_mangle_symbol (HAVE_GETCPU_VSYSCALL);
> +  VDSO_SYMBOL(getcpu) =
> +    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_GETCPU_VSYSCALL);
>  #endif
>  
>  #ifdef HAVE_TIME_VSYSCALL
> -  VDSO_SYMBOL(time) = get_vdso_mangle_symbol (HAVE_TIME_VSYSCALL);
> +  VDSO_SYMBOL(time) =
> +    __libc_vdso_mangled_symbol (initial ? NULL : HAVE_TIME_VSYSCALL);
>  #endif
>  
>  #ifdef VDSO_SETUP_ARCH
> -  VDSO_SETUP_ARCH ();
> +  if (!initial)
> +    VDSO_SETUP_ARCH ();
>  #endif
>  }
>  
> -#define VDSO_SETUP __libc_vdso_platform_setup
> +#define VDSO_PRE_SETUP() ({ __libc_vdso_platform_setup (true); })
> +#define VDSO_SETUP()     ({ __libc_vdso_platform_setup (false); })
>  
>  #include <csu/init-first.c>
> 

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH 3/8] Enable vDSO on interposed malloc linked statically
  2019-10-08 18:35   ` Adhemerval Zanella
@ 2019-10-08 19:04     ` DJ Delorie
  0 siblings, 0 replies; 20+ messages in thread
From: DJ Delorie @ 2019-10-08 19:04 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>> Checked on x86_64-linux-gnu.
>> 
>> 	[BZ #24967]
>> 	* sysdeps/unix/sysv/linux/init-first.c (libc_vdso_mangled_symbol):
>> 	New symbol.
>> 	(__libc_vdso_platform_setup): Add an option to call it to initialize
>> 	the hooks to null values.
>> 	(VDSO_PRE_SETUP): Define.
>> 	* csu/init-first.c (_init): Add a pre-hook to initialize the vDSO
>> 	internal pointer.
>> 	* malloc/tst-interpose-aux.c (allocation_header): Add ts member.
>> 	(malloc_internal): Call clock_gettime.

the malloc/tst-interpose-aux.c part is OK with me

(don't feel qualified to OK the rest of it yet ;)

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-10-08 19:05 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-05 20:56 [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
2019-09-05 20:56 ` [PATCH v2 2/8] Refactor vDSO initialization code Adhemerval Zanella
2019-09-17 14:23   ` Adhemerval Zanella
2019-09-24 11:41   ` [PATCH] Fix vDSO initialization on arm and mips Andreas Schwab
2019-09-24 11:51     ` Florian Weimer
2019-09-24 14:08     ` Adhemerval Zanella
2019-09-05 20:56 ` [PATCH 3/8] Enable vDSO on interposed malloc linked statically Adhemerval Zanella
2019-10-08 18:35   ` Adhemerval Zanella
2019-10-08 19:04     ` DJ Delorie
2019-09-05 20:56 ` [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros Adhemerval Zanella
2019-09-05 22:05   ` cseo
2019-09-17 14:23     ` Adhemerval Zanella
2019-09-05 20:56 ` [PATCH v2 5/8] mips: Consolidate INTERNAL_VSYSCALL_CALL Adhemerval Zanella
2019-09-17 14:24   ` Adhemerval Zanella
2019-09-05 20:56 ` [PATCH v2 6/8] sparc64: Use linux generic time implementation Adhemerval Zanella
2019-09-17 14:26   ` Adhemerval Zanella
2019-09-05 20:56 ` [PATCH v2 7/8] linux: Consolidate " Adhemerval Zanella
2019-09-05 20:56 ` [PATCH v2 8/8] linux: Consolidate gettimeofday implementation Adhemerval Zanella
2019-09-11 14:10 ` [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Andreas Schwab
2019-09-17 14:22   ` Adhemerval Zanella

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).