This is the mail archive of the glibc-cvs@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]

GNU C Library master sources branch, release/2.11/master, updated. glibc-2.11.3-61-g78856c5


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.11/master has been updated
       via  78856c5c73f74d2a850da0a62393dca9dd5a2df4 (commit)
       via  50cb4b00a29d36d99bb36be9b15c78ef5da14305 (commit)
       via  54717475a5f7d0ecc25dfb0cf51d9cf43d4ff8f8 (commit)
       via  7d76befe53d074de0b7a8d78a64a89c57908ec44 (commit)
       via  875703d0957adb972d542cfd174dba9bb95e8321 (commit)
       via  88a97c6e4cedbd71e05008dab220922894ef66da (commit)
       via  82c938203add9de265744987c8f1efa454d80461 (commit)
       via  b77931ad9f5661f23fcb236eac7ec1f8b0c94bff (commit)
       via  9bb6bfdf659cd1a04c5d93282535b8a9e320fc7d (commit)
       via  18852b24dcd132d2aaa3488638ab18c15833730f (commit)
       via  564bc26b7954ca49de2b7f18a88aad03445de2d9 (commit)
       via  d95270c5b52632ec3bc438c852516bda6b1f87d1 (commit)
       via  2363f73c9f88f20303b5dcb0effe1d8036e95f6e (commit)
       via  2d028cbedbf2ed783d31f1873312ad0b9fac4047 (commit)
       via  426cfd73719462d0fedd72d78169218509dae574 (commit)
       via  7b1d92c6439bfeea8b72631a1f3849109a38c909 (commit)
       via  1b31d30e82cf802fa6e31ffa216264b035d339d1 (commit)
       via  8277fdc1cd54428e54e112db7f5be89303951001 (commit)
       via  fea332e16416691310088b5c0e6797694c88352b (commit)
       via  4e43f00fc3df9757f86bc82292e6d4ca7ccd701d (commit)
       via  7d789b1b4d3531172f788d13a76cf7d5a429835e (commit)
       via  c81fb726d822c5c5296c21c9d47c323ce14aa723 (commit)
       via  fa9f66a6f09f3b7234cc24ca3266259a589c3470 (commit)
       via  efdc6bb89a814bacc9601d725565eceb1c3160bc (commit)
       via  6a29825d63f8e6c429c4fe425c3a0ed70a3245cb (commit)
       via  411a9d6b1de462394aabd2a5bf920fde140249ff (commit)
       via  957a75e60be98088738b5b5640164e8dfffc4f4e (commit)
       via  a02af4f1aedc6e1db180b9568d85e6d40d8fb1f6 (commit)
       via  522cb50e61c109d41df4dbc366312a133e248dca (commit)
       via  ad78094bcb15b4d36ae46da568bbdf29276912b6 (commit)
       via  21eddf8cffb9764fcc280e9d6b52669534c026ba (commit)
       via  a4fd88c0fcf4e51825a540820bc9a95081f4f9fb (commit)
       via  c55cc45ed76603b380489ee8c91ab5dce92e92f1 (commit)
       via  758c66a2344d9c88f320e180d785f214f77f9943 (commit)
       via  44092c71f67e4dbf9c56c7a7aff06bd7e81446b0 (commit)
      from  b72646ad0c414b7e81540de0a72945cd1c858668 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=78856c5c73f74d2a850da0a62393dca9dd5a2df4

commit 78856c5c73f74d2a850da0a62393dca9dd5a2df4
Author: H.J. Lu <hongjiu.lu@intel.com>
Date:   Wed May 18 19:50:48 2011 -0400

    Fix typo in x86-64 powl
    
    (cherry picked from commit 8db736347c7aca3201f61e3f05b5f672bcdd5bd9)

diff --git a/ChangeLog b/ChangeLog
index 1dbb176..0f2a92b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-17  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #12775]
+	* sysdeps/x86_64/fpu/e_powl.S: Fix a typo.
+	* math/Makefile (tests): Add test-powl.
+	(CFLAGS-test-powl.c): Define.
+	* math/test-powl.c: New file.
+
 2011-05-16  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12766]
diff --git a/math/Makefile b/math/Makefile
index 7e3a626..45954e2 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -90,7 +90,8 @@ distribute += $(filter-out $(generated),$(long-m-yes:=.c) $(long-c-yes:=.c))
 # Rules for the test suite.
 tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
 	test-misc test-fpucw tst-definitions test-tgmath test-tgmath-ret \
-	bug-nextafter bug-nexttoward bug-tgmath1 test-tgmath-int test-tgmath2
+	bug-nextafter bug-nexttoward bug-tgmath1 test-tgmath-int \
+	test-tgmath2 test-powl
 # We do the `long double' tests only if this data type is available and
 # distinct from `double'.
 test-longdouble-yes = test-ldouble test-ildoubl
@@ -131,6 +132,7 @@ CFLAGS-test-ldouble.c = -fno-inline -ffloat-store -fno-builtin
 CFLAGS-test-tgmath.c = -fno-builtin
 CFLAGS-test-tgmath2.c = -fno-builtin
 CFLAGS-test-tgmath-ret.c = -fno-builtin
+CFLAGS-test-powl.c = -fno-builtin
 CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
 			 -DTEST_FAST_MATH -fno-builtin
 CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
diff --git a/math/test-powl.c b/math/test-powl.c
new file mode 100644
index 0000000..c464d78
--- /dev/null
+++ b/math/test-powl.c
@@ -0,0 +1,51 @@
+/* Test for powl
+   Copyright (C) 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 <stdio.h>
+#include <math.h>
+#include <float.h>
+#include <ieee754.h>
+
+int
+main (void)
+{
+  int result = 0;
+
+#ifndef NO_LONG_DOUBLE
+# if LDBL_MANT_DIG == 64
+    {
+      long double x = 1e-20;
+      union ieee854_long_double u;
+      u.ieee.mantissa0 = 1;
+      u.ieee.mantissa1 = 1;
+      u.ieee.exponent = 0;
+      u.ieee.negative = 0;
+      (void) powl (0.2, u.d);
+      x = powl (x, 1.5);
+      if (fabsl (x - 1e-30) > 1e-10)
+	{
+	  printf ("powl (1e-20, 1.5): wrong result: %Lg\n", x);
+	  result = 1;
+	}
+    }
+# endif
+#endif
+
+  return result;
+}
diff --git a/sysdeps/x86_64/fpu/e_powl.S b/sysdeps/x86_64/fpu/e_powl.S
index 4959bea..a0b1b1d 100644
--- a/sysdeps/x86_64/fpu/e_powl.S
+++ b/sysdeps/x86_64/fpu/e_powl.S
@@ -1,5 +1,5 @@
 /* ix87 specific implementation of pow function.
-   Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 2007
+   Copyright (C) 1996, 1997, 1998, 1999, 2001, 2004, 2007, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -154,7 +154,7 @@ ENTRY(__ieee754_powl)
 	fucompp			// 1.0 : x : y
 	fnstsw
 	fxch			// x : 1.0 : y
-	test	$4500,%eax
+	test	$0x4500,%eax
 	jz	7f
 	fsub	%st(1)		// x-1 : 1.0 : y
 	fyl2xp1			// log2(x) : y

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=50cb4b00a29d36d99bb36be9b15c78ef5da14305

commit 50cb4b00a29d36d99bb36be9b15c78ef5da14305
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Mon May 16 14:10:36 2011 +0100

    Fix test for error_one_per_line mode in error
    
    (cherry picked from commit 15cc7dd182a6be79cbb01a5de4f13e958717bd69)

diff --git a/ChangeLog b/ChangeLog
index 0609c91..1dbb176 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-05-16  Ulrich Drepper  <drepper@gmail.com>
 
+	[BZ #12766]
+	* misc/error.c (error_at_line): Ensure file_name and old_file_name
+	point to strings before performing equality test for error_one_per_line
+	mode.
+
 	[BZ #11697]
 	* login/programs/pt_chown.c (do_pt_chown): Always call chown.
 
diff --git a/misc/error.c b/misc/error.c
index 85d1cff..9a73a61 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -1,5 +1,5 @@
 /* Error handler for noninteractive utilities
-   Copyright (C) 1990-1998, 2000-2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1990-1998, 2000-2006, 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
@@ -272,7 +272,9 @@ error_at_line (int status, int errnum, const char *file_name,
 
       if (old_line_number == line_number
 	  && (file_name == old_file_name
-	      || strcmp (old_file_name, file_name) == 0))
+	      || (old_file_name != NULL
+		  && file_name != NULL
+		  && strcmp (old_file_name, file_name) == 0)))
 	/* Simply return and print nothing.  */
 	return;
 

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=54717475a5f7d0ecc25dfb0cf51d9cf43d4ff8f8

commit 54717475a5f7d0ecc25dfb0cf51d9cf43d4ff8f8
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Mon May 16 06:43:56 2011 +0100

    Remove shortcut for call of chown
    
    The UID might differ, too.  Just call chown unconditionally.
    
    (cherry picked from commit f3799213a3ee8265ba47fad33d9cff71d97ab0d4)

diff --git a/ChangeLog b/ChangeLog
index 884b21e..0609c91 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-16  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #11697]
+	* login/programs/pt_chown.c (do_pt_chown): Always call chown.
+
 2011-05-14  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12083]
diff --git a/login/programs/pt_chown.c b/login/programs/pt_chown.c
index 4c36f2ce..9aa34e7 100644
--- a/login/programs/pt_chown.c
+++ b/login/programs/pt_chown.c
@@ -64,7 +64,7 @@ print_version (FILE *stream, struct argp_state *state)
 Copyright (C) %s Free Software Foundation, Inc.\n\
 This is free software; see the source for copying conditions.  There is NO\n\
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
-"), "1999");
+"), "2011");
 }
 
 static char *
@@ -123,7 +123,7 @@ do_pt_chown (void)
 
   /* Set the owner to the real user ID, and the group to that special
      group ID.  */
-  if (st.st_gid != gid && chown (pty, getuid (), gid) < 0)
+  if (chown (pty, getuid (), gid) < 0)
     return FAIL_EACCES;
 
   /* Set the permission mode to readable and writable by the owner,

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7d76befe53d074de0b7a8d78a64a89c57908ec44

commit 7d76befe53d074de0b7a8d78a64a89c57908ec44
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun May 15 00:30:37 2011 +0100

    Fix initialization of optimization values for AIO
    
    (cherry picked from commit 2fc54d6f9f7d6770ecb0e0bb5a3b977965bfe273)

diff --git a/ChangeLog b/ChangeLog
index 8fcbbbb..884b21e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-05-14  Ulrich Drepper  <drepper@gmail.com>
 
+	[BZ #12083]
+	* sysdeps/pthread/aio_misc.c (__aio_init): Compute optim.aio_num
+	correctly.
+
 	* libio/fileops.c (_IO_new_file_close_it): Initialize write_status.
 
 	* iconv/loop.c (SINGLE) [STORE_REST]: Add input bytes to bytebuf before
diff --git a/sysdeps/pthread/aio_misc.c b/sysdeps/pthread/aio_misc.c
index c82acbb..ca3d111 100644
--- a/sysdeps/pthread/aio_misc.c
+++ b/sysdeps/pthread/aio_misc.c
@@ -1,5 +1,5 @@
 /* Handle general operations.
-   Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2006, 2007, 2009
+   Copyright (C) 1997-2001, 2003, 2004, 2006, 2007, 2009, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -26,6 +26,7 @@
 #include <pthread.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <aio_misc.h>
@@ -87,7 +88,7 @@ static int idle_thread_count;
 static struct aioinit optim =
 {
   20,	/* int aio_threads;	Maximal number of threads.  */
-  64,	/* int aio_num;		Number of expected simultanious requests. */
+  64,	/* int aio_num;		Number of expected simultaneous requests. */
   0,
   0,
   0,
@@ -282,9 +283,10 @@ __aio_init (const struct aioinit *init)
   if (pool == NULL)
     {
       optim.aio_threads = init->aio_threads < 1 ? 1 : init->aio_threads;
+      assert (powerof2 (ENTRIES_PER_ROW));
       optim.aio_num = (init->aio_num < ENTRIES_PER_ROW
 		       ? ENTRIES_PER_ROW
-		       : init->aio_num & ~ENTRIES_PER_ROW);
+		       : init->aio_num & ~(ENTRIES_PER_ROW - 1));
     }
 
   if (init->aio_idle_time != 0)

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=875703d0957adb972d542cfd174dba9bb95e8321

commit 875703d0957adb972d542cfd174dba9bb95e8321
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat May 14 15:59:54 2011 +0100

    Initialize variable in _IO_new_file_close_it
    
    The last change left a variable in some situations uninitialized.
    
    (cherry picked from commit ca408c157c71edebf45862c35738eb2614cbcd77)

diff --git a/ChangeLog b/ChangeLog
index 3f05f09..8fcbbbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,10 @@
 2011-05-14  Ulrich Drepper  <drepper@gmail.com>
 
+	* libio/fileops.c (_IO_new_file_close_it): Initialize write_status.
+
 	* iconv/loop.c (SINGLE) [STORE_REST]: Add input bytes to bytebuf before
-	storing incomplete byte sequence in state object.
+	storing incomplete byte sequence in state object.  Avoid testing for
+	guaranteed too small input if we know there is enough data available.
 
 2011-05-13  Ulrich Drepper  <drepper@gmail.com>
 
diff --git a/libio/fileops.c b/libio/fileops.c
index adf4cfa..66c17df 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -175,6 +175,8 @@ _IO_new_file_close_it (fp)
       else
 	write_status = _IO_SYSSEEK (fp, o, SEEK_SET) < 0 ? EOF : 0;
     }
+  else
+    write_status = 0;
 
   INTUSE(_IO_unsave_markers) (fp);
 

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=88a97c6e4cedbd71e05008dab220922894ef66da

commit 88a97c6e4cedbd71e05008dab220922894ef66da
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat May 14 00:53:21 2011 -0400

    Fix handling of incomplete character storage in state
    
    If iconv is called more than once in a row for adding bytes to the sequence
    while still remain under the minimum size of a character and if STORE_REST
    is defined, we didn't consume any input.  Fix that.
    
    (cherry picked from commit 1af4e29837e9969377781b47254b6e4c293353ed)

diff --git a/ChangeLog b/ChangeLog
index 221f8a9..3f05f09 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-14  Ulrich Drepper  <drepper@gmail.com>
+
+	* iconv/loop.c (SINGLE) [STORE_REST]: Add input bytes to bytebuf before
+	storing incomplete byte sequence in state object.
+
 2011-05-13  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12724]
diff --git a/iconv/loop.c b/iconv/loop.c
index da11bc2..72fef94 100644
--- a/iconv/loop.c
+++ b/iconv/loop.c
@@ -1,5 +1,5 @@
 /* Conversion loop frame work.
-   Copyright (C) 1998-2002, 2003, 2005, 2008 Free Software Foundation, Inc.
+   Copyright (C) 1998-2003, 2005, 2008, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -399,6 +399,9 @@ SINGLE(LOOPFCT) (struct __gconv_step *step,
     {
       *inptrp = inend;
 #ifdef STORE_REST
+      while (inptr < inend)
+	bytebuf[inlen++] = *inptr++;
+
       inptr = bytebuf;
       inptrp = &inptr;
       inend = &bytebuf[inlen];

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=82c938203add9de265744987c8f1efa454d80461

commit 82c938203add9de265744987c8f1efa454d80461
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat May 14 02:08:45 2011 +0100

    Fix file descriptor position after fclose
    
    fclose should leave the file descriptor position after the last read
    or written byte.
    
    (cherry picked from commit fcabc0f8b185f9e0a9289720be5ede6c39b3bf21)

diff --git a/ChangeLog b/ChangeLog
index 5077269..221f8a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-05-13  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12724]
+	* libio/fileops.c (_IO_new_file_close_it): Always flush when
+	currently writing and seek to current position when not.
+	* libio/Makefile (tests): Add bug-fclose1.
+	* libio/bug-fclose1.c: New file.
+
 2011-05-12  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12511]
diff --git a/libio/Makefile b/libio/Makefile
index 83b9458..ec30904 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1995-2004,2006,2007,2008,2009 Free Software Foundation, Inc.
+# Copyright (C) 1995-2004,2006-2009,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
@@ -58,7 +58,7 @@ tests = tst_swprintf tst_wprintf tst_swscanf tst_wscanf tst_getwc tst_putwc   \
 	tst-memstream1 tst-memstream2 \
 	tst-wmemstream1 tst-wmemstream2 \
 	bug-memstream1 bug-wmemstream1 \
-	tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos
+	tst-setvbuf1 tst-popen1 tst-fgetwc bug-wsetpos bug-fclose1
 test-srcs = test-freopen
 
 all: # Make this the default target; it will be defined in Rules.
diff --git a/libio/bug-fclose1.c b/libio/bug-fclose1.c
new file mode 100644
index 0000000..f1e09f5
--- /dev/null
+++ b/libio/bug-fclose1.c
@@ -0,0 +1,132 @@
+// BZ #12724
+
+static void do_prepare (void);
+#define PREPARE(argc, argv) do_prepare ()
+static int do_test (void);
+#define TEST_FUNCTION do_test()
+#include "../test-skeleton.c"
+
+
+static int fd;
+
+
+static void
+do_prepare (void)
+{
+  fd = create_temp_file ("bug-fclose1.", NULL);
+  if (fd == -1)
+    {
+      printf ("cannot create temporary file: %m\n");
+      exit (1);
+    }
+}
+
+
+static int
+do_test (void)
+{
+  static const char pattern[] = "hello world";
+
+  /* Prepare a seekable file.  */
+  if (write (fd, pattern, sizeof pattern) != sizeof pattern)
+    {
+      printf ("cannot write pattern: %m\n");
+      return 1;
+    }
+  if (lseek (fd, 1, SEEK_SET) != 1)
+    {
+      printf ("cannot seek after write: %m\n");
+      return 1;
+    }
+
+  /* Create an output stream visiting the file; when it is closed, all
+     other file descriptors visiting the file must see the new file
+     position.  */
+  int fd2 = dup (fd);
+  if (fd2 < 0)
+    {
+      printf ("cannot duplicate descriptor for writing: %m\n");
+      return 1;
+    }
+  FILE *f = fdopen (fd2, "w");
+  if (f == NULL)
+    {
+      printf ("first fdopen failed: %m\n");
+      return 1;
+    }
+  if (fputc (pattern[1], f) != pattern[1])
+    {
+      printf ("fputc failed: %m\n");
+      return 1;
+    }
+  if (fclose (f) != 0)
+    {
+      printf ("first fclose failed: %m\n");
+      return 1;
+    }
+  errno = 0;
+  if (lseek (fd2, 0, SEEK_CUR) != -1)
+    {
+      printf ("lseek after fclose after write did not fail\n");
+      return 1;
+    }
+  if (errno != EBADF)
+    {
+      printf ("lseek after fclose after write did not fail with EBADF: %m\n");
+      return 1;
+    }
+  off_t o = lseek (fd, 0, SEEK_CUR);
+  if (o != 2)
+    {
+      printf ("\
+lseek on original descriptor after first fclose returned %ld, expected 2\n",
+	      (long int) o);
+      return 1;
+    }
+
+  /* Likewise for an input stream.  */
+  fd2 = dup (fd);
+  if (fd2 < 0)
+     {
+      printf ("cannot duplicate descriptor for reading: %m\n");
+      return 1;
+    }
+  f = fdopen (fd2, "r");
+   if (f == NULL)
+    {
+      printf ("second fdopen failed: %m\n");
+      return 1;
+    }
+   char c = fgetc (f);
+   if (c != pattern[2])
+     {
+       printf ("getc returned %c, expected %c\n", c, pattern[2]);
+       return 1;
+     }
+  if (fclose (f) != 0)
+    {
+      printf ("second fclose failed: %m\n");
+      return 1;
+    }
+  errno = 0;
+  if (lseek (fd2, 0, SEEK_CUR) != -1)
+    {
+      printf ("lseek after fclose after read did not fail\n");
+      return 1;
+    }
+  if (errno != EBADF)
+    {
+      printf ("lseek after fclose after read did not fail with EBADF: %m\n");
+      return 1;
+    }
+  o = lseek (fd, 0, SEEK_CUR);
+  if (o != 3)
+    {
+      printf ("\
+lseek on original descriptor after second fclose returned %ld, expected 3\n",
+	      (long int) o);
+      return 1;
+    }
+
+  return 0;
+}
diff --git a/libio/fileops.c b/libio/fileops.c
index 1e7ef07..adf4cfa 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -160,19 +160,25 @@ int
 _IO_new_file_close_it (fp)
      _IO_FILE *fp;
 {
-  int write_status, close_status;
   if (!_IO_file_is_open (fp))
     return EOF;
 
-  if ((fp->_flags & _IO_NO_WRITES) == 0
-      && (fp->_flags & _IO_CURRENTLY_PUTTING) != 0)
+  int write_status;
+  if (_IO_in_put_mode (fp))
     write_status = _IO_do_flush (fp);
-  else
-    write_status = 0;
+  else if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
+	   && !_IO_in_backup (fp))
+    {
+      off64_t o = _IO_SEEKOFF (fp, 0, _IO_seek_cur, 0);
+      if (o == WEOF)
+	write_status = EOF;
+      else
+	write_status = _IO_SYSSEEK (fp, o, SEEK_SET) < 0 ? EOF : 0;
+    }
 
   INTUSE(_IO_unsave_markers) (fp);
 
-  close_status = _IO_SYSCLOSE (fp);
+  int close_status = _IO_SYSCLOSE (fp);
 
   /* Free buffer. */
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=b77931ad9f5661f23fcb236eac7ec1f8b0c94bff

commit b77931ad9f5661f23fcb236eac7ec1f8b0c94bff
Author: Piotr Bury <pbury@goahead.com>
Date:   Fri May 13 02:59:09 2011 +0100

    Fix resizing able for unique symbols when adding symbol for copy relocation
    
    (cherry picked from commit 320a5dc07b907b1e640fd11ce49a04aa2b367711)

diff --git a/ChangeLog b/ChangeLog
index 5a63842..5077269 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-05-12  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12511]
+	* elf/dl-lookup.c (enter): Don't test for copy relocation here and
+	don't set DF_1_NODELETE here.
+	(do_lookup_x): When entering new entry test for copy relocation
+	and if necessary set DF_1_NODELETE flag.
+	Patch by Piotr Bury <pbury@goahead.com>.
+
 2011-05-11  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12052]
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 0a7b94b..8f37cac 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -312,39 +312,21 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
 		 definition we have to use it.  */
 	      void enter (struct unique_sym *table, size_t size,
 			  unsigned int hash, const char *name,
-			  const ElfW(Sym) *sym, struct link_map *map)
+			  const ElfW(Sym) *sym, const struct link_map *map)
 	      {
 		size_t idx = hash % size;
 		size_t hash2 = 1 + hash % (size - 2);
-		while (1)
+		while (table[idx].name != NULL)
 		  {
-		    if (table[idx].name == NULL)
-		      {
-			table[idx].hashval = hash;
-			table[idx].name = name;
-			if ((type_class & ELF_RTYPE_CLASS_COPY) != 0)
-			  {
-			    table[idx].sym = ref;
-			    table[idx].map = undef_map;
-			  }
-			else
-			  {
-			    table[idx].sym = sym;
-			    table[idx].map = map;
-
-			    if (map->l_type == lt_loaded)
-			      /* Make sure we don't unload this object by
-				 setting the appropriate flag.  */
-			      map->l_flags_1 |= DF_1_NODELETE;
-			  }
-
-			return;
-		      }
-
 		    idx += hash2;
 		    if (idx >= size)
 		      idx -= size;
 		  }
+
+		table[idx].hashval = hash;
+		table[idx].name = name;
+		table[idx].sym = sym;
+		table[idx].map = map;
 	      }
 
 	      struct unique_sym_table *tab
@@ -436,8 +418,19 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
 		  tab->free = free;
 		}
 
-	      enter (entries, size, new_hash, strtab + sym->st_name, sym,
-		     (struct link_map *) map);
+	      if ((type_class & ELF_RTYPE_CLASS_COPY) != 0)
+		enter (entries, size, new_hash, strtab + sym->st_name, ref,
+		       undef_map);
+	      else
+		{
+		  enter (entries, size, new_hash, strtab + sym->st_name, sym,
+			 map);
+
+		  if (map->l_type == lt_loaded)
+		    /* Make sure we don't unload this object by
+		       setting the appropriate flag.  */
+		    ((struct link_map *) map)->l_flags_1 |= DF_1_NODELETE;
+		}
 	      ++tab->n_elements;
 
 	      __rtld_lock_unlock_recursive (tab->lock);

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=9bb6bfdf659cd1a04c5d93282535b8a9e320fc7d

commit 9bb6bfdf659cd1a04c5d93282535b8a9e320fc7d
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Thu May 12 04:58:02 2011 +0100

    Fix sched_setscheduler call in spawn implementation
    
    (cherry picked from commit f574184a0e4b6ed69a5d9a3234543fba6d2a7367)

diff --git a/ChangeLog b/ChangeLog
index ad835e6..5a63842 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-05-11  Ulrich Drepper  <drepper@gmail.com>
 
+	[BZ #12052]
+	* sysdeps/posix/spawni.c (__spawni): Fix sched_setscheduler call.
+
 	[BZ #12625]
 	* misc/mntent_r.c (addmntent): Flush the stream after the output
 
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index 29803a8..1c50f8e 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -142,9 +142,7 @@ __spawni (pid_t *pid, const char *file,
     }
   else if ((flags & POSIX_SPAWN_SETSCHEDULER) != 0)
     {
-      if (__sched_setscheduler (0, attrp->__policy,
-				(flags & POSIX_SPAWN_SETSCHEDPARAM) != 0
-				? &attrp->__sp : NULL) == -1)
+      if (__sched_setscheduler (0, attrp->__policy, &attrp->__sp) == -1)
 	_exit (SPAWN_ERROR);
     }
 #endif

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=18852b24dcd132d2aaa3488638ab18c15833730f

commit 18852b24dcd132d2aaa3488638ab18c15833730f
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Thu May 12 04:37:25 2011 +0100

    Report write error  in addmnt even for cached streams.
    
    (cherry picked from commit e1fb097f447a89aa69a926e45e673a52d86a6c57)

diff --git a/ChangeLog b/ChangeLog
index 20a0c49..ad835e6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-05-11  Ulrich Drepper  <drepper@gmail.com>
 
+	[BZ #12625]
+	* misc/mntent_r.c (addmntent): Flush the stream after the output
+
 	[BZ #12393]
 	* elf/dl-load.c (is_trusted_path): Remove unnecessary test.
 	(is_trusted_path_normalize): Skip initial colon.  Append slash
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index 9598528..6959f0e 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -1,5 +1,5 @@
 /* Utilities for reading/writing fstab, mtab, etc.
-   Copyright (C) 1995-2000, 2001, 2002, 2003, 2006, 2010
+   Copyright (C) 1995-2000, 2001, 2002, 2003, 2006, 2010, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -263,8 +263,8 @@ __addmntent (FILE *stream, const struct mntent *mnt)
 		   mntcopy.mnt_type,
 		   mntcopy.mnt_opts,
 		   mntcopy.mnt_freq,
-		   mntcopy.mnt_passno)
-	  < 0 ? 1 : 0);
+		   mntcopy.mnt_passno) < 0
+	  || fflush (stream) != 0);
 }
 weak_alias (__addmntent, addmntent)
 

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=564bc26b7954ca49de2b7f18a88aad03445de2d9

commit 564bc26b7954ca49de2b7f18a88aad03445de2d9
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Wed May 11 23:23:24 2011 +0100

    Translate kernel error into what pthread_create should return
    
    (cherry picked from commit 5bdcc10322c488f53557440acf71623d8b313ab5)

diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index d7dc113..ae6a121 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-11  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #386]
+	* allocatestack.c (allocate_stack): Convert ENOMEM error to EAGAIN.
+
 2011-04-10  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12650]
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 550a8be..81c8333 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -628,7 +628,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
 	    {
 	      int err;
 	    mprot_error:
-	      err = errno;
+	      err = errno == ENOMEM ? EAGAIN : errno;
 
 	      lll_lock (stack_cache_lock, LLL_PRIVATE);
 

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d95270c5b52632ec3bc438c852516bda6b1f87d1

commit d95270c5b52632ec3bc438c852516bda6b1f87d1
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Wed May 11 00:15:38 2011 -0400

    Fix up testing for valid $ORIGIN use
    
    (cherry picked from commit 22836f52e3e4740e450f9b93a2f1e31a90b168a6)

diff --git a/ChangeLog b/ChangeLog
index f3ed880..20a0c49 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-05-11  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12393]
+	* elf/dl-load.c (is_trusted_path): Remove unnecessary test.
+	(is_trusted_path_normalize): Skip initial colon.  Append slash
+	to empty buffer.  Duplicate is_trusted_path code but allow
+	constructed patch to be prefix.
+	(is_dst): Allow $ORIGIN followed by /.
+	(_dl_dst_substitute): Correct clearing of check_for_trusted.
+	Correct testing of result of is_trusted_path_normalize
+	(decompose_rpath): Fix warning.
+
 2011-05-07  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12734]
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 1630d71..aa525f3 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -171,10 +171,6 @@ local_strdup (const char *s)
 static bool
 is_trusted_path (const char *path, size_t len)
 {
-  /* All trusted directories must be complete names.  */
-  if (path[0] != '/')
-    return false;
-
   const char *trun = system_dirs;
 
   for (size_t idx = 0; idx < nsystem_dirs_len; ++idx)
@@ -193,9 +189,17 @@ is_trusted_path (const char *path, size_t len)
 static bool
 is_trusted_path_normalize (const char *path, size_t len)
 {
+  if (len == 0)
+    return false;
+
+  if (*path == ':')
+    {
+      ++path;
+      --len;
+    }
+
   char *npath = (char *) alloca (len + 2);
   char *wnp = npath;
-
   while (*path != '\0')
     {
       if (path[0] == '/')
@@ -225,11 +229,23 @@ is_trusted_path_normalize (const char *path, size_t len)
 
       *wnp++ = *path++;
     }
-  if (wnp > npath && wnp[-1] != '/')
+
+  if (wnp == npath || wnp[-1] != '/')
     *wnp++ = '/';
-  *wnp = '\0';
 
-  return is_trusted_path (npath, wnp - npath);
+  const char *trun = system_dirs;
+
+  for (size_t idx = 0; idx < nsystem_dirs_len; ++idx)
+    {
+      if (wnp - npath >= system_dirs_len[idx]
+	  && memcmp (trun, npath, system_dirs_len[idx]) == 0)
+	/* Found it.  */
+	return true;
+
+      trun += system_dirs_len[idx] + 1;
+    }
+
+  return false;
 }
 
 
@@ -265,7 +281,8 @@ is_dst (const char *start, const char *name, const char *str,
     return 0;
 
   if (__builtin_expect (secure, 0)
-      && ((name[len] != '\0' && (!is_path || name[len] != ':'))
+      && ((name[len] != '\0' && name[len] != '/'
+	   && (!is_path || name[len] != ':'))
 	  || (name != start + 1 && (!is_path || name[-2] != ':'))))
     return 0;
 
@@ -371,13 +388,12 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 		 normalized path must be rooted in one of the trusted
 		 directories.  */
 	      if (__builtin_expect (check_for_trusted, false)
-		  && is_trusted_path_normalize (last_elem, wp - last_elem))
-		{
-		  wp = last_elem;
-		  check_for_trusted = false;
-		}
+		  && !is_trusted_path_normalize (last_elem, wp - last_elem))
+		wp = last_elem;
 	      else
 		last_elem = wp;
+
+	      check_for_trusted = false;
 	    }
 	}
     }
@@ -386,7 +402,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
   /* In SUID/SGID programs, after $ORIGIN expansion the normalized
      path must be rooted in one of the trusted directories.  */
   if (__builtin_expect (check_for_trusted, false)
-      && is_trusted_path_normalize (last_elem, wp - last_elem))
+      && !is_trusted_path_normalize (last_elem, wp - last_elem))
     wp = last_elem;
 
   *wp = '\0';
@@ -628,7 +644,7 @@ decompose_rpath (struct r_search_path_struct *sps,
   if (*copy == 0)
     {
       free (copy);
-      sps->dirs = (char *) -1;
+      sps->dirs = (struct r_search_path_elem **) -1;
       return false;
     }
 

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2363f73c9f88f20303b5dcb0effe1d8036e95f6e

commit 2363f73c9f88f20303b5dcb0effe1d8036e95f6e
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat May 7 18:05:19 2011 +0100

    Backport BIND code to query name as TLD.
    
    (cherry picked from commit f87dfb1f11c01f2ccdc40d81e134cd06b32e28e8)

diff --git a/ChangeLog b/ChangeLog
index e6529a6..f3ed880 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-05-07  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12734]
+	* resolv/resolv.h: Define RES_NOTLDQUERY.
+	* resolv/res_init.c (res_setoptions): Recognize no_tld_query and
+	no-tld-query and set RES_NOTLDQUERY.
+	* resolv/res_debug.c (p_option): Handle RES_NOTLDQUERY.
+	* resolv/res_query.c (__libc_res_nsearch): Backport changes from
+	modern BIND to search name as TLD unless forbidden.
+
 2011-05-07  Petr Baudis  <pasky@suse.cz>
 	    Ulrich Drepper  <drepper@gmail.com>
 
diff --git a/resolv/res_debug.c b/resolv/res_debug.c
index f7996a7..3daa44e 100644
--- a/resolv/res_debug.c
+++ b/resolv/res_debug.c
@@ -189,7 +189,7 @@ do_section(const res_state statp,
 						buf = malloc(buflen += 1024);
 					if (buf == NULL) {
 						fprintf(file,
-				              ";; memory allocation failure\n");
+					      ";; memory allocation failure\n");
 					      return;
 					}
 					continue;
@@ -356,7 +356,7 @@ const struct res_sym __p_class_syms[] = {
 	{C_HS,		"HESIOD"},
 	{C_ANY,		"ANY"},
 	{C_NONE,	"NONE"},
-	{C_IN, 		(char *)0}
+	{C_IN,		(char *)0}
 };
 libresolv_hidden_data_def (__p_class_syms)
 
@@ -588,6 +588,7 @@ p_option(u_long option) {
 	case RES_USEBSTRING:	return "ip6-bytstring";
 	case RES_USE_EDNS0:	return "edns0";
 	case RES_USE_DNSSEC:	return "dnssec";
+	case RES_NOTLDQUERY:	return "no-tld-query";
 				/* XXX nonreentrant */
 	default:		sprintf(nbuf, "?0x%lx?", (u_long)option);
 				return (nbuf);
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 74715f3..7588432 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -545,6 +545,11 @@ res_setoptions(res_state statp, const char *options, const char *source) {
 		} else if (!strncmp(cp, "single-request",
 				    sizeof("single-request") - 1)) {
 			statp->options |= RES_SNGLKUP;
+		} else if (!strncmp(cp, "no_tld_query",
+				    sizeof("no_tld_query") - 1) ||
+			   !strncmp(cp, "no-tld-query",
+				    sizeof("no-tld-query") - 1)) {
+			statp->options |= RES_NOTLDQUERY;
 		} else {
 			/* XXX - print a warning here? */
 		}
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 5ff352e..26daf0d 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -123,7 +123,7 @@ __libc_res_nquery(res_state statp,
 {
 	HEADER *hp = (HEADER *) answer;
 	int n, use_malloc = 0;
-        u_int oflags = statp->_flags;
+	u_int oflags = statp->_flags;
 
 	size_t bufsize = (type == T_UNSPEC ? 2 : 1) * QUERYSIZE;
 	u_char *buf = alloca (bufsize);
@@ -210,7 +210,7 @@ __libc_res_nquery(res_state statp,
 			if (statp->options & RES_DEBUG)
 				printf(";; res_nquery: retry without EDNS0\n");
 #endif
-                        goto again;
+			goto again;
 		}
 #ifdef DEBUG
 		if (statp->options & RES_DEBUG)
@@ -344,6 +344,7 @@ __libc_res_nsearch(res_state statp,
 	int trailing_dot, ret, saved_herrno;
 	int got_nodata = 0, got_servfail = 0, root_on_list = 0;
 	int tried_as_is = 0;
+	int searched = 0;
 
 	__set_errno (0);
 	RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);  /* True if we never query. */
@@ -406,6 +407,7 @@ __libc_res_nsearch(res_state statp,
 		for (domain = (const char * const *)statp->dnsrch;
 		     *domain && !done;
 		     domain++) {
+			searched = 1;
 
 			if (domain[0][0] == '\0' ||
 			    (domain[0][0] == '.' && domain[0][1] == '\0'))
@@ -477,11 +479,11 @@ __libc_res_nsearch(res_state statp,
 	}
 
 	/*
-	 * If the name has any dots at all, and no earlier 'as-is' query
-	 * for the name, and "." is not on the search list, then try an as-is
-	 * query now.
+	 * f the query has not already been tried as is then try it
+	 * unless RES_NOTLDQUERY is set and there were no dots.
 	 */
-	if (dots && !(tried_as_is || root_on_list)) {
+	if ((dots || !searched || (statp->options & RES_NOTLDQUERY) == 0)
+	    && !(tried_as_is || root_on_list)) {
 		ret = __libc_res_nquerydomain(statp, name, NULL, class, type,
 					      answer, anslen, answerp,
 					      answerp2, nanswerp2, resplen2);
diff --git a/resolv/resolv.h b/resolv/resolv.h
index e49c29d..ed15a70 100644
--- a/resolv/resolv.h
+++ b/resolv/resolv.h
@@ -102,7 +102,7 @@ typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *__ns,
 # define RES_MAXTIME		65535	/* Infinity, in milliseconds. */
 
 struct __res_state {
-	int	retrans;	 	/* retransmition time interval */
+	int	retrans;		/* retransmition time interval */
 	int	retry;			/* number of times to retransmit */
 	u_long	options;		/* option flags - see below. */
 	int	nscount;		/* number of name servers */
@@ -219,6 +219,8 @@ struct res_sym {
 #define RES_SNGLKUPREOP	0x00400000	/* -"-, but open new socket for each
 					   request */
 #define RES_USE_DNSSEC	0x00800000	/* use DNSSEC using OK bit in OPT */
+#define RES_NOTLDQUERY	0x01000000	/* Do not look up unqualified name
+					   as a TLD.  */
 
 #define RES_DEFAULT	(RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
 

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2d028cbedbf2ed783d31f1873312ad0b9fac4047

commit 2d028cbedbf2ed783d31f1873312ad0b9fac4047
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sat May 7 16:44:26 2011 +0100

    Allow $ORIGIN to reference trusted directoreis in SUID binaries.
    
    (cherry picked from commit 47c3cd7a74e8c089d60d603afce6d9cf661178d6)

diff --git a/ChangeLog b/ChangeLog
index e3875af..e6529a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-05-07  Petr Baudis  <pasky@suse.cz>
+	    Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12393]
+	* elf/dl-load.c (fillin_rpath): Move trusted path check...
+	(is_trusted_path): ...to here.
+	(is_norm_trusted_path): Add wrapper for /../ and /./ normalization.
+	(_dl_dst_substitute): Verify expanded $ORIGIN path elements
+	using is_norm_trusted_path() in setuid scripts.
+
 2011-05-03  Andreas Schwab  <schwab@redhat.com>
 
 	* elf/ldconfig.c (add_dir): Don't crash on empty path.
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 2993aa9..1630d71 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1,5 +1,5 @@
 /* Map in a shared object's segments from the file.
-   Copyright (C) 1995-2005, 2006, 2007, 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1995-2007, 2009, 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
@@ -168,6 +168,71 @@ local_strdup (const char *s)
 }
 
 
+static bool
+is_trusted_path (const char *path, size_t len)
+{
+  /* All trusted directories must be complete names.  */
+  if (path[0] != '/')
+    return false;
+
+  const char *trun = system_dirs;
+
+  for (size_t idx = 0; idx < nsystem_dirs_len; ++idx)
+    {
+      if (len == system_dirs_len[idx] && memcmp (trun, path, len) == 0)
+	/* Found it.  */
+	return true;
+
+      trun += system_dirs_len[idx] + 1;
+    }
+
+  return false;
+}
+
+
+static bool
+is_trusted_path_normalize (const char *path, size_t len)
+{
+  char *npath = (char *) alloca (len + 2);
+  char *wnp = npath;
+
+  while (*path != '\0')
+    {
+      if (path[0] == '/')
+	{
+	  if (path[1] == '.')
+	    {
+	      if (path[2] == '.' && (path[3] == '/' || path[3] == '\0'))
+		{
+		  while (wnp > npath && *--wnp != '/')
+		    ;
+		  path += 3;
+		  continue;
+		}
+	      else if (path[2] == '/' || path[2] == '\0')
+		{
+		  path += 2;
+		  continue;
+		}
+	    }
+
+	  if (wnp > npath && wnp[-1] == '/')
+	    {
+	      ++path;
+	      continue;
+	    }
+	}
+
+      *wnp++ = *path++;
+    }
+  if (wnp > npath && wnp[-1] != '/')
+    *wnp++ = '/';
+  *wnp = '\0';
+
+  return is_trusted_path (npath, wnp - npath);
+}
+
+
 static size_t
 is_dst (const char *start, const char *name, const char *str,
 	int is_path, int secure)
@@ -240,13 +305,14 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 		    int is_path)
 {
   const char *const start = name;
-  char *last_elem, *wp;
 
   /* Now fill the result path.  While copying over the string we keep
      track of the start of the last path element.  When we come accross
      a DST we copy over the value or (if the value is not available)
      leave the entire path element out.  */
-  last_elem = wp = result;
+  char *wp = result;
+  char *last_elem = result;
+  bool check_for_trusted = false;
 
   do
     {
@@ -265,6 +331,9 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 	      else
 #endif
 		repl = l->l_origin;
+
+	      check_for_trusted = (INTUSE(__libc_enable_secure)
+				   && l->l_type == lt_executable);
 	    }
 	  else if ((len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0)
 	    repl = GLRO(dl_platform);
@@ -297,11 +366,29 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 	{
 	  *wp++ = *name++;
 	  if (is_path && *name == ':')
-	    last_elem = wp;
+	    {
+	      /* In SUID/SGID programs, after $ORIGIN expansion the
+		 normalized path must be rooted in one of the trusted
+		 directories.  */
+	      if (__builtin_expect (check_for_trusted, false)
+		  && is_trusted_path_normalize (last_elem, wp - last_elem))
+		{
+		  wp = last_elem;
+		  check_for_trusted = false;
+		}
+	      else
+		last_elem = wp;
+	    }
 	}
     }
   while (*name != '\0');
 
+  /* In SUID/SGID programs, after $ORIGIN expansion the normalized
+     path must be rooted in one of the trusted directories.  */
+  if (__builtin_expect (check_for_trusted, false)
+      && is_trusted_path_normalize (last_elem, wp - last_elem))
+    wp = last_elem;
+
   *wp = '\0';
 
   return result;
@@ -411,33 +498,8 @@ fillin_rpath (char *rpath, struct r_search_path_elem **result, const char *sep,
 	cp[len++] = '/';
 
       /* Make sure we don't use untrusted directories if we run SUID.  */
-      if (__builtin_expect (check_trusted, 0))
-	{
-	  const char *trun = system_dirs;
-	  size_t idx;
-	  int unsecure = 1;
-
-	  /* All trusted directories must be complete names.  */
-	  if (cp[0] == '/')
-	    {
-	      for (idx = 0; idx < nsystem_dirs_len; ++idx)
-		{
-		  if (len == system_dirs_len[idx]
-		      && memcmp (trun, cp, len) == 0)
-		    {
-		      /* Found it.  */
-		      unsecure = 0;
-		      break;
-		    }
-
-		  trun += system_dirs_len[idx] + 1;
-		}
-	    }
-
-	  if (unsecure)
-	    /* Simply drop this directory.  */
-	    continue;
-	}
+      if (__builtin_expect (check_trusted, 0) && !is_trusted_path (cp, len))
+	continue;
 
       /* See if this directory is already known.  */
       for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=426cfd73719462d0fedd72d78169218509dae574

commit 426cfd73719462d0fedd72d78169218509dae574
Author: Andreas Schwab <schwab@redhat.com>
Date:   Tue May 3 13:44:25 2011 -0400

    ldconfig: don't crash on empty path in config file
    
    (cherry picked from commit 00ee369c1cbdcc4ca4a009e9223799951c6c8f04)

diff --git a/ChangeLog b/ChangeLog
index 853f82d..e3875af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-03  Andreas Schwab  <schwab@redhat.com>
+
+	* elf/ldconfig.c (add_dir): Don't crash on empty path.
+
 2011-04-30  Bruno Haible  <bruno@clisp.org>
 
 	[BZ #12717]
diff --git a/elf/ldconfig.c b/elf/ldconfig.c
index 6ba8e07..c11b1f5 100644
--- a/elf/ldconfig.c
+++ b/elf/ldconfig.c
@@ -384,14 +384,17 @@ add_dir (const char *line)
     }
 
   /* Canonify path: for now only remove leading and trailing
-     whitespace and the trailing slashes slashes.  */
-  i = strlen (entry->path) - 1;
+     whitespace and the trailing slashes.  */
+  i = strlen (entry->path);
 
-  while (isspace (entry->path[i]) && i > 0)
-    entry->path[i--] = '\0';
+  while (i > 0 && isspace (entry->path[i - 1]))
+    entry->path[--i] = '\0';
 
-  while (entry->path[i] == '/' && i > 0)
-    entry->path[i--] = '\0';
+  while (i > 0 && entry->path[i - 1] == '/')
+    entry->path[--i] = '\0';
+
+  if (i == 0)
+    return;
 
   char *path = entry->path;
   if (opt_chroot)

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7b1d92c6439bfeea8b72631a1f3849109a38c909

commit 7b1d92c6439bfeea8b72631a1f3849109a38c909
Author: Bruno Haible <bruno@clisp.org>
Date:   Mon May 2 02:36:43 2011 +0100

    Fix getnameinfo flags parameter type.
    
    (cherry picked from commit e4ecafe004b3d4270b3a9dace8f970047400ed38)

diff --git a/ChangeLog b/ChangeLog
index ff00f2e..853f82d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-04-30  Bruno Haible  <bruno@clisp.org>
+
+	[BZ #12717]
+	* conform/data/netdb.h-data (getnameinfo): Make POSIX compliant.
+	* resolv/netdb.h (getnameinfo): Change type of flags parameter
+	to 'int'.
+	* inet/getnameinfo.c (getnameinfo): Likewise.
+
 2011-04-22  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12685]
diff --git a/conform/data/netdb.h-data b/conform/data/netdb.h-data
index 483a3fc..0e22d7e 100644
--- a/conform/data/netdb.h-data
+++ b/conform/data/netdb.h-data
@@ -87,7 +87,7 @@ function int getaddrinfo (const char*, const char*, const struct addrinfo*, stru
 function {struct hostent*} gethostbyaddr (const void*, socklen_t, int)
 function {struct hostent*} gethostbyname (const char*)
 function {struct hostent*} gethostent (void)
-function int getnameinfo (const struct sockaddr*, socklen_t, char*, socklen_t, char*, socklen_t, unsigned)
+function int getnameinfo (const struct sockaddr*, socklen_t, char*, socklen_t, char*, socklen_t, int)
 function {struct netent*} getnetbyaddr (uint32_t, int)
 function {struct netent*} getnetbyname (const char*)
 function {struct netent*} getnetent (void)
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
index db6b5c7..6fb6ad6 100644
--- a/inet/getnameinfo.c
+++ b/inet/getnameinfo.c
@@ -159,7 +159,7 @@ nrl_domainname (void)
 int
 getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
 	     socklen_t hostlen, char *serv, socklen_t servlen,
-	     unsigned int flags)
+	     int flags)
 {
   int serrno = errno;
   int tmpbuflen = 1024;
@@ -385,7 +385,7 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
 	break;
 
       default:
-        return EAI_FAMILY;
+	return EAI_FAMILY;
     }
 
   if (serv && (servlen > 0))
diff --git a/resolv/netdb.h b/resolv/netdb.h
index 06e9a9a..bc8b6f4 100644
--- a/resolv/netdb.h
+++ b/resolv/netdb.h
@@ -1,4 +1,4 @@
-  /* Copyright (C) 1996-2002, 2003, 2004, 2009 Free Software Foundation, Inc.
+  /* Copyright (C) 1996-2004, 2009, 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
@@ -677,7 +677,7 @@ extern __const char *gai_strerror (int __ecode) __THROW;
 extern int getnameinfo (__const struct sockaddr *__restrict __sa,
 			socklen_t __salen, char *__restrict __host,
 			socklen_t __hostlen, char *__restrict __serv,
-			socklen_t __servlen, unsigned int __flags);
+			socklen_t __servlen, int __flags);
 #endif	/* POSIX */
 
 #ifdef __USE_GNU

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=1b31d30e82cf802fa6e31ffa216264b035d339d1

commit 1b31d30e82cf802fa6e31ffa216264b035d339d1
Author: Eric Blake <eblake@redhat.com>
Date:   Sat Apr 23 04:40:57 2011 +0100

    Use al possible bytes from fopen mode string.
    
    (cherry picked from commit b722481ac27a296c5e4c4ef5ebb85f48a9efac95)

diff --git a/ChangeLog b/ChangeLog
index 9d8ecac..ff00f2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-04-22  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12685]
+	* libio/fileops.c (_IO_new_file_fopen): Scan up to 7 bytes of the
+	mode string.
+	Patch by Eric Blake <eblake@redhat.com>.
+
 2011-04-17  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12420]
diff --git a/libio/fileops.c b/libio/fileops.c
index 4698953..1e7ef07 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -290,7 +290,7 @@ _IO_new_file_fopen (fp, filename, mode, is32not64)
 #ifdef _LIBC
   last_recognized = mode;
 #endif
-  for (i = 1; i < 6; ++i)
+  for (i = 1; i < 7; ++i)
     {
       switch (*++mode)
 	{
@@ -997,18 +997,18 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
       /* Adjust for read-ahead (bytes is buffer). */
       offset -= fp->_IO_read_end - fp->_IO_read_ptr;
       if (fp->_offset == _IO_pos_BAD)
-        {
-          if (mode != 0)
-            goto dumb;
-          else
-            {
-              result = _IO_SYSSEEK (fp, 0, dir);
-              if (result == EOF)
-                return result;
-
-              fp->_offset = result;
-            }
-        }
+	{
+	  if (mode != 0)
+	    goto dumb;
+	  else
+	    {
+	      result = _IO_SYSSEEK (fp, 0, dir);
+	      if (result == EOF)
+		return result;
+
+	      fp->_offset = result;
+	    }
+	}
       /* Make offset absolute, assuming current pointer is file_ptr(). */
       offset += fp->_offset;
       if (offset < 0)
@@ -1270,7 +1270,7 @@ _IO_new_file_write (f, data, n)
 	{
 	  f->_flags |= _IO_ERR_SEEN;
 	  break;
-        }
+	}
       to_do -= count;
       data = (void *) ((char *) data + count);
     }
@@ -1358,12 +1358,12 @@ _IO_new_file_xsputn (f, data, n)
       do_write = to_do - (block_size >= 128 ? to_do % block_size : 0);
 
       if (do_write)
-        {
+	{
 	  count = new_do_write (f, s, do_write);
 	  to_do -= count;
 	  if (count < do_write)
 	    return n - to_do;
-        }
+	}
 
       /* Now write out the remainder.  Normally, this will fit in the
 	 buffer, but it's somewhat messier for line-buffered files,

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=8277fdc1cd54428e54e112db7f5be89303951001

commit 8277fdc1cd54428e54e112db7f5be89303951001
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Mon Apr 18 02:51:26 2011 +0100

    Fix FPU context handling in getcontext on x86-64.
    
    fnstenv on x86-64 seems to clear the state.  Work around.
    
    (cherry picked from commit 75ea32abcde4e1699328354e1804ea94560d2950)

diff --git a/ChangeLog b/ChangeLog
index a50025b..9d8ecac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-04-17  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12420]
+	* sysdeps/unix/sysv/linux/x86_64/getcontext.S: Reload context after
+	storing it.
+	* stdlib/bug-getcontext.c: New file.
+	* stdlib/Makefile: Add rules to build and run bug-getcontext.
+
 2011-04-10  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12650]
diff --git a/stdlib/Makefile b/stdlib/Makefile
index d361dd8..6b8e021 100644
--- a/stdlib/Makefile
+++ b/stdlib/Makefile
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+# Copyright (C) 1991-2009, 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
@@ -70,7 +70,7 @@ tests		:= tst-strtol tst-strtod testmb testrand testsort testdiv   \
 		   test-a64l tst-qsort tst-system testmb2 bug-strtod2	    \
 		   tst-atof1 tst-atof2 tst-strtod2 tst-strtod3 tst-rand48-2 \
 		   tst-makecontext tst-strtod4 tst-strtod5 tst-qsort2	    \
-		   tst-makecontext2 tst-strtod6 tst-unsetenv1
+		   tst-makecontext2 tst-strtod6 tst-unsetenv1 bug-getcontext
 
 include ../Makeconfig
 
@@ -144,3 +144,10 @@ $(objpfx)tst-putenv: $(objpfx)tst-putenvmod.so
 $(objpfx)tst-putenvmod.so: $(objpfx)tst-putenvmod.os
 	$(build-module)
 CFLAGS-tst-putenvmod.c = -DNOT_IN_libc=1
+
+ifeq ($(build-shared),yes)
+link-libm = $(common-objpfx)math/libm.so
+else
+link-libm = $(common-objpfx)math/libm.a
+endif
+$(objpfx)bug-getcontext: $(link-libm)
diff --git a/stdlib/bug-getcontext.c b/stdlib/bug-getcontext.c
new file mode 100644
index 0000000..745aa1f
--- /dev/null
+++ b/stdlib/bug-getcontext.c
@@ -0,0 +1,48 @@
+/* BZ 12420 */
+
+#include <errno.h>
+#include <fenv.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ucontext.h>
+
+static int
+do_test (void)
+{
+  int except_mask =  FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW;
+  int status = feenableexcept (except_mask);
+
+  except_mask = fegetexcept ();
+  if (except_mask == -1)
+    {
+      printf("\nBefore getcontext(): fegetexcept returned: %d\n",
+	     except_mask);
+      return 1;
+    }
+
+  ucontext_t ctx;
+  status = getcontext(&ctx);
+  if (status)
+    {
+      printf("\ngetcontext failed, errno: %d.\n", errno);
+      return 1;
+    }
+
+  printf ("\nDone with getcontext()!\n");
+  fflush (NULL);
+
+  int mask = fegetexcept ();
+  if (mask != except_mask)
+    {
+      printf("\nAfter getcontext(): fegetexcept returned: %d, expected: %d.\n",
+	     mask, except_mask);
+      return 1;
+    }
+
+  printf("\nAt end fegetexcept() returned %d, expected: %d.\n",
+	 mask, except_mask);
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/sysdeps/unix/sysv/linux/x86_64/getcontext.S b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
index 4bbc7a4..1a31d72 100644
--- a/sysdeps/unix/sysv/linux/x86_64/getcontext.S
+++ b/sysdeps/unix/sysv/linux/x86_64/getcontext.S
@@ -1,5 +1,5 @@
 /* Save current context.
-   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Andreas Jaeger <aj@suse.de>, 2002.
 
@@ -62,6 +62,7 @@ ENTRY(__getcontext)
 	movq	%rcx, oFPREGS(%rdi)
 	/* Save the floating-point environment.  */
 	fnstenv	(%rcx)
+	fldenv	(%rcx)
 	stmxcsr oMXCSR(%rdi)
 
 	/* Save the current signal mask with

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=fea332e16416691310088b5c0e6797694c88352b

commit fea332e16416691310088b5c0e6797694c88352b
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Mon Apr 11 03:43:01 2011 +0100

    Fix memory leak in TLS of loaded objects.
    
    (cherry picked from commit e6c61494125126d2ba77e5d99f83887a2ed49783)

diff --git a/ChangeLog b/ChangeLog
index 2e7c309..a50025b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2011-04-10  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12650]
+	* sysdeps/i386/dl-tls.h: Define TLS_DTV_UNALLOCATED.
+	* sysdeps/ia64/dl-tls.h: Likewise.
+	* sysdeps/powerpc/dl-tls.h: Likewise.
+	* sysdeps/s390/dl-tls.h: Likewise.
+	* sysdeps/sh/dl-tls.h: Likewise.
+	* sysdeps/sparc/dl-tls.h: Likewise.
+	* sysdeps/x86_64/dl-tls.h: Likewise.
+	* elf/dl-tls.c: Don't define TLS_DTV_UNALLOCATED here.
+
 2011-03-14  Andreas Schwab  <schwab@redhat.com>
 
 	* elf/dl-load.c (_dl_dst_substitute): When skipping the first
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 824adc1..ea94aa0 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  Generic version.
-   Copyright (C) 2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc.
+   Copyright (C) 2002-2006,2008,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
@@ -33,9 +33,6 @@
    to allow dynamic loading of modules defining IE-model TLS data.  */
 #define TLS_STATIC_SURPLUS	64 + DL_NNS * 100
 
-/* Value used for dtv entries for which the allocation is delayed.  */
-#define TLS_DTV_UNALLOCATED	((void *) -1l)
-
 
 /* Out-of-memory handler.  */
 #ifdef SHARED
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index aeb7183..d7dc113 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,10 @@
+2011-04-10  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12650]
+	* allocatestack.c (get_cached_stack): Deallocate DTV entries before
+	clearing memory.
+	Patch partly by Robert Rex <robert.rex@exasol.com>.
+
 2011-01-13  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #10484]
diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c
index 3c3585f..550a8be 100644
--- a/nptl/allocatestack.c
+++ b/nptl/allocatestack.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2002-2007, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2002-2007, 2009, 2011 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
 
@@ -26,6 +26,7 @@
 #include <sys/mman.h>
 #include <sys/param.h>
 #include <dl-sysdep.h>
+#include <dl-tls.h>
 #include <tls.h>
 #include <lowlevellock.h>
 #include <kernel-features.h>
@@ -238,6 +239,10 @@ get_cached_stack (size_t *sizep, void **memp)
 
   /* Clear the DTV.  */
   dtv_t *dtv = GET_DTV (TLS_TPADJ (result));
+  for (size_t cnt = 0; cnt < dtv[-1].counter; ++cnt)
+    if (! dtv[1 + cnt].pointer.is_static
+	&& dtv[1 + cnt].pointer.val != TLS_DTV_UNALLOCATED)
+      free (dtv[1 + cnt].pointer.val);
   memset (dtv, '\0', (dtv[-1].counter + 1) * sizeof (dtv_t));
 
   /* Re-initialize the TLS.  */
diff --git a/sysdeps/i386/dl-tls.h b/sysdeps/i386/dl-tls.h
index 58705c7..21b949b 100644
--- a/sysdeps/i386/dl-tls.h
+++ b/sysdeps/i386/dl-tls.h
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  i386 version.
-   Copyright (C) 2002, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 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
@@ -58,3 +58,6 @@ strong_alias (___tls_get_addr, ___tls_get_addr_internal)
 
 # endif
 #endif
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
diff --git a/sysdeps/ia64/dl-tls.h b/sysdeps/ia64/dl-tls.h
index 26f3d2a..5e9a165 100644
--- a/sysdeps/ia64/dl-tls.h
+++ b/sysdeps/ia64/dl-tls.h
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  IA-64 version.
-   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2002, 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
@@ -28,3 +28,6 @@
 #define DONT_USE_TLS_INDEX	1
 
 extern void *__tls_get_addr (size_t m, size_t offset);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
diff --git a/sysdeps/powerpc/dl-tls.h b/sysdeps/powerpc/dl-tls.h
index 957d4b4..9ab81f9 100644
--- a/sysdeps/powerpc/dl-tls.h
+++ b/sysdeps/powerpc/dl-tls.h
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  PowerPC version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -47,3 +47,6 @@ extern void *__tls_get_addr (tls_index *ti);
 # define GET_ADDR_OFFSET	(ti->ti_offset + TLS_DTV_OFFSET)
 # define __TLS_GET_ADDR(__ti)	(__tls_get_addr (__ti) - TLS_DTV_OFFSET)
 #endif
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
diff --git a/sysdeps/s390/dl-tls.h b/sysdeps/s390/dl-tls.h
index 0560462..7295abc 100644
--- a/sysdeps/s390/dl-tls.h
+++ b/sysdeps/s390/dl-tls.h
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  s390 version.
-   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 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
@@ -72,6 +72,9 @@ __tls_get_offset:\n\
 # define __TLS_GET_ADDR(__ti) \
   ({ extern char _GLOBAL_OFFSET_TABLE_[] attribute_hidden;		  \
      (void *) __tls_get_offset ((char *) (__ti) - _GLOBAL_OFFSET_TABLE_)  \
-     + (unsigned long) __builtin_thread_pointer (); }) 
+     + (unsigned long) __builtin_thread_pointer (); })
 
 #endif
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
diff --git a/sysdeps/sh/dl-tls.h b/sysdeps/sh/dl-tls.h
index 98e2f19..cf60790 100644
--- a/sysdeps/sh/dl-tls.h
+++ b/sysdeps/sh/dl-tls.h
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  SH version.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 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
@@ -27,3 +27,6 @@ typedef struct
 
 
 extern void *__tls_get_addr (tls_index *ti);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
diff --git a/sysdeps/sparc/dl-tls.h b/sysdeps/sparc/dl-tls.h
index 6edf8d5..fb2535e 100644
--- a/sysdeps/sparc/dl-tls.h
+++ b/sysdeps/sparc/dl-tls.h
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  SPARC version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 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
@@ -27,3 +27,6 @@ typedef struct
 
 
 extern void *__tls_get_addr (tls_index *ti);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)
diff --git a/sysdeps/x86_64/dl-tls.h b/sysdeps/x86_64/dl-tls.h
index 9b389ed..c382cd8 100644
--- a/sysdeps/x86_64/dl-tls.h
+++ b/sysdeps/x86_64/dl-tls.h
@@ -1,5 +1,5 @@
 /* Thread-local storage handling in the ELF dynamic linker.  x86-64 version.
-   Copyright (C) 2002, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2005, 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
@@ -27,3 +27,6 @@ typedef struct dl_tls_index
 
 
 extern void *__tls_get_addr (tls_index *ti);
+
+/* Value used for dtv entries for which the allocation is delayed.  */
+#define TLS_DTV_UNALLOCATED	((void *) -1l)

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=4e43f00fc3df9757f86bc82292e6d4ca7ccd701d

commit 4e43f00fc3df9757f86bc82292e6d4ca7ccd701d
Author: Andreas Schwab <schwab@linux-m68k.org>
Date:   Sat Apr 9 19:55:26 2011 +0100

    Don't leave empty element in rpath when skipping an element
    
    (cherry picked from commit 34fe483e121660aff222ec1c15d57804f64191ea)

diff --git a/ChangeLog b/ChangeLog
index e9e8f50..2e7c309 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-03-14  Andreas Schwab  <schwab@redhat.com>
+
+	* elf/dl-load.c (_dl_dst_substitute): When skipping the first
+	rpath element also skip the following colon.
+	(expand_dynamic_string_token): Add is_path parameter and pass
+	down to DL_DST_REQUIRED and _dl_dst_substitute.
+	(decompose_rpath): Call expand_dynamic_string_token with
+	non-zero is_path.  Ignore empty rpaths.
+	(_dl_map_object_from_fd): Call expand_dynamic_string_token
+	with zero is_path.
+
 2011-04-07  Andreas Schwab  <schwab@redhat.com>
 
 	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S (CALL_FAIL):
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 8d4ad73..2993aa9 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1,5 +1,5 @@
 /* Map in a shared object's segments from the file.
-   Copyright (C) 1995-2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1995-2005, 2006, 2007, 2009, 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
@@ -284,6 +284,10 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
 	      name += len;
 	      while (*name != '\0' && (!is_path || *name != ':'))
 		++name;
+	      /* Also skip following colon if this is the first rpath
+		 element, but keep an empty element at the end.  */
+	      if (wp == result && is_path && *name == ':' && name[1] != '\0')
+		++name;
 	    }
 	  else
 	    /* No DST we recognize.  */
@@ -310,7 +314,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result,
    belonging to the map is loaded.  In this case the path element
    containing $ORIGIN is left out.  */
 static char *
-expand_dynamic_string_token (struct link_map *l, const char *s)
+expand_dynamic_string_token (struct link_map *l, const char *s, int is_path)
 {
   /* We make two runs over the string.  First we determine how large the
      resulting string is and then we copy it over.  Since this is now
@@ -321,7 +325,7 @@ expand_dynamic_string_token (struct link_map *l, const char *s)
   char *result;
 
   /* Determine the number of DST elements.  */
-  cnt = DL_DST_COUNT (s, 1);
+  cnt = DL_DST_COUNT (s, is_path);
 
   /* If we do not have to replace anything simply copy the string.  */
   if (__builtin_expect (cnt, 0) == 0)
@@ -335,7 +339,7 @@ expand_dynamic_string_token (struct link_map *l, const char *s)
   if (result == NULL)
     return NULL;
 
-  return _dl_dst_substitute (l, s, result, 1);
+  return _dl_dst_substitute (l, s, result, is_path);
 }
 
 
@@ -551,13 +555,21 @@ decompose_rpath (struct r_search_path_struct *sps,
 
   /* Make a writable copy.  At the same time expand possible dynamic
      string tokens.  */
-  copy = expand_dynamic_string_token (l, rpath);
+  copy = expand_dynamic_string_token (l, rpath, 1);
   if (copy == NULL)
     {
       errstring = N_("cannot create RUNPATH/RPATH copy");
       goto signal_error;
     }
 
+  /* Ignore empty rpaths.  */
+  if (*copy == 0)
+    {
+      free (copy);
+      sps->dirs = (char *) -1;
+      return false;
+    }
+
   /* Count the number of necessary elements in the result array.  */
   nelems = 0;
   for (cp = copy; *cp != '\0'; ++cp)
@@ -2170,7 +2182,7 @@ _dl_map_object (struct link_map *loader, const char *name,
     {
       /* The path may contain dynamic string tokens.  */
       realname = (loader
-		  ? expand_dynamic_string_token (loader, name)
+		  ? expand_dynamic_string_token (loader, name, 0)
 		  : local_strdup (name));
       if (realname == NULL)
 	fd = -1;

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7d789b1b4d3531172f788d13a76cf7d5a429835e

commit 7d789b1b4d3531172f788d13a76cf7d5a429835e
Author: Andreas Schwab <schwab@redhat.com>
Date:   Thu Apr 7 16:23:52 2011 -0400

    Maintain stack alignment in ____longjmp_chk on x86_64
    
    (cherry picked from commit e451d22b22c959a4dbf86dbc9f125985601473ab)

diff --git a/ChangeLog b/ChangeLog
index 3219d0c..e9e8f50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-07  Andreas Schwab  <schwab@redhat.com>
+
+	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S (CALL_FAIL):
+	Maintain aligned stack.
+	(CHECK_RSP): Remove unused macro.
+
 2011-04-01  Andreas Schwab  <schwab@redhat.com>
 
 	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
diff --git a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
index da35115..3881082 100644
--- a/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
+++ b/sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001,2004,2005,2006,2009,2010 Free Software Foundation, Inc.
+/* Copyright (C) 2001,2004,2005,2006,2009,2010,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
@@ -30,19 +30,23 @@ longjmp_msg:
 //#define __longjmp ____longjmp_chk
 
 #ifdef PIC
-# define CALL_FAIL	leaq	longjmp_msg(%rip), %rdi;		      \
-			call	__GI___fortify_fail
+# define CALL_FAIL	subq	$8, %rsp;				      \
+			cfi_remember_state;				      \
+			cfi_def_cfa_offset(16);				      \
+			leaq	longjmp_msg(%rip), %rdi;		      \
+			call	__GI___fortify_fail;			      \
+			nop;						      \
+			cfi_restore_state
 #else
-# define CALL_FAIL	movq	$longjmp_msg, %rdi;			      \
-			call	__fortify_fail
+# define CALL_FAIL	subq	$8, %rsp;				      \
+			cfi_remember_state;				      \
+			cfi_def_cfa_offset(16);				      \
+			movq	$longjmp_msg, %rdi;			      \
+			call	__fortify_fail;				      \
+			nop;						      \
+			cfi_restore_state
 #endif
 
-#define CHECK_RSP(reg) \
-	cmpq	reg, %rsp;						      \
-	jbe	.Lok;							      \
-	CALL_FAIL;							      \
-.Lok:
-
 /* Jump to the position specified by ENV, causing the
    setjmp call there to return VAL, or 1 if VAL is 0.
    void __longjmp (__jmp_buf env, int val).  */

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c81fb726d822c5c5296c21c9d47c323ce14aa723

commit c81fb726d822c5c5296c21c9d47c323ce14aa723
Author: Andreas Schwab <schwab@redhat.com>
Date:   Fri Apr 1 10:40:53 2011 -0400

    Install bits/timex.h header.
    
    (cherry picked from commit 6e63d5e1aebc659a95223cf8862a7b42c67dbb1c)

diff --git a/ChangeLog b/ChangeLog
index a29a823..3219d0c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-04-01  Andreas Schwab  <schwab@redhat.com>
+
+	* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
+	bits/timex.h
+
 2011-03-18  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12583]
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index cee5d29..803d9ee 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -95,7 +95,7 @@ generated += syscall-list.h syscall-list.d
 endif
 
 ifeq ($(subdir),time)
-sysdep_headers += sys/timex.h
+sysdep_headers += sys/timex.h bits/timex.h
 
 sysdep_routines += ntp_gettime
 endif

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=fa9f66a6f09f3b7234cc24ca3266259a589c3470

commit fa9f66a6f09f3b7234cc24ca3266259a589c3470
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Fri Mar 18 05:29:20 2011 -0400

    Check size of pattern in wide character representation in fnmatch.
    
    (cherry picked from commit 8126d90480fa3e0c5c5cd0d02cb1c93174b45485)

diff --git a/ChangeLog b/ChangeLog
index a174446..a29a823 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-03-18  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12583]
+	* posix/fnmatch.c (fnmatch): Check size of pattern in wide
+	character representation.
+	Partly based on a patch by Tomas Hoger <thoger@redhat.com>.
+
 2011-03-16  Ryan S. Arnold  <rsa@us.ibm.com>
 
 	* sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S (isnanf): Fix
diff --git a/posix/fnmatch.c b/posix/fnmatch.c
index 0af5ee6..819a6a7 100644
--- a/posix/fnmatch.c
+++ b/posix/fnmatch.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2007,2010
+/* Copyright (C) 1991,1992,1993,1996,1997,1998,1999,2000,2001,2002,2003,2007,2010,2011
 	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -375,6 +375,11 @@ fnmatch (pattern, string, flags)
 	       XXX Do we have to set `errno' to something which mbsrtows hasn't
 	       already done?  */
 	    return -1;
+	  if (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0))
+	    {
+	      __set_errno (ENOMEM);
+	      return -2;
+	    }
 	  wpattern_malloc = wpattern
 	    = (wchar_t *) malloc ((n + 1) * sizeof (wchar_t));
 	  assert (mbsinit (&ps));
@@ -419,6 +424,12 @@ fnmatch (pattern, string, flags)
 	       XXX Do we have to set `errno' to something which mbsrtows hasn't
 	       already done?  */
 	    goto free_return;
+	  if (__builtin_expect (n >= (size_t) -1 / sizeof (wchar_t), 0))
+	    {
+	      free (wpattern_malloc);
+	      __set_errno (ENOMEM);
+	      return -2;
+	    }
 
 	  wstring_malloc = wstring
 	    = (wchar_t *) malloc ((n + 1) * sizeof (wchar_t));

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=efdc6bb89a814bacc9601d725565eceb1c3160bc

commit efdc6bb89a814bacc9601d725565eceb1c3160bc
Author: Ryan S. Arnold <rsa@us.ibm.com>
Date:   Fri Mar 18 05:15:00 2011 -0400

    PowerPC: Fix POWER6 s_isnanf.S: END(__isnan) to END(__isnanf)
    
    (cherry picked from commit ccfe366e6fc64bb81183480bd2ae113041d3c84c)

diff --git a/ChangeLog b/ChangeLog
index 7a71e6c..a174446 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-03-16  Ryan S. Arnold  <rsa@us.ibm.com>
+
+	* sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S (isnanf): Fix
+	END(__isnan) to END(__isnanf) to match function entry point/label
+	EALIGN(__isnanf,...).
+
 2011-03-10  Jakub Jelinek  <jakub@redhat.com>
 
 	* wcsmbs/wchar.h (wmemcmp): Remove __restrict qualifiers.
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S
index 12bf473..0f71a98 100644
--- a/sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S
+++ b/sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S
@@ -1,5 +1,5 @@
 /* isnanf().  PowerPC32 version.
-   Copyright (C) 2008 Free Software Foundation, Inc.
+   Copyright (C) 2008, 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
@@ -39,8 +39,7 @@ EALIGN (__isnanf, 4, 0)
 L(NaN):
 	li	r3,1		/* else return 1 */
 	blr
-	END (__isnan)
+	END (__isnanf)
 
 hidden_def (__isnanf)
 weak_alias (__isnanf, isnanf)
-

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=6a29825d63f8e6c429c4fe425c3a0ed70a3245cb

commit 6a29825d63f8e6c429c4fe425c3a0ed70a3245cb
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Mar 10 13:04:08 2011 -0500

    Remove __restrict quals from wmemcmp prototype.
    
    (cherry picked from commit c6e13027abd4b9c2d694fb4d8b28ab8290ea5971)

diff --git a/ChangeLog b/ChangeLog
index 850d300..7a71e6c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+	* wcsmbs/wchar.h (wmemcmp): Remove __restrict qualifiers.
+
 2011-03-10  Ulrich Drepper  <drepper@gmail.com>
 
 	[BZ #12510]
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index fc2c6a4..e64e8e2 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -319,8 +319,7 @@ extern wchar_t *wmemchr (__const wchar_t *__s, wchar_t __c, size_t __n)
 #endif
 
 /* Compare N wide characters of S1 and S2.  */
-extern int wmemcmp (__const wchar_t *__restrict __s1,
-		    __const wchar_t *__restrict __s2, size_t __n)
+extern int wmemcmp (__const wchar_t *__s1, __const wchar_t *__s2, size_t __n)
      __THROW __attribute_pure__;
 
 /* Copy N wide characters of SRC to DEST.  */

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=411a9d6b1de462394aabd2a5bf920fde140249ff

commit 411a9d6b1de462394aabd2a5bf920fde140249ff
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Thu Mar 10 18:51:33 2011 +0100

    Fix copy relocations handling of unique objects.
    
    (cherry picked from commit 028478fa40d85a73b19638dbe3f83b1acebf370c)

diff --git a/ChangeLog b/ChangeLog
index c97afec..850d300 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-03-10  Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12510]
+	* elf/dl-lookup.c (do_lookup_x): For copy relocations of unique objects
+	copy from the symbol referenced in the relocation to initialize the
+	used variable.
+	Patch by Piotr Bury <pbury@goahead.com>.
+
 2011-03-06  Ulrich Drepper  <drepper@gmail.com>
 
 	* elf/dl-load.c (_dl_map_object): If we are looking for the first
diff --git a/elf/dl-lookup.c b/elf/dl-lookup.c
index 763ec16..0a7b94b 100644
--- a/elf/dl-lookup.c
+++ b/elf/dl-lookup.c
@@ -1,5 +1,5 @@
 /* Look up a symbol in the loaded objects.
-   Copyright (C) 1995-2005, 2006, 2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1995-2007, 2009, 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
@@ -363,8 +363,19 @@ do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
 		      if (entries[idx].hashval == new_hash
 			  && strcmp (entries[idx].name, undef_name) == 0)
 			{
-			  result->s = entries[idx].sym;
-			  result->m = (struct link_map *) entries[idx].map;
+			  if ((type_class & ELF_RTYPE_CLASS_COPY) != 0)
+			    {
+			      /* We possibly have to initialize the central
+				 copy from the copy addressed through the
+				 relocation.  */
+			      result->s = sym;
+			      result->m = (struct link_map *) map;
+			    }
+			  else
+			    {
+			      result->s = entries[idx].sym;
+			      result->m = (struct link_map *) entries[idx].map;
+			    }
 			  __rtld_lock_unlock_recursive (tab->lock);
 			  return 1;
 			}

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=957a75e60be98088738b5b5640164e8dfffc4f4e

commit 957a75e60be98088738b5b5640164e8dfffc4f4e
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun Mar 6 00:01:50 2011 -0500

    Fix loading first object along a path when tracing.
    
    (cherry picked from commit 6a5ee1029b3966c5ae9adaaa881e255b2880f511)

diff --git a/ChangeLog b/ChangeLog
index a6fa7a9..c97afec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-03-06  Ulrich Drepper  <drepper@gmail.com>
+
+	* elf/dl-load.c (_dl_map_object): If we are looking for the first
+	to-be-loaded object along a path to loader is ld.so.
+
 2011-03-03  Andreas Schwab  <schwab@redhat.com>
 
 	* libio/fmemopen.c (fmemopen): Don't read past end of buffer.
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 9e35dc4..8d4ad73 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -2102,7 +2102,9 @@ _dl_map_object (struct link_map *loader, const char *name,
 	    {
 #ifdef SHARED
 	      // XXX Correct to unconditionally default to namespace 0?
-	      l = loader ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded;
+	      l = (loader
+		   ?: GL(dl_ns)[LM_ID_BASE]._ns_loaded
+		   ?: &GL(dl_rtld_map));
 #else
 	      l = loader;
 #endif

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=a02af4f1aedc6e1db180b9568d85e6d40d8fb1f6

commit a02af4f1aedc6e1db180b9568d85e6d40d8fb1f6
Author: Andreas Schwab <schwab@redhat.com>
Date:   Fri Mar 4 00:48:00 2011 -0500

    Don't read past end of buffer in fmemopen
    
    (cherry picked from commit 9d25c392ba73065ac20f518d1cef1cdc96860545)

diff --git a/ChangeLog b/ChangeLog
index 0aaabe7..a6fa7a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-03  Andreas Schwab  <schwab@redhat.com>
+
+	* libio/fmemopen.c (fmemopen): Don't read past end of buffer.
+
 2011-02-23  Andreas Schwab  <schwab@redhat.com>
 	    Ulrich Drepper  <drepper@gmail.com>
 
diff --git a/libio/fmemopen.c b/libio/fmemopen.c
index d3750fc..1a631d5 100644
--- a/libio/fmemopen.c
+++ b/libio/fmemopen.c
@@ -1,5 +1,5 @@
 /* Fmemopen implementation.
-   Copyright (C) 2000, 2002, 2005, 2006, 2008, 2009
+   Copyright (C) 2000, 2002, 2005, 2006, 2008, 2009, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Hanno Mueller, kontakt@hanno.de, 2000.
@@ -243,7 +243,7 @@ fmemopen (void *buf, size_t len, const char *mode)
   if (mode[0] == 'w')
     c->buffer[0] = '\0';
 
-  c->maxpos = strlen (c->buffer);
+  c->maxpos = strnlen (c->buffer, len);
 
   if (mode[0] == 'a')
     c->pos = c->maxpos;

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=522cb50e61c109d41df4dbc366312a133e248dca

commit 522cb50e61c109d41df4dbc366312a133e248dca
Author: Andreas Schwab <schwab@redhat.com>
Date:   Sat Feb 26 02:49:48 2011 +0100

    Fix memory leak in dlopen with RTLD_NOLOAD.
    
    (cherry picked from commit 4bff6e0175ed195871f4e01cc4c4c33274b8f6e3)

diff --git a/ChangeLog b/ChangeLog
index 48f592f..0aaabe7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2011-02-23  Andreas Schwab  <schwab@redhat.com>
+	    Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12509]
+	* include/link.h (struct link_map): Add l_orig_initfini.
+	* elf/dl-load.c (_dl_map_object_from_fd): Free realname before
+	returning unsuccessfully.
+	* elf/dl-close.c (_dl_close_worker): If this is the last explicit
+	close of a file loaded at startup, restore the original l_initfini
+	list.
+	* elf/dl-deps.c (_dl_map_object_deps): Don't free old l_initfini
+	list, store the pointer.
+	* elf/Makefile ($(objpfx)noload-mem): New rule.
+	(noload-ENV): Define.
+	(tests): Add $(objpfx)noload-mem.
+	* elf/noload.c: Include <memcheck.h>.
+	(main): Call mtrace.  Close all opened handles.
+
 2011-02-17  Andreas Schwab  <schwab@redhat.com>
 
 	[BZ #12454]
diff --git a/elf/Makefile b/elf/Makefile
index 34609a0..addb086 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -209,7 +209,7 @@ endif
 ifeq (yesyes,$(have-fpie)$(build-shared))
 tests: $(objpfx)tst-pie1.out
 endif
-tests: $(objpfx)tst-leaks1-mem
+tests: $(objpfx)tst-leaks1-mem $(objpfx)noload-mem
 tlsmod17a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 tlsmod18a-suffixes = 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 modules-names = testobj1 testobj2 testobj3 testobj4 testobj5 testobj6 \
@@ -658,6 +658,10 @@ $(objpfx)noload: $(objpfx)testobj1.so
 LDFLAGS-noload = -rdynamic
 $(objpfx)noload.out: $(objpfx)testobj5.so
 
+$(objpfx)noload-mem: $(objpfx)noload.out
+	$(common-objpfx)malloc/mtrace $(objpfx)noload.mtrace > $@
+noload-ENV = MALLOC_TRACE=$(objpfx)noload.mtrace
+
 LDFLAGS-nodelete = -rdynamic
 LDFLAGS-nodelmod1.so = -Wl,--enable-new-dtags,-z,nodelete
 LDFLAGS-nodelmod4.so = -Wl,--enable-new-dtags,-z,nodelete
diff --git a/elf/dl-close.c b/elf/dl-close.c
index b73a7ad..e1940da 100644
--- a/elf/dl-close.c
+++ b/elf/dl-close.c
@@ -1,5 +1,5 @@
 /* Close a shared object opened by `_dl_open'.
-   Copyright (C) 1996-2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1996-2007, 2009, 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
@@ -119,8 +119,17 @@ _dl_close_worker (struct link_map *map)
   if (map->l_direct_opencount > 0 || map->l_type != lt_loaded
       || dl_close_state != not_pending)
     {
-      if (map->l_direct_opencount == 0 && map->l_type == lt_loaded)
-	dl_close_state = rerun;
+      if (map->l_direct_opencount == 0)
+	{
+	  if (map->l_type == lt_loaded)
+	    dl_close_state = rerun;
+	  else if (map->l_type == lt_library)
+	    {
+	      struct link_map **oldp = map->l_initfini;
+	      map->l_initfini = map->l_orig_initfini;
+	      _dl_scope_free (oldp);
+	    }
+	}
 
       /* There are still references to this object.  Do nothing more.  */
       if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index b2f6a46..06fcabb 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -669,5 +669,5 @@ Filters not supported with LD_TRACE_PRELINKING"));
       _dl_scope_free (old_l_reldeps);
     }
   if (old_l_initfini != NULL)
-    _dl_scope_free (old_l_initfini);
+      map->l_orig_initfini = old_l_initfini;
 }
diff --git a/elf/dl-load.c b/elf/dl-load.c
index aa324d1..9e35dc4 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -897,6 +897,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
     {
       /* We are not supposed to load the object unless it is already
 	 loaded.  So return now.  */
+      free (realname);
       __close (fd);
       return NULL;
     }
@@ -915,6 +916,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
       _dl_zerofd = _dl_sysdep_open_zero_fill ();
       if (_dl_zerofd == -1)
 	{
+	  free (realname);
 	  __close (fd);
 	  _dl_signal_error (errno, NULL, NULL,
 			    N_("cannot open zero fill device"));
diff --git a/elf/noload.c b/elf/noload.c
index 9281ec7..bcc85ef 100644
--- a/elf/noload.c
+++ b/elf/noload.c
@@ -1,20 +1,28 @@
 #include <dlfcn.h>
 #include <stdio.h>
+#include <mcheck.h>
 
 int
 main (void)
 {
   int result = 0;
+  void *p;
+
+  mtrace ();
 
   /* First try to load an object which is a dependency.  This should
      succeed.  */
-  if (dlopen ("testobj1.so", RTLD_LAZY | RTLD_NOLOAD) == NULL)
+  p = dlopen ("testobj1.so", RTLD_LAZY | RTLD_NOLOAD);
+  if (p == NULL)
     {
       printf ("cannot open \"testobj1.so\": %s\n", dlerror ());
       result = 1;
     }
   else
-    puts ("loading \"testobj1.so\" succeeded, OK");
+    {
+      puts ("loading \"testobj1.so\" succeeded, OK");
+      dlclose (p);
+    }
 
   /* Now try loading an object which is not already loaded.  */
   if (dlopen ("testobj5.so", RTLD_LAZY | RTLD_NOLOAD) != NULL)
@@ -25,8 +33,6 @@ main (void)
   else
     {
       /* Load the object and run the same test again.  */
-      void *p;
-
       puts ("\"testobj5.so\" wasn't loaded and RTLD_NOLOAD prevented it, OK");
 
       p = dlopen ("testobj5.so", RTLD_LAZY);
@@ -41,13 +47,17 @@ main (void)
 	{
 	  puts ("loading \"testobj5.so\" succeeded, OK");
 
-	  if (dlopen ("testobj5.so", RTLD_LAZY | RTLD_NOLOAD) == NULL)
+	  void *q = dlopen ("testobj5.so", RTLD_LAZY | RTLD_NOLOAD);
+	  if (q == NULL)
 	    {
 	      printf ("cannot open \"testobj5.so\": %s\n", dlerror ());
 	      result = 1;
 	    }
 	  else
-	    puts ("loading \"testobj5.so\" with RTLD_NOLOAD succeeded, OK");
+	    {
+	      puts ("loading \"testobj5.so\" with RTLD_NOLOAD succeeded, OK");
+	      dlclose (q);
+	    }
 
 	  if (dlclose (p) != 0)
 	    {
diff --git a/include/link.h b/include/link.h
index 26c6743..e1700b1 100644
--- a/include/link.h
+++ b/include/link.h
@@ -1,6 +1,6 @@
 /* Data structure for communication from the run-time dynamic linker for
    loaded ELF shared objects.
-   Copyright (C) 1995-2006, 2007, 2009 Free Software Foundation, Inc.
+   Copyright (C) 1995-2006, 2007, 2009, 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
@@ -236,6 +236,9 @@ struct link_map
 
     /* List of object in order of the init and fini calls.  */
     struct link_map **l_initfini;
+    /* The init and fini list generated at startup, saved when the
+       object is also loaded dynamically.  */
+    struct link_map **l_orig_initfini;
 
     /* List of the dependencies introduced through symbol binding.  */
     struct link_map_reldeps

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=ad78094bcb15b4d36ae46da568bbdf29276912b6

commit ad78094bcb15b4d36ae46da568bbdf29276912b6
Author: Andreas Schwab <schwab@redhat.com>
Date:   Fri Feb 25 16:51:24 2011 -0500

    Don't crash when dependencies are missing
    
    (cherry picked from commit f2092faf2b6bd491a1891d5d5e393a8bf85d01d7)

diff --git a/ChangeLog b/ChangeLog
index dd8f114..48f592f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
+2011-02-17  Andreas Schwab  <schwab@redhat.com>
+
+	[BZ #12454]
+	* elf/dl-deps.c (_dl_map_object_deps): Signal error early when
+	dependencies are missing.
+
 2011-02-22  Samuel Thibault  <samuel.thibault@ens-lyon.org>
 
-        Fix __if_freereq crash: Unlike the generic version which uses free,
+	Fix __if_freereq crash: Unlike the generic version which uses free,
 	Hurd needs munmap.
 	* sysdeps/mach/hurd/ifreq.h: New file.
 
diff --git a/elf/dl-deps.c b/elf/dl-deps.c
index 7191508..b2f6a46 100644
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -491,6 +491,10 @@ _dl_map_object_deps (struct link_map *map,
   if (errno == 0 && errno_saved != 0)
     __set_errno (errno_saved);
 
+  if (errno_reason)
+    _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname,
+		      NULL, errstring);
+
   struct link_map **old_l_initfini = NULL;
   if (map->l_initfini != NULL && map->l_type == lt_loaded)
     {
@@ -666,8 +670,4 @@ Filters not supported with LD_TRACE_PRELINKING"));
     }
   if (old_l_initfini != NULL)
     _dl_scope_free (old_l_initfini);
-
-  if (errno_reason)
-    _dl_signal_error (errno_reason == -1 ? 0 : errno_reason, objname,
-		      NULL, errstring);
 }

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=21eddf8cffb9764fcc280e9d6b52669534c026ba

commit 21eddf8cffb9764fcc280e9d6b52669534c026ba
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date:   Mon Feb 21 16:53:10 2011 -0800

    Fix __if_freereq crash: Unlike the generic version which uses free, Hurd needs munmap.
    
    (cherry picked from commit 6c8a2e88d12b7341440ac9669db0448223deb381)

diff --git a/ChangeLog b/ChangeLog
index 25c8e7e..dd8f114 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-02-22  Samuel Thibault  <samuel.thibault@ens-lyon.org>
+
+        Fix __if_freereq crash: Unlike the generic version which uses free,
+	Hurd needs munmap.
+	* sysdeps/mach/hurd/ifreq.h: New file.
+
 2011-01-27  Petr Baudis  <pasky@suse.cz>
 	    Ulrich Drepper  <drepper@gmail.com>
 
diff --git a/sysdeps/mach/hurd/ifreq.h b/sysdeps/mach/hurd/ifreq.h
new file mode 100644
index 0000000..92cb7b9
--- /dev/null
+++ b/sysdeps/mach/hurd/ifreq.h
@@ -0,0 +1,45 @@
+/* Copyright (C) 1999, 2002, 2003, 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Andreas Jaeger <aj@suse.de>.
+
+   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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+static inline struct ifreq *
+__if_nextreq (struct ifreq *ifr)
+{
+#ifdef _HAVE_SA_LEN
+  if (ifr->ifr_addr.sa_len > sizeof ifr->ifr_addr)
+    return (struct ifreq *) ((char *) &ifr->ifr_addr + ifr->ifr_addr.sa_len);
+#endif
+  return ifr + 1;
+}
+
+extern void __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd);
+
+
+static inline void
+__if_freereq (struct ifreq *ifreqs, int num_ifs)
+{
+  munmap (ifreqs, num_ifs * sizeof (struct ifreq));
+}

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=a4fd88c0fcf4e51825a540820bc9a95081f4f9fb

commit a4fd88c0fcf4e51825a540820bc9a95081f4f9fb
Author: Petr Baudis <pasky@suse.cz>
Date:   Sun Feb 20 13:59:49 2011 +0100

    Fix allocation when handling positional parameters in printf.
    
    (cherry picked from commit 84a4211850e3d23a9d3a4f3b294752a3b30bc0ff)

diff --git a/ChangeLog b/ChangeLog
index 17c436d..25c8e7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-01-27  Petr Baudis  <pasky@suse.cz>
+	    Ulrich Drepper  <drepper@gmail.com>
+
+	[BZ #12445]
+	* stdio-common/vfprintf.c (vfprintf): Pass correct newlen
+	to extend_alloca().
+	* stdio-common/bug23.c: New file.
+	* stdio-common/Makefile (tests): Add bug23.
+
 2011-02-16  Ryan S. Arnold  <rsa@us.ibm.com>
 
 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h:
diff --git a/stdio-common/Makefile b/stdio-common/Makefile
index 6aabfb6..6c71f1c 100644
--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -60,7 +60,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
 	 tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
 	 tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a \
 	 bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21 bug22 \
-	 scanf16 scanf17 tst-setvbuf1 tst-grouping
+	 scanf16 scanf17 tst-setvbuf1 tst-grouping bug23
 
 test-srcs = tst-unbputc tst-printf
 
diff --git a/stdio-common/bug23.c b/stdio-common/bug23.c
new file mode 100644
index 0000000..dcc5428
--- /dev/null
+++ b/stdio-common/bug23.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <string.h>
+
+static char buf[32768];
+static const char expected[] = "\
+\n\
+a\n\
+abbcd55%%%%%%%%%%%%%%%%%%%%%%%%%%\n";
+
+static int
+do_test (void)
+{
+  snprintf (buf, sizeof (buf),
+	    "\n%1$s\n" "%1$s" "%2$s" "%2$s" "%3$s" "%4$s" "%5$d" "%5$d"
+	    "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n",
+	    "a", "b", "c", "d", 5);
+  return strcmp (buf, expected) != 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index 6e0e85c..ab7fa13 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2008, 2009   Free Software Foundation, Inc.
+/* Copyright (C) 1991-2008, 2009, 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
@@ -1676,7 +1676,8 @@ do_positional:
 	  {
 	    /* Extend the array of format specifiers.  */
 	    struct printf_spec *old = specs;
-	    specs = extend_alloca (specs, nspecs_max, 2 * nspecs_max);
+	    specs = extend_alloca (specs, nspecs_max,
+				   2 * nspecs_max * sizeof (*specs));
 
 	    /* Copy the old array's elements to the new space.  */
 	    memmove (specs, old, nspecs * sizeof (struct printf_spec));

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c55cc45ed76603b380489ee8c91ab5dce92e92f1

commit c55cc45ed76603b380489ee8c91ab5dce92e92f1
Author: Ryan S. Arnold <rsa@us.ibm.com>
Date:   Thu Feb 17 01:21:08 2011 -0500

    Fix INTERNAL_[V]SYSCALL_NCS macros to not cast return val to int.
    
    (cherry picked from commit d55fd7a5573ea7c7c14af95bc37618469cde8a5f)

diff --git a/ChangeLog b/ChangeLog
index 9d07a90..17c436d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-02-16  Ryan S. Arnold  <rsa@us.ibm.com>
+
+	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h:
+	(INTERNAL_VSYSCALL_NCS INTERNAL_SYSCALL_NCS): Remove erroneous (int)
+	cast from r3.
+	* sysdeps/wordsize-64/Makefile: New file.  Add tst-writev to
+	'tests' variable.
+	* sysdeps/wordsize-64/tst-writev.c: New file.
+
 2011-02-15  Ryan S. Arnold  <rsa@us.ibm.com>
 
 	* sysdeps/powerpc/powerpc64/power7/Makefile: New file which adds
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index aab4b72..e714c4c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -172,7 +172,7 @@
        : "r9", "r10", "r11", "r12",					\
          "cr0", "ctr", "lr", "memory");					\
 	  err = (long int) r0;						\
-    (int) r3;								\
+    r3;								\
   })
 
 #undef INLINE_SYSCALL
@@ -219,7 +219,7 @@
        : "r9", "r10", "r11", "r12",					\
          "cr0", "ctr", "memory");					\
 	  err = r0;  \
-    (int) r3;  \
+    r3;  \
   })
 #define INTERNAL_SYSCALL(name, err, nr, args...)			\
   INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, args)
diff --git a/sysdeps/wordsize-64/Makefile b/sysdeps/wordsize-64/Makefile
new file mode 100644
index 0000000..9903f51
--- /dev/null
+++ b/sysdeps/wordsize-64/Makefile
@@ -0,0 +1,6 @@
+ifeq ($(subdir),misc)
+tests += tst-writev
+
+# Time enough for a large writev syscall to complete.
+tst-writev-ENV = TIMEOUTFACTOR="10"
+endif
diff --git a/sysdeps/wordsize-64/tst-writev.c b/sysdeps/wordsize-64/tst-writev.c
new file mode 100644
index 0000000..6e47886
--- /dev/null
+++ b/sysdeps/wordsize-64/tst-writev.c
@@ -0,0 +1,107 @@
+/* Copyright (C) 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ryan S. Arnold <rsa@us.ibm.com>, 2011.
+
+   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 <fcntl.h>
+#include <paths.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/uio.h>
+
+
+/* The purpose of this test is to verify that the INTERNAL_[V]SYSCALL_NCS
+   macros on 64-bit platforms don't cast the return type to (int) which would
+   erroneously sign extend the return value should the high bit of the bottom
+   half of the word be '1'.  */
+
+#if 0
+/* Used to test the non power-of-2 code path.  */
+#undef IOV_MAX
+#define IOV_MAX 1000
+#endif
+
+/* writev() should report that it has written EXPECTED number of bytes.  */
+#define EXPECTED ((size_t) INT32_MAX + 1)
+
+static int
+do_test (void)
+{
+  struct iovec iv[IOV_MAX];
+  /* POSIX doesn't guarantee that IOV_MAX is pow of 2 but we're optimistic.  */
+  size_t bufsz = EXPECTED / IOV_MAX;
+  size_t bufrem = EXPECTED % IOV_MAX;
+
+  /* If there's a remainder then IOV_MAX probably isn't a power of 2 and we
+     need to make bufsz bigger so that the last iovec, iv[IOV_MAX-1], is free
+     for the remainder.  */
+  if (bufrem)
+    {
+      bufsz = bufsz + 1;
+      bufrem = EXPECTED - (bufsz * (IOV_MAX - 1));
+    }
+
+  /* We writev to /dev/null since we're just testing writev's return value.  */
+  int fd = open (_PATH_DEVNULL, O_WRONLY);
+  if (fd == -1)
+    {
+      printf ("Unable to open /dev/null for writing.\n");
+      return -1;
+    }
+
+  iv[0].iov_base = malloc (bufsz);
+  if (iv[0].iov_base == NULL)
+    {
+      printf ("malloc (%zu) failed.\n", bufsz);
+      close (fd);
+      return -1;
+    }
+  iv[0].iov_len = bufsz;
+
+  /* We optimistically presume that there isn't a remainder and set all iovec
+     instances to the same base and len as the first instance.  */
+  for (int i = 1; i < IOV_MAX; i++)
+    {
+      /* We don't care what the data is so reuse the allocation from iv[0];  */
+      iv[i].iov_base = iv[0].iov_base;
+      iv[i].iov_len = iv[0].iov_len;
+    }
+
+  /* If there is a remainder then we correct the last iov_len.  */
+  if (bufrem)
+    iv[IOV_MAX - 1].iov_len = bufrem;
+
+  /* Write junk to /dev/null with the writev syscall in order to get a return
+     of INT32_MAX+1 bytes to verify that the INTERNAL_SYSCALL wrappers aren't
+     mangling the result if the signbit of a 32-bit number is set.  */
+  ssize_t ret = writev (fd, iv, IOV_MAX);
+
+  free (iv[0].iov_base);
+  close (fd);
+
+  if (ret != (ssize_t) EXPECTED)
+    {
+      printf ("writev() return value: %zd != EXPECTED: %zd\n", ret, EXPECTED);
+      return 1;
+    }
+
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=758c66a2344d9c88f320e180d785f214f77f9943

commit 758c66a2344d9c88f320e180d785f214f77f9943
Author: Ryan S. Arnold <rsa@us.ibm.com>
Date:   Thu Feb 17 00:59:15 2011 -0500

    Disable VSX usage in rtld.c to prevent TOC ref before relocs are resolved.
    
    (cherry picked from commit 2206397e1c46f69fb20eeb3de1920d3a7014c325)

diff --git a/ChangeLog b/ChangeLog
index 08bb5de..9d07a90 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-02-15  Ryan S. Arnold  <rsa@us.ibm.com>
+
+	* sysdeps/powerpc/powerpc64/power7/Makefile: New file which adds
+	-mno-vsx to the CFLAGS-rtld.c variable to avoid using VSX registers and
+	insns in _dl_start to prevent a TOC reference before relocs are
+	resolved.
+
 2011-02-11  Jakub Jelinek  <jakub@redhat.com>
 
 	* stdio-common/printf-parsemb.c (__parse_one_specmb): Handle
diff --git a/sysdeps/powerpc/powerpc64/power7/Makefile b/sysdeps/powerpc/powerpc64/power7/Makefile
new file mode 100644
index 0000000..b0f4520
--- /dev/null
+++ b/sysdeps/powerpc/powerpc64/power7/Makefile
@@ -0,0 +1,5 @@
+ifeq ($(subdir),elf)
+# Prevent the use of VSX registers and insns in _dl_start, which under -O3
+# optimization may require a TOC reference before relocations are resolved.
+CFLAGS-rtld.c += -mno-vsx
+endif

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=44092c71f67e4dbf9c56c7a7aff06bd7e81446b0

commit 44092c71f67e4dbf9c56c7a7aff06bd7e81446b0
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Feb 15 13:51:48 2011 -0500

    Fix two printf handler issues.
    
    (cherry picked from commit c1d0e639a95d6d3d3f1c1f70cf97d596bd5a24ec)

diff --git a/ChangeLog b/ChangeLog
index 3d76b4d..08bb5de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-02-11  Jakub Jelinek  <jakub@redhat.com>
+
+	* stdio-common/printf-parsemb.c (__parse_one_specmb): Handle
+	arginfo fn returning -1.
+
+	* stdio-common/_i18n_number.h (_i18n_number_rewrite): Ensure decimal
+	and thousands string is zero terminated.
+
 2011-02-02  Ulrich Drepper  <drepper@gmail.com>
 
 	* elf/dl-runtime.c (_dl_call_pltexit): Pass correct address of the
diff --git a/stdio-common/_i18n_number.h b/stdio-common/_i18n_number.h
index 8bb5619..43ed17e 100644
--- a/stdio-common/_i18n_number.h
+++ b/stdio-common/_i18n_number.h
@@ -30,8 +30,8 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
 # define decimal NULL
 # define thousands NULL
 #else
-  char decimal[MB_LEN_MAX];
-  char thousands[MB_LEN_MAX];
+  char decimal[MB_LEN_MAX + 1];
+  char thousands[MB_LEN_MAX + 1];
 #endif
 
   /* "to_outpunct" is a map from ASCII decimal point and thousands-sep
@@ -47,13 +47,19 @@ _i18n_number_rewrite (CHAR_T *w, CHAR_T *rear_ptr, CHAR_T *end)
       mbstate_t state;
       memset (&state, '\0', sizeof (state));
 
-      if (__wcrtomb (decimal, wdecimal, &state) == (size_t) -1)
+      size_t n = __wcrtomb (decimal, wdecimal, &state);
+      if (n == (size_t) -1)
 	memcpy (decimal, ".", 2);
+      else
+	decimal[n] = '\0';
 
       memset (&state, '\0', sizeof (state));
 
-      if (__wcrtomb (thousands, wthousands, &state) == (size_t) -1)
+      n = __wcrtomb (thousands, wthousands, &state);
+      if (n == (size_t) -1)
 	memcpy (thousands, ",", 2);
+      else
+	thousands[n] = '\0';
     }
 #endif
 
diff --git a/stdio-common/printf-parsemb.c b/stdio-common/printf-parsemb.c
index efd1eca..a67cc1a 100644
--- a/stdio-common/printf-parsemb.c
+++ b/stdio-common/printf-parsemb.c
@@ -295,9 +295,9 @@ __parse_one_specmb (const UCHAR_T *format, size_t posn,
       /* We don't try to get the types for all arguments if the format
 	 uses more than one.  The normal case is covered though.  If
 	 the call returns -1 we continue with the normal specifiers.  */
-      || (spec->ndata_args = (*__printf_arginfo_table[spec->info.spec])
-	  (&spec->info, 1, &spec->data_arg_type,
-	   &spec->size)) < 0)
+      || (int) (spec->ndata_args = (*__printf_arginfo_table[spec->info.spec])
+				   (&spec->info, 1, &spec->data_arg_type,
+				    &spec->size)) < 0)
     {
       /* Find the data argument types of a built-in spec.  */
       spec->ndata_args = 1;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |  243 ++++++++++++++++++++
 conform/data/netdb.h-data                          |    2 +-
 elf/Makefile                                       |    6 +-
 elf/dl-close.c                                     |   15 +-
 elf/dl-deps.c                                      |   10 +-
 elf/dl-load.c                                      |  170 +++++++++++---
 elf/dl-lookup.c                                    |   64 +++---
 elf/dl-tls.c                                       |    5 +-
 elf/ldconfig.c                                     |   15 +-
 elf/noload.c                                       |   22 ++-
 iconv/loop.c                                       |    5 +-
 include/link.h                                     |    5 +-
 inet/getnameinfo.c                                 |    4 +-
 libio/Makefile                                     |    4 +-
 libio/bug-fclose1.c                                |  132 +++++++++++
 libio/fileops.c                                    |   48 +++--
 libio/fmemopen.c                                   |    4 +-
 login/programs/pt_chown.c                          |    4 +-
 math/Makefile                                      |    4 +-
 math/test-powl.c                                   |   51 ++++
 misc/error.c                                       |    6 +-
 misc/mntent_r.c                                    |    6 +-
 nptl/ChangeLog                                     |   12 +
 nptl/allocatestack.c                               |    9 +-
 posix/fnmatch.c                                    |   13 +-
 resolv/netdb.h                                     |    4 +-
 resolv/res_debug.c                                 |    5 +-
 resolv/res_init.c                                  |    5 +
 resolv/res_query.c                                 |   14 +-
 resolv/resolv.h                                    |    4 +-
 stdio-common/Makefile                              |    2 +-
 stdio-common/_i18n_number.h                        |   14 +-
 stdio-common/bug23.c                               |   21 ++
 stdio-common/printf-parsemb.c                      |    6 +-
 stdio-common/vfprintf.c                            |    5 +-
 stdlib/Makefile                                    |   11 +-
 stdlib/bug-getcontext.c                            |   48 ++++
 sysdeps/i386/dl-tls.h                              |    5 +-
 sysdeps/ia64/dl-tls.h                              |    5 +-
 sysdeps/mach/hurd/ifreq.h                          |   45 ++++
 sysdeps/posix/spawni.c                             |    4 +-
 sysdeps/powerpc/dl-tls.h                           |    5 +-
 sysdeps/powerpc/powerpc32/power6/fpu/s_isnanf.S    |    5 +-
 sysdeps/powerpc/powerpc64/power7/Makefile          |    5 +
 sysdeps/pthread/aio_misc.c                         |    8 +-
 sysdeps/s390/dl-tls.h                              |    7 +-
 sysdeps/sh/dl-tls.h                                |    5 +-
 sysdeps/sparc/dl-tls.h                             |    5 +-
 sysdeps/unix/sysv/linux/Makefile                   |    2 +-
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h |    4 +-
 sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S   |   26 ++-
 sysdeps/unix/sysv/linux/x86_64/getcontext.S        |    3 +-
 sysdeps/wordsize-64/Makefile                       |    6 +
 sysdeps/wordsize-64/tst-writev.c                   |  107 +++++++++
 sysdeps/x86_64/dl-tls.h                            |    5 +-
 sysdeps/x86_64/fpu/e_powl.S                        |    4 +-
 wcsmbs/wchar.h                                     |    3 +-
 57 files changed, 1065 insertions(+), 192 deletions(-)
 create mode 100644 libio/bug-fclose1.c
 create mode 100644 math/test-powl.c
 create mode 100644 stdio-common/bug23.c
 create mode 100644 stdlib/bug-getcontext.c
 create mode 100644 sysdeps/mach/hurd/ifreq.h
 create mode 100644 sysdeps/powerpc/powerpc64/power7/Makefile
 create mode 100644 sysdeps/wordsize-64/Makefile
 create mode 100644 sysdeps/wordsize-64/tst-writev.c


hooks/post-receive
-- 
GNU C Library master sources


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