diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2012-05-24 13:23:44 -0700 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2012-05-24 13:23:44 -0700 |
commit | f7d63c839b817c3e26f9126fca2ccd19cc021ea1 (patch) | |
tree | 554aa4396c60f256433d56c688613d7292f9f521 | |
parent | a7f9a9cd523d33e7b0c01dd5cd841f025bd5e3f5 (diff) | |
parent | c14874927b499ddfdbb03745bb32bfc778b8595f (diff) | |
download | glibc-hjl/x32/master.tar.gz glibc-hjl/x32/master.tar.xz glibc-hjl/x32/master.zip |
Merge remote-tracking branch 'origin/master' into hjl/x32/master hjl/x32/master
-rw-r--r-- | ChangeLog | 35 | ||||
-rw-r--r-- | Makeconfig | 4 | ||||
-rw-r--r-- | Makerules | 4 | ||||
-rw-r--r-- | include/sys/time.h | 9 | ||||
-rw-r--r-- | sysdeps/mach/gettimeofday.c | 8 | ||||
-rw-r--r-- | sysdeps/posix/gettimeofday.c | 8 | ||||
-rw-r--r-- | sysdeps/unix/make-syscalls.sh | 142 | ||||
-rw-r--r-- | sysdeps/unix/syscalls.list | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/dl-vdso.h | 11 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/gettimeofday.c | 7 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/s390/gettimeofday.c | 7 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/gettimeofday.c | 25 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list | 2 | ||||
-rw-r--r-- | time/gettimeofday.c | 11 |
14 files changed, 186 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog index e81684e70c..983ffe645e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2012-05-24 Roland McGrath <roland@hack.frob.com> + + * sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list: New file. + + * sysdeps/unix/make-syscalls.sh: Support "syscall:vdso_name@VDSOVER" + in the third column, to generate for the shared library an IFUNC + that uses _dl_vdso_vsym. + * Makerules (COMPILE.c, compile-stdin.c): New variables. + * Makeconfig (object-suffixes-noshared): New variable. + + * sysdeps/unix/sysv/linux/dl-vdso.h (PREPARE_VERSION_KNOWN): New macro. + (VDSO_NAME_LINUX_2_6, VDSO_HASH_LINUX_2_6): New macros. + (VDSO_NAME_LINUX_2_6_15, VDSO_HASH_LINUX_2_6_15): New macros. + (VDSO_NAME_LINUX_2_6_29, VDSO_HASH_LINUX_2_6_29): New macros. + + [BZ #14132] + * include/sys/time.h (__gettimeofday): Remove macro. + (__gettimeofday, gettimeofday): Add libc_hidden_proto. + * time/gettimeofday.c (__gettimeofday): Remove #undef. + Remove INTDEF. + (__gettimeofday): Add libc_hidden_def. + (gettimeofday): Add libc_hidden_weak. + * sysdeps/mach/gettimeofday.c: Likewise. + * sysdeps/posix/gettimeofday.c: Likewise. + * sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise. + * sysdeps/unix/sysv/linux/s390/gettimeofday.c: Likewise. + * sysdeps/unix/sysv/linux/x86_64/gettimeofday.c + (__gettimeofday_internal): Remove strong_alias. + (__gettimeofday): Add libc_hidden_def. + (gettimeofday): Add libc_hidden_weak. + * sysdeps/unix/syscalls.list (gettimeofday): + Remove __gettimeofday_internal alias. + 2012-05-24 Daniel Jacobowitz <drow@false.org> H.J. Lu <hongjiu.lu@intel.com> @@ -535,7 +568,7 @@ * manual/install.texi (Configuring and compiling): Update description about files modified in the source directory. - * INSTALL: Regenerated. + * INSTALL: Regenerated. 2012-05-18 H.J. Lu <hongjiu.lu@intel.com> diff --git a/Makeconfig b/Makeconfig index 4f9b9cf654..6d2d05a346 100644 --- a/Makeconfig +++ b/Makeconfig @@ -720,6 +720,10 @@ CFLAGS-.op = -pg libtype.op = lib%_p.a endif +# Convenience variable for when we want to treat shared-library cases +# differently from the rest. +object-suffixes-noshared := $(filter-out .os,$(object-suffixes)) + bppfx = BP- ifeq (yes,$(build-bounded)) # Under --enable-bounded, we build the library with `-fbounded-pointers -g' diff --git a/Makerules b/Makerules index 0fd1b5b3e3..685b1b86c6 100644 --- a/Makerules +++ b/Makerules @@ -366,6 +366,7 @@ compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS) compile.cc = $(CXX) $< -c $(CXXFLAGS) $(CPPFLAGS) compile.S = $(CC) $< -c $(CPPFLAGS) $(S-CPPFLAGS) \ $(ASFLAGS) $(ASFLAGS-$(suffix $@)) +COMPILE.c = $(CC) -c $(CFLAGS) $(CPPFLAGS) COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \ $(ASFLAGS) $(ASFLAGS-$(suffix $@)) @@ -374,6 +375,9 @@ COMPILE.S = $(CC) -c $(CPPFLAGS) $(S-CPPFLAGS) \ # together. You can't compile the C library with such a compiler. OUTPUT_OPTION = -o $@ +# This is the end of the pipeline for compiling generated C code. +compile-stdin.c = $(COMPILE.c) -o $@ -x c - $(compile-mkdep-flags) + # We need the $(CFLAGS) to be in there to have the right predefines during # the dependency run for C sources. But having it for assembly sources can # get the wrong predefines. diff --git a/include/sys/time.h b/include/sys/time.h index d5de942ed6..599e189bcd 100644 --- a/include/sys/time.h +++ b/include/sys/time.h @@ -5,9 +5,8 @@ /* Now document the internal interfaces. */ extern int __gettimeofday (struct timeval *__tv, struct timezone *__tz); -extern int __gettimeofday_internal (struct timeval *__tv, - struct timezone *__tz) - attribute_hidden; +libc_hidden_proto (__gettimeofday) +libc_hidden_proto (gettimeofday) extern int __settimeofday (const struct timeval *__tv, const struct timezone *__tz) attribute_hidden; @@ -23,9 +22,5 @@ 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; -#ifndef NOT_IN_libc -# define __gettimeofday(tv, tz) INTUSE(__gettimeofday) (tv, tz) -#endif - #endif #endif diff --git a/sysdeps/mach/gettimeofday.c b/sysdeps/mach/gettimeofday.c index 88dca8e89e..293a77595b 100644 --- a/sysdeps/mach/gettimeofday.c +++ b/sysdeps/mach/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1992,1995-1997,2001,2002 Free Software Foundation, Inc. +/* Copyright (C) 1991-2012 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 @@ -20,8 +20,6 @@ #include <sys/time.h> #include <mach.h> -#undef __gettimeofday - /* Get the current time of day and timezone information, putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. Returns 0 on success, -1 on errors. */ @@ -42,6 +40,6 @@ __gettimeofday (tv, tz) } return 0; } - -INTDEF(__gettimeofday) +libc_hidden_def (__gettimeofday) weak_alias (__gettimeofday, gettimeofday) +libc_hidden_weak (gettimeofday) diff --git a/sysdeps/posix/gettimeofday.c b/sysdeps/posix/gettimeofday.c index 31b3dd3fa1..1108ff0167 100644 --- a/sysdeps/posix/gettimeofday.c +++ b/sysdeps/posix/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991,1992,1994-1997,2002,2005 Free Software Foundation, Inc. +/* Copyright (C) 1991-2012 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 @@ -19,8 +19,6 @@ #include <time.h> #include <sys/time.h> -#undef __gettimeofday - /* Get the current time of day and timezone information, putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. Returns 0 on success, -1 on errors. */ @@ -66,6 +64,6 @@ __gettimeofday (tv, tz) return 0; } - -INTDEF(__gettimeofday) +libc_hidden_def (__gettimeofday) weak_alias (__gettimeofday, gettimeofday) +libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh index 48aab629f5..cedce3193c 100644 --- a/sysdeps/unix/make-syscalls.sh +++ b/sysdeps/unix/make-syscalls.sh @@ -64,10 +64,67 @@ done` # Any calls left? test -n "$calls" || exit 0 +# This uses variables $weak and $strong. +emit_weak_aliases() +{ + # A shortcoming in the current gas is that it will only allow one + # version-alias per symbol. So we create new strong aliases as needed. + vcount="" + + for name in $weak; do + case $name in + *@@*) + base=`echo $name | sed 's/@@.*//'` + ver=`echo $name | sed 's/.*@@//'` + if test -z "$vcount" ; then + source=$strong + vcount=1 + else + source="${strong}_${vcount}" + vcount=`expr $vcount + 1` + echo " echo 'strong_alias ($strong, $source)'; \\" + fi + echo " echo 'default_symbol_version($source, $base, $ver)'; \\" + ;; + *@*) + base=`echo $name | sed 's/@.*//'` + ver=`echo $name | sed 's/.*@//'` + if test -z "$vcount" ; then + source=$strong + vcount=1 + else + source="${strong}_${vcount}" + vcount=`expr $vcount + 1` + echo " echo 'strong_alias ($strong, $source)'; \\" + fi + echo " echo 'symbol_version ($source, $base, $ver)'; \\" + ;; + !*) + name=`echo $name | sed 's/.//'` + echo " echo 'strong_alias ($strong, $name)'; \\" + echo " echo 'libc_hidden_def ($name)'; \\" + ;; + *) + echo " echo 'weak_alias ($strong, $name)'; \\" + echo " echo 'libc_hidden_weak ($name)'; \\" + ;; + esac + done +} + + # Emit rules to compile the syscalls remaining in $calls. echo "$calls" | while read file srcfile caller syscall args strong weak; do + vdso_syscall= + case x"$syscall" in + *:*@*) + vdso_syscall="${syscall#*:}" + syscall="${syscall%:*}" + ;; + esac + case x"$syscall" in x-) callnum=_ ;; *) @@ -144,13 +201,14 @@ while read file srcfile caller syscall args strong weak; do # Emit a compilation rule for this syscall. if test $shared_only = t; then # The versioned symbols are only in the shared library. - echo "\ -shared-only-routines += $file -\$(objpfx)${file}.os: \\" + echo "shared-only-routines += $file" + test -n "$vdso_syscall" || echo "\$(objpfx)${file}.os: \\" else + object_suffixes='$(object-suffixes)' + test -z "$vdso_syscall" || object_suffixes='$(object-suffixes-noshared)' echo "\ \$(foreach p,\$(sysd-rules-targets),\ -\$(foreach o,\$(object-suffixes),\$(objpfx)\$(patsubst %,\$p,$file)\$o)): \\" +\$(foreach o,${object_suffixes},\$(objpfx)\$(patsubst %,\$p,$file)\$o)): \\" fi echo " \$(..)sysdeps/unix/make-syscalls.sh" @@ -178,55 +236,43 @@ shared-only-routines += $file esac # Append any weak aliases or versions defined for this syscall function. - - # A shortcoming in the current gas is that it will only allow one - # version-alias per symbol. So we create new strong aliases as needed. - vcount="" - - for name in $weak; do - case $name in - *@@*) - base=`echo $name | sed 's/@@.*//'` - ver=`echo $name | sed 's/.*@@//'` - if test -z "$vcount" ; then - source=$strong - vcount=1 - else - source="${strong}_${vcount}" - vcount=`expr $vcount + 1` - echo " echo 'strong_alias ($strong, $source)'; \\" - fi - echo " echo 'default_symbol_version($source, $base, $ver)'; \\" - ;; - *@*) - base=`echo $name | sed 's/@.*//'` - ver=`echo $name | sed 's/.*@//'` - if test -z "$vcount" ; then - source=$strong - vcount=1 - else - source="${strong}_${vcount}" - vcount=`expr $vcount + 1` - echo " echo 'strong_alias ($strong, $source)'; \\" - fi - echo " echo 'symbol_version ($source, $base, $ver)'; \\" - ;; - !*) - name=`echo $name | sed 's/.//'` - echo " echo 'strong_alias ($strong, $name)'; \\" - echo " echo 'libc_hidden_def ($name)'; \\" - ;; - *) - echo " echo 'weak_alias ($strong, $name)'; \\" - echo " echo 'libc_hidden_weak ($name)'; \\" - ;; - esac - done + emit_weak_aliases # And finally, pipe this all into the compiler. echo ' ) | $(compile-syscall) '"\ \$(foreach p,\$(patsubst %$file,%,\$(basename \$(@F))),\$(\$(p)CPPFLAGS))" + if test -n "$vdso_syscall"; then + # In the shared library, we're going to emit an IFUNC using a vDSO function. + # $vdso_syscall looks like "name@KERNEL_X.Y" where "name" is the symbol + # name in the vDSO and KERNEL_X.Y is its symbol version. + vdso_symbol="${vdso_syscall%@*}" + vdso_symver="${vdso_syscall#*@}" + vdso_symver="${vdso_symver//./_}" + echo "\ +\$(foreach p,\$(sysd-rules-targets),\$(objpfx)\$(patsubst %,\$p,$file).os): \\ + \$(..)sysdeps/unix/make-syscalls.sh\ + \$(make-target-directory) + (echo '#include <dl-vdso.h>'; \\ + echo 'extern void *${strong}_ifunc (void) __asm (\"${strong}\");'; \\ + echo 'void *'; \\ + echo '${strong}_ifunc (void)'; \\ + echo '{'; \\ + echo ' PREPARE_VERSION_KNOWN (symver, ${vdso_symver});'; \\ + echo ' return _dl_vdso_vsym (\"${vdso_symbol}\", &symver);'; \\ + echo '}'; \\ + echo 'asm (\".type ${strong}, %gnu_indirect_function\");'; \\" + # This is doing "libc_hidden_def (${strong})", but the compiler + # doesn't know that we've defined ${strong} in the same file, so + # we can't do it the normal way. + echo "\ + echo 'asm (\".globl __GI_${strong}\\n\"'; \\ + echo ' \"__GI_${strong} = ${strong}\");'; \\" + emit_weak_aliases + echo ' ) | $(compile-stdin.c) '"\ +\$(foreach p,\$(patsubst %$file,%,\$(basename \$(@F))),\$(\$(p)CPPFLAGS))" + fi + if test $shared_only = t; then # The versioned symbols are only in the shared library. echo endif diff --git a/sysdeps/unix/syscalls.list b/sysdeps/unix/syscalls.list index 39c40ed7f6..bd780f5695 100644 --- a/sysdeps/unix/syscalls.list +++ b/sysdeps/unix/syscalls.list @@ -26,7 +26,7 @@ getpid - getpid Ei: __getpid getpid getpriority - getpriority i:ii getpriority getrlimit - getrlimit i:ip __getrlimit getrlimit getrusage - getrusage i:ip __getrusage getrusage -gettimeofday - gettimeofday i:PP __gettimeofday gettimeofday __gettimeofday_internal +gettimeofday - gettimeofday i:pP __gettimeofday gettimeofday getuid - getuid Ei: __getuid getuid ioctl - ioctl i:iiI __ioctl ioctl kill - kill i:ii __kill kill diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h index c30671de72..4149bacdce 100644 --- a/sysdeps/unix/sysv/linux/dl-vdso.h +++ b/sysdeps/unix/sysv/linux/dl-vdso.h @@ -33,6 +33,17 @@ /* We don't have a specific file where the symbol can be found. */ \ var.filename = NULL +/* Use this for the known version sets defined below, where we + record their precomputed hash values only once, in this file. */ +#define PREPARE_VERSION_KNOWN(var, vname) \ + PREPARE_VERSION (var, VDSO_NAME_##vname, VDSO_HASH_##vname) + +#define VDSO_NAME_LINUX_2_6 "LINUX_2.6" +#define VDSO_HASH_LINUX_2_6 61765110 +#define VDSO_NAME_LINUX_2_6_15 "LINUX_2.6.15" +#define VDSO_HASH_LINUX_2_6_15 123718565 +#define VDSO_NAME_LINUX_2_6_29 "LINUX_2.6.29" +#define VDSO_HASH_LINUX_2_6_29 123718585 /* Functions for resolving symbols in the VDSO link map. */ extern void *_dl_vdso_vsym (const char *name, diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index b2ef2da973..737613516f 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2005 Free Software Foundation, Inc. +/* Copyright (C) 2005-2012 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 @@ -22,7 +22,6 @@ #include <time.h> #include <hp-timing.h> -#undef __gettimeofday #include <bits/libc-vdso.h> /* Get the current time of day and timezone information, @@ -36,6 +35,6 @@ __gettimeofday (tv, tz) { return INLINE_VSYSCALL (gettimeofday, 2, CHECK_1 (tv), CHECK_1 (tz)); } - -INTDEF (__gettimeofday) +libc_hidden_def (__gettimeofday) weak_alias (__gettimeofday, gettimeofday) +libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/sysv/linux/s390/gettimeofday.c b/sysdeps/unix/sysv/linux/s390/gettimeofday.c index 63faef85b6..efbf1e8110 100644 --- a/sysdeps/unix/sysv/linux/s390/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/s390/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2008 Free Software Foundation, Inc. +/* Copyright (C) 2008-2012 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 @@ -22,7 +22,6 @@ #include <time.h> #include <hp-timing.h> -#undef __gettimeofday #include <bits/libc-vdso.h> /* Get the current time of day and timezone information, @@ -36,6 +35,6 @@ __gettimeofday (tv, tz) { return INLINE_VSYSCALL (gettimeofday, 2, CHECK_1 (tv), CHECK_1 (tz)); } - -INTDEF (__gettimeofday) +libc_hidden_def (__gettimeofday) weak_alias (__gettimeofday, gettimeofday) +libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c index e41fddb297..d52f938e71 100644 --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2007, 2011 Free Software Foundation, Inc. +/* Copyright (C) 2002-2012 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 @@ -15,13 +15,14 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ -#include <dl-vdso.h> +#include <sys/time.h> +#ifdef SHARED -#define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul +# include <dl-vdso.h> +# define VSYSCALL_ADDR_vgettimeofday 0xffffffffff600000ul -#ifdef SHARED void *gettimeofday_ifunc (void) __asm__ ("__gettimeofday"); void * @@ -33,9 +34,16 @@ gettimeofday_ifunc (void) return (_dl_vdso_vsym ("__vdso_gettimeofday", &linux26) ?: (void *) VSYSCALL_ADDR_vgettimeofday); } -__asm (".type __gettimeofday, %gnu_indirect_function"); +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 <sys/time.h> + # include <sysdep.h> # include <errno.h> @@ -44,7 +52,8 @@ __gettimeofday (struct timeval *tv, struct timezone *tz) { return INLINE_SYSCALL (gettimeofday, 2, tv, tz); } -#endif +libc_hidden_def (__gettimeofday) +#endif weak_alias (__gettimeofday, gettimeofday) -strong_alias (__gettimeofday, __gettimeofday_internal) +libc_hidden_weak (gettimeofday) diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list index 7edb6fd618..2cc58af2df 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list @@ -1,6 +1,8 @@ # File name Caller Syscall name # args Strong name Weak names fallocate - fallocate Ci:iiii fallocate fallocate64 +gettimeofday - gettimeofday:__vdso_gettimeofday@LINUX_2.6 i:pP __gettimeofday gettimeofday posix_fadvise - fadvise64 Vi:iiii posix_fadvise posix_fadvise64 preadv - preadv Ci:ipii preadv preadv64 pwritev - pwritev Ci:ipii pwritev pwritev64 +time - time:__vdso_time@LINUX_2.6 Ei:P time diff --git a/time/gettimeofday.c b/time/gettimeofday.c index cfe6549db0..7eb770c2d7 100644 --- a/time/gettimeofday.c +++ b/time/gettimeofday.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1995, 1996, 1997, 2002 Free Software Foundation, Inc. +/* Copyright (C) 1991-2012 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 @@ -18,8 +18,6 @@ #include <errno.h> #include <sys/time.h> -#undef __gettimeofday - /* Get the current time of day and timezone information, putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled. Returns 0 on success, -1 on errors. */ @@ -31,8 +29,9 @@ __gettimeofday (tv, tz) __set_errno (ENOSYS); return -1; } -stub_warning (gettimeofday) - -INTDEF(__gettimeofday) +libc_hidden_def (__gettimeofday) weak_alias (__gettimeofday, gettimeofday) +libc_hidden_weak (gettimeofday) + +stub_warning (gettimeofday) #include <stub-tag.h> |