summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv/linux/powerpc/time.c
diff options
context:
space:
mode:
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>2014-01-16 06:53:18 -0600
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>2014-01-16 06:53:18 -0600
commit736c304a1ab4cee36a2f3343f1698bc0abae4608 (patch)
tree63e4834af05375e2b1ef3b8c7db6515109edd6b8 /sysdeps/unix/sysv/linux/powerpc/time.c
parent94d0cea0ad2c225019736c2f18e1280eae50fa6c (diff)
downloadglibc-736c304a1ab4cee36a2f3343f1698bc0abae4608.tar.gz
PowerPC: Fix ftime gettimeofday internal call returning bogus data
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.
Diffstat (limited to 'sysdeps/unix/sysv/linux/powerpc/time.c')
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/time.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
index 089d0b69ec..023bc026be 100644
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ b/sysdeps/unix/sysv/linux/powerpc/time.c
@@ -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