]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: Fix ftime gettimeofday internal call returning bogus data
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Thu, 16 Jan 2014 12:53:18 +0000 (06:53 -0600)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 16 Jan 2015 02:03:27 +0000 (21:03 -0500)
This patches fixes BZ#16430 by setting a different symbol for internal
GLIBC calls that points to ifunc resolvers. For PPC32, if the symbol
is defined as hidden (which is the case for gettimeofday and time) the
compiler will create local branches (symbol@local) and linker will not
create PLT calls (required for IFUNC). This will leads to internal symbol
calling the IFUNC resolver instead of the resolved symbol.
For PPC64 this behavior does not occur because a call to a function in
another translation unit might use a different toc pointer thus requiring
a PLT call.

ChangeLog
sysdeps/unix/sysv/linux/powerpc/gettimeofday.c

index 963a282cf10c1f69dd4c99290cd4323db292ba1d..aa456cfa38483dba900687ecb2da26d9b78f8538 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-01-16  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+       [BZ#16430]
+       * sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+       (__GI___gettimeofday): Alias for a different internal symbol to avoid
+       local calls issues by not having a PLT stub required for IFUNC calls.
+       * sysdeps/unix/sysv/linux/powerpc/time.c (__GI_time): Likewise.
+
 2013-11-08  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
 
        * sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h (VDSO_IFUNC_RET):
        (parse_dollars): Remove check for WRDE_NOCMD.
        (parse_dquote): Likewise.
 
-2014-12-16  Florian Weimer  <fweimer@redhat.com>
-
-       [BZ #17630]
-       * resolv/nss_dns/dns-network.c (getanswer_r): Iterate over alias
-       names.
-
 2014-12-15  Jeff Law  <law@redhat.com>
 
        [BZ #16617]
index 06aae83cc510c498948ab1b8fbe04595cabf16be..cc5d82e10a3d2d56a8d4016f4b752789490405eb 100644 (file)
@@ -43,8 +43,24 @@ asm (".type __gettimeofday, %gnu_indirect_function");
 /* This is doing "libc_hidden_def (__gettimeofday)" but the compiler won't
    let us do it in C because it doesn't know we're defining __gettimeofday
    here in this file.  */
-asm (".globl __GI___gettimeofday\n"
-     "__GI___gettimeofday = __gettimeofday");
+asm (".globl __GI___gettimeofday");
+
+/* __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.  */
+#ifdef __powerpc64__
+asm ("__GI___gettimeofday = __gettimeofday");
+#else
+int
+__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
+{
+  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
+}
+asm ("__GI___gettimeofday = __gettimeofday_vsyscall");
+#endif
 
 #else