olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1064945.patch

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