This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Remove hidden_def for __gettimeofday for x86_64


Hi,

__gettimeofday is an ifunc on x86_64, which resolves to
__vdso_gettimeofday if available or else it falls back to the
vsyscall.  The hidden def for this is pointless since it does not
avoid a PLT.  Attached patch removes the hidden definition for x86_64.

This was caught due to a localplt test failure in Fedora rawhide
(binutils-2.23.52.0.1-9.fc20.x86_64).  The failure shows up as an
additional memset@PLT, which, on debugging callers, turned out to be
__GI___gettimeofday.  This seems to be a problem with binutils, but
the problem of __GI___gettimeofday is real.  The fix does not resolve
the failure itself, since binutils now confuses realloc with memset
and __libc_memmove with realloc.

So in the end, while this patch does remove an unnecessary symbol, it
doesn't really end up fixing anything since the real bug seems to be
in binutils.  Is it worthwhile committing this now, or wait till 2.19,
or not commit at all?

Siddhesh

	* include/sys/time.h: Move file...
	* sysdeps/generic/sys/time.h: ... here.
	* sysdeps/unix/sysv/linux/x86_64/gettimeofday.c [SHARED]:
	Remove libc_hidden_def and libc_hidden_weak.
	[!SHARED]: Add libc_hidden_weak.
	* sysdeps/unix/sysv/linux/x86_64/sys/time.h: New file.

diff --git a/include/sys/time.h b/include/sys/time.h
deleted file mode 100644
index b9af6d4..0000000
--- a/include/sys/time.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Time function internal interfaces.
-   Copyright (C) 1997-2013 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _SYS_TIME_H
-# include <time/sys/time.h>
-
-# ifndef _ISOMAC
-extern int __gettimeofday (struct timeval *__tv,
-			   struct timezone *__tz);
-libc_hidden_proto (__gettimeofday)
-libc_hidden_proto (gettimeofday)
-extern int __settimeofday (const struct timeval *__tv,
-			   const struct timezone *__tz)
-	attribute_hidden;
-extern int __adjtime (const struct timeval *__delta,
-		      struct timeval *__olddelta);
-extern int __getitimer (enum __itimer_which __which,
-			struct itimerval *__value);
-extern int __setitimer (enum __itimer_which __which,
-			const struct itimerval *__restrict __new,
-			struct itimerval *__restrict __old)
-	attribute_hidden;
-extern int __utimes (const char *__file, const struct timeval __tvp[2])
-	attribute_hidden;
-extern int __futimes (int fd, const struct timeval tvp[2]) attribute_hidden;
-
-# endif
-#endif
diff --git a/sysdeps/generic/sys/time.h b/sysdeps/generic/sys/time.h
new file mode 100644
index 0000000..b9af6d4
--- /dev/null
+++ b/sysdeps/generic/sys/time.h
@@ -0,0 +1,43 @@
+/* Time function internal interfaces.
+   Copyright (C) 1997-2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _SYS_TIME_H
+# include <time/sys/time.h>
+
+# ifndef _ISOMAC
+extern int __gettimeofday (struct timeval *__tv,
+			   struct timezone *__tz);
+libc_hidden_proto (__gettimeofday)
+libc_hidden_proto (gettimeofday)
+extern int __settimeofday (const struct timeval *__tv,
+			   const struct timezone *__tz)
+	attribute_hidden;
+extern int __adjtime (const struct timeval *__delta,
+		      struct timeval *__olddelta);
+extern int __getitimer (enum __itimer_which __which,
+			struct itimerval *__value);
+extern int __setitimer (enum __itimer_which __which,
+			const struct itimerval *__restrict __new,
+			struct itimerval *__restrict __old)
+	attribute_hidden;
+extern int __utimes (const char *__file, const struct timeval __tvp[2])
+	attribute_hidden;
+extern int __futimes (int fd, const struct timeval tvp[2]) attribute_hidden;
+
+# endif
+#endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
index 556e0d5..50a83a1 100644
--- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
@@ -36,12 +36,6 @@ gettimeofday_ifunc (void)
 }
 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");
-
 #else
 
 # include <sysdep.h>
@@ -53,7 +47,7 @@ __gettimeofday (struct timeval *tv, struct timezone *tz)
   return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
 }
 libc_hidden_def (__gettimeofday)
+libc_hidden_weak (gettimeofday)
 
 #endif
 weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/x86_64/sys/time.h b/sysdeps/unix/sysv/linux/x86_64/sys/time.h
new file mode 100644
index 0000000..9bb25f1
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/sys/time.h
@@ -0,0 +1,45 @@
+/* Time function internal interfaces.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _SYS_TIME_H
+# include <time/sys/time.h>
+
+# ifndef _ISOMAC
+extern int __gettimeofday (struct timeval *__tv,
+			   struct timezone *__tz);
+#  ifndef SHARED
+libc_hidden_proto (__gettimeofday)
+libc_hidden_proto (gettimeofday)
+#  endif
+extern int __settimeofday (const struct timeval *__tv,
+			   const struct timezone *__tz)
+	attribute_hidden;
+extern int __adjtime (const struct timeval *__delta,
+		      struct timeval *__olddelta);
+extern int __getitimer (enum __itimer_which __which,
+			struct itimerval *__value);
+extern int __setitimer (enum __itimer_which __which,
+			const struct itimerval *__restrict __new,
+			struct itimerval *__restrict __old)
+	attribute_hidden;
+extern int __utimes (const char *__file, const struct timeval __tvp[2])
+	attribute_hidden;
+extern int __futimes (int fd, const struct timeval tvp[2]) attribute_hidden;
+
+# endif
+#endif


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]