From 9f8fef024e5774608545e165c5a0eec56170585e32aef14d98cc84502a504def Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Fri, 2 Sep 2011 09:31:57 +0000 Subject: [PATCH] Accepting request 80630 from home:a_jaeger:branches:openSUSE:Factory Add support for new vdso. OBS-URL: https://build.opensuse.org/request/show/80630 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=98 --- glibc-2.15-vsyscall.patch | 310 ++++++++++++++++++++++++++++++++++++++ glibc.changes | 7 + glibc.spec | 3 + 3 files changed, 320 insertions(+) create mode 100644 glibc-2.15-vsyscall.patch diff --git a/glibc-2.15-vsyscall.patch b/glibc-2.15-vsyscall.patch new file mode 100644 index 0000000..331314d --- /dev/null +++ b/glibc-2.15-vsyscall.patch @@ -0,0 +1,310 @@ +commit 91b392a4bab0c2dc90e7e3ff914dec20b97adca8 +Author: Ulrich Drepper +Date: Sun Aug 21 13:52:28 2011 -0400 + + Use ifuncs for time and gettimeofday on x86-64 + +2011-08-21 Ulrich Drepper + + * sysdeps/unix/sysv/linux/x86_64/gettimeofday.S: Removed. + * sysdeps/unix/sysv/linux/x86_64/time.S: Removed. + * sysdeps/unix/sysv/linux/x86_64/gettimeofday.c: New file. + * sysdeps/unix/sysv/linux/x86_64/time.c: New file. + * sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h: Remove declaration + of __vdso_gettimeofday. + * sysdeps/unix/sysv/linux/x86_64/init-first.c: Remove definition of + __vdso_gettimeofday and __vdso_time. Define __vdso_getcpu with + attribute_hidden. + (_libc_vdso_platform_setup): Remove initialization of + __vdso_gettimeofday and __vdso_time. + +diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h b/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h +index d7123c9..f9bf84e 100644 +--- a/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h ++++ b/sysdeps/unix/sysv/linux/x86_64/bits/libc-vdso.h +@@ -1,5 +1,5 @@ + /* Resolve function pointers to VDSO functions. +- Copyright (C) 2005, 2007 Free Software Foundation, Inc. ++ Copyright (C) 2005, 2007, 2011 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 +@@ -25,9 +25,6 @@ + + #ifdef SHARED + +-extern long int (*__vdso_gettimeofday) (struct timeval *, void *) +- attribute_hidden; +- + extern long int (*__vdso_clock_gettime) (clockid_t, struct timespec *); + + #endif +diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S +deleted file mode 100644 +index f618e73..0000000 +--- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.S ++++ /dev/null +@@ -1,49 +0,0 @@ +-/* Copyright (C) 2002, 2003, 2007 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, write to the Free +- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +- 02111-1307 USA. */ +- +-#include +-#define _ERRNO_H 1 +-#include +- +-/* For the calculation see asm/vsyscall.h. */ +-#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000 +- +- +-ENTRY (__gettimeofday) +- /* Align stack. */ +- sub $0x8, %rsp +- cfi_adjust_cfa_offset(8) +-#ifdef SHARED +- movq __vdso_gettimeofday(%rip), %rax +- PTR_DEMANGLE (%rax) +-#else +- movq $VSYSCALL_ADDR_vgettimeofday, %rax +-#endif +- callq *%rax +- /* Check error return. */ +- cmpl $-4095, %eax +- jae SYSCALL_ERROR_LABEL +- +-L(pseudo_end): +- add $0x8, %rsp +- cfi_adjust_cfa_offset(-8) +- ret +-PSEUDO_END(__gettimeofday) +- +-strong_alias (__gettimeofday, __gettimeofday_internal) +-weak_alias (__gettimeofday, gettimeofday) +diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c +new file mode 100644 +index 0000000..1a773d6 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c +@@ -0,0 +1,49 @@ ++/* Copyright (C) 2002, 2003, 2007, 2011 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++ ++ ++#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul ++ ++ ++#ifdef SHARED ++void *gettimeofday_ifunc (void) __asm__ ("__gettimeofday"); ++ ++void * ++gettimeofday_ifunc (void) ++{ ++ PREPARE_VERSION (linux26, "LINUX_2.6", 61765110); ++ ++ /* If the vDSO is not available we fall back on the old vsyscall. */ ++ return (_dl_vdso_vsym ("gettimeofday", &linux26) ++ ?: (void *) VSYSCALL_ADDR_vgettimeofday); ++} ++__asm (".type __gettimeofday, %gnu_indirect_function"); ++#else ++# include ++ ++int ++__gettimeofday (struct timeval *tv, struct timezone *tz) ++{ ++ return ((int (*) (struct timeval *, struct timezone *)) VSYSCALL_ADDR_vgettimeofday) (tv, tz); ++} ++#endif ++ ++weak_alias (__gettimeofday, gettimeofday) ++strong_alias (__gettimeofday, __gettimeofday_internal) +diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c +index e676f62..25cf08b 100644 +--- a/sysdeps/unix/sysv/linux/x86_64/init-first.c ++++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c +@@ -20,15 +20,11 @@ + # include + # include + +-long int (*__vdso_gettimeofday) (struct timeval *, void *) attribute_hidden; +- + long int (*__vdso_clock_gettime) (clockid_t, struct timespec *) + __attribute__ ((nocommon)); + strong_alias (__vdso_clock_gettime, __GI___vdso_clock_gettime attribute_hidden) + +-long int (*__vdso_getcpu) (unsigned *, unsigned *, void *); +- +-long int (*__vdso_time) (time_t *) attribute_hidden; ++long int (*__vdso_getcpu) (unsigned *, unsigned *, void *) attribute_hidden; + + + static inline void +@@ -36,15 +32,7 @@ _libc_vdso_platform_setup (void) + { + PREPARE_VERSION (linux26, "LINUX_2.6", 61765110); + +- void *p = _dl_vdso_vsym ("gettimeofday", &linux26); +- /* If the vDSO is not available we fall back on the old vsyscall. */ +-#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul +- if (p == NULL) +- p = (void *) VSYSCALL_ADDR_vgettimeofday; +- PTR_MANGLE (p); +- __vdso_gettimeofday = p; +- +- p = _dl_vdso_vsym ("clock_gettime", &linux26); ++ void *p = _dl_vdso_vsym ("clock_gettime", &linux26); + PTR_MANGLE (p); + __GI___vdso_clock_gettime = p; + +@@ -55,14 +43,6 @@ _libc_vdso_platform_setup (void) + p = (void *) VSYSCALL_ADDR_vgetcpu; + PTR_MANGLE (p); + __vdso_getcpu = p; +- +- p = _dl_vdso_vsym ("time", &linux26); +- /* If the vDSO is not available we fall back on the old vsyscall. */ +-#define VSYSCALL_ADDR_vtime 0xffffffffff600400 +- if (p == NULL) +- p = (void *) VSYSCALL_ADDR_vtime; +- PTR_MANGLE (p); +- __vdso_time = p; + } + + # define VDSO_SETUP _libc_vdso_platform_setup +diff --git a/sysdeps/unix/sysv/linux/x86_64/time.S b/sysdeps/unix/sysv/linux/x86_64/time.S +deleted file mode 100644 +index 66d7498..0000000 +--- a/sysdeps/unix/sysv/linux/x86_64/time.S ++++ /dev/null +@@ -1,47 +0,0 @@ +-/* Copyright (C) 2001,02, 2003, 2011 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, write to the Free +- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +- 02111-1307 USA. */ +- +-#include +-#define _ERRNO_H 1 +-#include +- +-/* For the calculation see asm/vsyscall.h. */ +-#define VSYSCALL_ADDR_vtime 0xffffffffff600400 +- +- +-/* Return the current time as a `time_t' and also put it in *T if T is +- not NULL. Time is represented as seconds from Jan 1 00:00:00 1970. */ +- +-ENTRY (time) +- /* Align stack. */ +- sub $0x8, %rsp +- cfi_adjust_cfa_offset(8) +- +-#ifdef SHARED +- movq __vdso_time(%rip), %rax +- PTR_DEMANGLE (%rax) +-#else +- movq $VSYSCALL_ADDR_vtime, %rax +-#endif +- callq *%rax +- +- add $0x8, %rsp +- cfi_adjust_cfa_offset(-8) +- ret +-PSEUDO_END_NOERRNO(time) +-libc_hidden_def (time) +diff --git a/sysdeps/unix/sysv/linux/x86_64/time.c b/sysdeps/unix/sysv/linux/x86_64/time.c +new file mode 100644 +index 0000000..698d561 +--- /dev/null ++++ b/sysdeps/unix/sysv/linux/x86_64/time.c +@@ -0,0 +1,47 @@ ++/* Copyright (C) 2001,02, 2003, 2011 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, write to the Free ++ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA ++ 02111-1307 USA. */ ++ ++#include ++ ++ ++#define VSYSCALL_ADDR_vtime 0xffffffffff600400 ++ ++ ++#ifdef SHARED ++void *time_ifunc (void) __asm__ ("time"); ++ ++void * ++time_ifunc (void) ++{ ++ PREPARE_VERSION (linux26, "LINUX_2.6", 61765110); ++ ++ /* If the vDSO is not available we fall back on the old vsyscall. */ ++ return _dl_vdso_vsym ("time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime; ++} ++__asm (".type time, %gnu_indirect_function"); ++#else ++# include ++ ++time_t ++time (time_t *t) ++{ ++ return ((time_t (*) (time_t *)) VSYSCALL_ADDR_vtime) (t); ++} ++#endif ++ ++strong_alias (time, __GI_time) diff --git a/glibc.changes b/glibc.changes index 160e877..f61afd8 100644 --- a/glibc.changes +++ b/glibc.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Sep 1 20:49:16 UTC 2011 - aj@suse.de + +- Add support for new vdso (3.1 kernel) and only then + for vsyscall which is not anymore in 3.1 kernel + (patch glibc-2.15-vsyscall.patch) + ------------------------------------------------------------------- Thu Aug 25 09:44:37 UTC 2011 - lnussel@suse.de diff --git a/glibc.spec b/glibc.spec index 62b4457..be2c240 100644 --- a/glibc.spec +++ b/glibc.spec @@ -200,6 +200,8 @@ Patch67: glibc-revert-fseek-on-fclose.diff Patch68: glibc-fix-lookup-crash.patch # PATCH-FIX-UPSTREAM Fix fopen("non-existing-file", "re") errno bnc#713146 aj@suse.de Patch69: fopen-close-exec.patch +# PATCH-FIX-UPSTREAM Use ifuncs for time and gettimeofday on x86-64 - aj@suse.de +Patch70: glibc-2.15-vsyscall.patch # PATCH-FEATURE-OPENSUSE -- add sha support to crypt_blowfish lnussel@suse.de Patch80: crypt_blowfish-1.2-sha.diff # PATCH-FEATURE-OPENSUSE -- use separate symbol version for Owl extensions - lnussel@suse.de @@ -435,6 +437,7 @@ rm nscd/s-stamp %patch67 -p1 %patch68 -p1 %patch69 -p1 +%patch70 -p1 # # Inconsistency detected by ld.so: dl-close.c: 719: _dl_close: Assertion `map->l_init_called' failed!