5de29b
#
5de29b
# commit d98720e07f67fbeec00f9e1347840404240d3c48
5de29b
# Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
5de29b
# Date:   Mon Jan 20 12:29:51 2014 -0600
5de29b
# 
5de29b
#     PowerPC: Fix gettimeofday ifunc selection
5de29b
#     
5de29b
#     The IFUNC selector for gettimeofday runs before _libc_vdso_platform_setup where
5de29b
#     __vdso_gettimeofday is set. The selector then sets __gettimeofday (the internal
5de29b
#     version used within GLIBC) to use the system call version instead of the vDSO one.
5de29b
#     This patch changes the check if vDSO is available to get its value directly
5de29b
#     instead of rely on __vdso_gettimeofday.
5de29b
#     
5de29b
#     This patch changes it by getting the vDSO value directly.
5de29b
#     
5de29b
#     It fixes BZ#16431.
5de29b
# 
12745e
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
5de29b
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c	2015-01-15 16:07:59.167420456 -0500
12745e
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c	2015-01-15 16:07:41.408969001 -0500
5de29b
@@ -34,9 +34,12 @@
5de29b
 void *
5de29b
 gettimeofday_ifunc (void)
5de29b
 {
5de29b
+  PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565);
5de29b
+
5de29b
   /* If the vDSO is not available we fall back syscall.  */
5de29b
-  return (__vdso_gettimeofday ? VDSO_IFUNC_RET (__vdso_gettimeofday)
5de29b
-	  : __gettimeofday_syscall);
5de29b
+  void *vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
5de29b
+  return (vdso_gettimeofday ? VDSO_IFUNC_RET (vdso_gettimeofday)
5de29b
+	  : (void*)__gettimeofday_syscall);
5de29b
 }
5de29b
 asm (".type __gettimeofday, %gnu_indirect_function");
5de29b
 
12745e
diff -urN glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c
5de29b
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c	2015-01-15 16:07:59.168420425 -0500
12745e
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c	2015-01-15 16:07:41.408969001 -0500
5de29b
@@ -45,9 +45,12 @@
5de29b
 void *
5de29b
 time_ifunc (void)
5de29b
 {
5de29b
+  PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565);
5de29b
+
5de29b
   /* If the vDSO is not available we fall back to the syscall.  */
5de29b
-  return (__vdso_time ? VDSO_IFUNC_RET (__vdso_time)
5de29b
-	  : time_syscall);
5de29b
+  void *vdso_time = _dl_vdso_vsym ("__kernel_time", &linux2615);
5de29b
+  return (vdso_time ? VDSO_IFUNC_RET (vdso_time)
5de29b
+	  : (void*)time_syscall);
5de29b
 }
5de29b
 asm (".type time, %gnu_indirect_function");
5de29b