diff options
author | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2014-01-16 06:53:18 -0600 |
---|---|---|
committer | Adhemerval Zanella <azanella@linux.vnet.ibm.com> | 2015-01-15 21:03:27 -0500 |
commit | 1bdb6daceb10307543599df3b118afd2109d2ec8 (patch) | |
tree | 298304c03c715f12d6857b5d21aa3647c47f2b3e /sysdeps/unix/sysv/linux | |
parent | e3008132765936162552b15a77fe348c01074310 (diff) | |
download | glibc-1bdb6daceb10307543599df3b118afd2109d2ec8.tar.gz glibc-1bdb6daceb10307543599df3b118afd2109d2ec8.tar.xz glibc-1bdb6daceb10307543599df3b118afd2109d2ec8.zip |
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')
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/gettimeofday.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index 06aae83cc5..cc5d82e10a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -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 |