]> 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 19:01:55 +0000 (13:01 -0600)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Thu, 16 Jan 2014 19:01:55 +0000 (13:01 -0600)
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
NEWS
sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
sysdeps/unix/sysv/linux/powerpc/time.c

index 4e3a8220fe3197048628558d35098fd917c8ff14..0992488a6a9ce5f7ba599f59af73162eadb9f213 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-16  Alan Modra  <amodra@gmail.com>
 
        * NEWS: Mention powerpc64le support and bugs fixed.
diff --git a/NEWS b/NEWS
index 2c6ad91d520e5ef635291789312ce01ce41f4076..db471a4ee8152ff5c713605bb48ed64bb3bdb092 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,7 +10,7 @@ Version 2.18.1
 * The following bugs are resolved with this release:
 
   14155, 14547, 14699, 15532, 15427, 15522, 15680, 15723, 15734, 15735,
-  15797, 15892, 15895, 15909, 15917, 15996, 16072, 16150.
+  15797, 15892, 15895, 15909, 15917, 15996, 16072, 16150, 16430.
 
 * Support for powerpc64le has been added.
 
index 48c3f84d86f60b0ddf9d0a5c7edcab3a710a2838..3ee063dba66b40e17c1259eb5ce963ec5e49394f 100644 (file)
@@ -44,8 +44,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
 
index 2d77ecec9be5ffb6be7dfd9fc78f154c17a887c4..85cc20e6e05277a476e1574c93d990c015b6a93e 100644 (file)
@@ -54,8 +54,24 @@ asm (".type time, %gnu_indirect_function");
 /* This is doing "libc_hidden_def (time)" but the compiler won't
  * let us do it in C because it doesn't know we're defining time
  * here in this file.  */
-asm (".globl __GI_time\n"
-     "__GI_time = time");
+asm (".globl __GI_time");
+
+/* __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.  */
+#ifdef __powerpc64__
+asm ("__GI_time = time");
+#else
+time_t
+__time_vsyscall (time_t *t)
+{
+  return INLINE_VSYSCALL (time, 1, t);
+}
+asm ("__GI_time = __time_vsyscall");
+#endif
 
 #else