Blame SOURCES/glibc-rh1064945.patch

147e83
commit 736c304a1ab4cee36a2f3343f1698bc0abae4608
147e83
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
147e83
Date:   Thu Jan 16 06:53:18 2014 -0600
147e83
147e83
    PowerPC: Fix ftime gettimeofday internal call returning bogus data
147e83
    
147e83
    This patches fixes BZ#16430 by setting a different symbol for internal
147e83
    GLIBC calls that points to ifunc resolvers. For PPC32, if the symbol
147e83
    is defined as hidden (which is the case for gettimeofday and time) the
147e83
    compiler will create local branches (symbol@local) and linker will not
147e83
    create PLT calls (required for IFUNC). This will leads to internal symbol
147e83
    calling the IFUNC resolver instead of the resolved symbol.
147e83
    For PPC64 this behavior does not occur because a call to a function in
147e83
    another translation unit might use a different toc pointer thus requiring
147e83
    a PLT call.
147e83
147e83
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
147e83
index 29a5e08..2085b68 100644
147e83
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
147e83
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
147e83
@@ -44,8 +44,24 @@ asm (".type __gettimeofday, %gnu_indirect_function");
147e83
 /* This is doing "libc_hidden_def (__gettimeofday)" but the compiler won't
147e83
    let us do it in C because it doesn't know we're defining __gettimeofday
147e83
    here in this file.  */
147e83
-asm (".globl __GI___gettimeofday\n"
147e83
-     "__GI___gettimeofday = __gettimeofday");
147e83
+asm (".globl __GI___gettimeofday");
147e83
+
147e83
+/* __GI___gettimeofday is defined as hidden and for ppc32 it enables the
147e83
+   compiler make a local call (symbol@local) for internal GLIBC usage. It
147e83
+   means the PLT won't be used and the ifunc resolver will be called directly.
147e83
+   For ppc64 a call to a function in another translation unit might use a
147e83
+   different toc pointer thus disallowing direct branchess and making internal
147e83
+   ifuncs calls safe.  */
147e83
+#ifdef __powerpc64__
147e83
+asm ("__GI___gettimeofday = __gettimeofday");
147e83
+#else
147e83
+int
147e83
+__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
147e83
+{
147e83
+  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
147e83
+}
147e83
+asm ("__GI___gettimeofday = __gettimeofday_vsyscall");
147e83
+#endif
147e83
 
147e83
 #else
147e83
 
147e83
diff --git glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c
147e83
index 089d0b6..023bc02 100644
147e83
--- glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c
147e83
+++ glibc-2.17-c758a686/sysdeps/unix/sysv/linux/powerpc/time.c
147e83
@@ -54,8 +54,24 @@ asm (".type time, %gnu_indirect_function");
147e83
 /* This is doing "libc_hidden_def (time)" but the compiler won't
147e83
  * let us do it in C because it doesn't know we're defining time
147e83
  * here in this file.  */
147e83
-asm (".globl __GI_time\n"
147e83
-     "__GI_time = time");
147e83
+asm (".globl __GI_time");
147e83
+
147e83
+/* __GI_time is defined as hidden and for ppc32 it enables the
147e83
+   compiler make a local call (symbol@local) for internal GLIBC usage. It
147e83
+   means the PLT won't be used and the ifunc resolver will be called directly.
147e83
+   For ppc64 a call to a function in another translation unit might use a
147e83
+   different toc pointer thus disallowing direct branchess and making internal
147e83
+   ifuncs calls safe.  */
147e83
+#ifdef __powerpc64__
147e83
+asm ("__GI_time = time");
147e83
+#else
147e83
+time_t
147e83
+__time_vsyscall (time_t *t)
147e83
+{
147e83
+  return INLINE_VSYSCALL (time, 1, t);
147e83
+}
147e83
+asm ("__GI_time = __time_vsyscall");
147e83
+#endif
147e83
 
147e83
 #else
147e83