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 master updated. glibc-2.16-ports-merge-437-g53cea63


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, master has been updated
       via  53cea63e99264bf81b278546581d6c2efc2c3fc5 (commit)
       via  1d1b34df90b1c20ed0c56162e31e912c5b931af2 (commit)
       via  bb859b06ddb311005266c3576bc46b1fe751d8d3 (commit)
       via  9cee55856438b714fa1efa45d8b7c1857467f4ca (commit)
      from  28234b077ec6667b5dd0a6b60c6d8dbd9e28f6e1 (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=53cea63e99264bf81b278546581d6c2efc2c3fc5

commit 53cea63e99264bf81b278546581d6c2efc2c3fc5
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 5 10:26:29 2012 -0700

    Move _dl_important_hwcaps to dl-hwcaps.c

diff --git a/ChangeLog b/ChangeLog
index 162c5d7..4ecb9d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2012-10-05  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* elf/Makefile (dl-routines): Add hwcaps.
+	* elf/dl-support.c (_dl_important_hwcaps): Removed.
+	* elf/dl-sysdep.c (_DL_FIRST_EXTRA): Likewise.
+	(_dl_important_hwcaps): Moved to ...
+	* elf/dl-hwcaps.c: Here.  New file.
+	* sysdeps/mach/hurd/dl-sysdep.c (_dl_important_hwcaps): Removed.
+
 	[BZ #14557]
 	* elf/setup-vdso.h (setup_vdso): Set GL(dl_nns) to 1 for vDSO
 	if IS_IN_rtld isn't defined.
diff --git a/elf/Makefile b/elf/Makefile
index 58cc15c..e91c3b4 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -28,7 +28,7 @@ routines	= $(dl-routines) dl-support dl-iteratephdr \
 
 # The core dynamic linking functions are in libc for the static and
 # profiled libraries.
-dl-routines	= $(addprefix dl-,load lookup object reloc deps \
+dl-routines	= $(addprefix dl-,load lookup object reloc deps hwcaps \
 				  runtime error init fini debug misc \
 				  version profile conflict tls origin scope \
 				  execstack caller open close trampoline)
diff --git a/elf/dl-hwcaps.c b/elf/dl-hwcaps.c
new file mode 100644
index 0000000..d911548
--- /dev/null
+++ b/elf/dl-hwcaps.c
@@ -0,0 +1,279 @@
+/* Hardware capability support for run-time dynamic loader.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+#include <elf.h>
+#include <errno.h>
+#include <libintl.h>
+#include <unistd.h>
+#include <ldsodefs.h>
+
+#include <dl-procinfo.h>
+
+#ifdef _DL_FIRST_PLATFORM
+# define _DL_FIRST_EXTRA (_DL_FIRST_PLATFORM + _DL_PLATFORMS_COUNT)
+#else
+# define _DL_FIRST_EXTRA _DL_HWCAP_COUNT
+#endif
+
+/* Return an array of useful/necessary hardware capability names.  */
+const struct r_strlenpair *
+internal_function
+_dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
+		      size_t *max_capstrlen)
+{
+  /* Determine how many important bits are set.  */
+  uint64_t masked = GLRO(dl_hwcap) & GLRO(dl_hwcap_mask);
+  size_t cnt = platform != NULL;
+  size_t n, m;
+  size_t total;
+  struct r_strlenpair *temp;
+  struct r_strlenpair *result;
+  struct r_strlenpair *rp;
+  char *cp;
+
+  /* Count the number of bits set in the masked value.  */
+  for (n = 0; (~((1ULL << n) - 1) & masked) != 0; ++n)
+    if ((masked & (1ULL << n)) != 0)
+      ++cnt;
+
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
+  /* The system-supplied DSO can contain a note of type 2, vendor "GNU".
+     This gives us a list of names to treat as fake hwcap bits.  */
+
+  const char *dsocaps = NULL;
+  size_t dsocapslen = 0;
+  if (GLRO(dl_sysinfo_map) != NULL)
+    {
+      const ElfW(Phdr) *const phdr = GLRO(dl_sysinfo_map)->l_phdr;
+      const ElfW(Word) phnum = GLRO(dl_sysinfo_map)->l_phnum;
+      for (uint_fast16_t i = 0; i < phnum; ++i)
+	if (phdr[i].p_type == PT_NOTE)
+	  {
+	    const ElfW(Addr) start = (phdr[i].p_vaddr
+				      + GLRO(dl_sysinfo_map)->l_addr);
+	    const struct
+	    {
+	      ElfW(Word) vendorlen;
+	      ElfW(Word) datalen;
+	      ElfW(Word) type;
+	    } *note = (const void *) start;
+	    while ((ElfW(Addr)) (note + 1) - start < phdr[i].p_memsz)
+	      {
+#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
+		if (note->type == NT_GNU_HWCAP
+		    && note->vendorlen == sizeof "GNU"
+		    && !memcmp ((note + 1), "GNU", sizeof "GNU")
+		    && note->datalen > 2 * sizeof (ElfW(Word)) + 2)
+		  {
+		    const ElfW(Word) *p = ((const void *) (note + 1)
+					   + ROUND (sizeof "GNU"));
+		    cnt += *p++;
+		    ++p;	/* Skip mask word.  */
+		    dsocaps = (const char *) p;
+		    dsocapslen = note->datalen - sizeof *p * 2;
+		    break;
+		  }
+		note = ((const void *) (note + 1)
+			+ ROUND (note->vendorlen) + ROUND (note->datalen));
+#undef ROUND
+	      }
+	    if (dsocaps != NULL)
+	      break;
+	  }
+    }
+#endif
+
+  /* For TLS enabled builds always add 'tls'.  */
+  ++cnt;
+
+  /* Create temporary data structure to generate result table.  */
+  temp = (struct r_strlenpair *) alloca (cnt * sizeof (*temp));
+  m = 0;
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
+  if (dsocaps != NULL)
+    {
+      const ElfW(Word) mask = ((const ElfW(Word) *) dsocaps)[-1];
+      GLRO(dl_hwcap) |= (uint64_t) mask << _DL_FIRST_EXTRA;
+      /* Note that we add the dsocaps to the set already chosen by the
+	 LD_HWCAP_MASK environment variable (or default HWCAP_IMPORTANT).
+	 So there is no way to request ignoring an OS-supplied dsocap
+	 string and bit like you can ignore an OS-supplied HWCAP bit.  */
+      GLRO(dl_hwcap_mask) |= (uint64_t) mask << _DL_FIRST_EXTRA;
+      size_t len;
+      for (const char *p = dsocaps; p < dsocaps + dsocapslen; p += len + 1)
+	{
+	  uint_fast8_t bit = *p++;
+	  len = strlen (p);
+
+	  /* Skip entries that are not enabled in the mask word.  */
+	  if (__builtin_expect (mask & ((ElfW(Word)) 1 << bit), 1))
+	    {
+	      temp[m].str = p;
+	      temp[m].len = len;
+	      ++m;
+	    }
+	  else
+	    --cnt;
+	}
+    }
+#endif
+  for (n = 0; masked != 0; ++n)
+    if ((masked & (1ULL << n)) != 0)
+      {
+	temp[m].str = _dl_hwcap_string (n);
+	temp[m].len = strlen (temp[m].str);
+	masked ^= 1ULL << n;
+	++m;
+      }
+  if (platform != NULL)
+    {
+      temp[m].str = platform;
+      temp[m].len = platform_len;
+      ++m;
+    }
+
+  temp[m].str = "tls";
+  temp[m].len = 3;
+  ++m;
+
+  assert (m == cnt);
+
+  /* Determine the total size of all strings together.  */
+  if (cnt == 1)
+    total = temp[0].len + 1;
+  else
+    {
+      total = temp[0].len + temp[cnt - 1].len + 2;
+      if (cnt > 2)
+	{
+	  total <<= 1;
+	  for (n = 1; n + 1 < cnt; ++n)
+	    total += temp[n].len + 1;
+	  if (cnt > 3
+	      && (cnt >= sizeof (size_t) * 8
+		  || total + (sizeof (*result) << 3)
+		     >= (1UL << (sizeof (size_t) * 8 - cnt + 3))))
+	    _dl_signal_error (ENOMEM, NULL, NULL,
+			      N_("cannot create capability list"));
+
+	  total <<= cnt - 3;
+	}
+    }
+
+  /* The result structure: we use a very compressed way to store the
+     various combinations of capability names.  */
+  *sz = 1 << cnt;
+  result = (struct r_strlenpair *) malloc (*sz * sizeof (*result) + total);
+  if (result == NULL)
+    _dl_signal_error (ENOMEM, NULL, NULL,
+		      N_("cannot create capability list"));
+
+  if (cnt == 1)
+    {
+      result[0].str = (char *) (result + *sz);
+      result[0].len = temp[0].len + 1;
+      result[1].str = (char *) (result + *sz);
+      result[1].len = 0;
+      cp = __mempcpy ((char *) (result + *sz), temp[0].str, temp[0].len);
+      *cp = '/';
+      *sz = 2;
+      *max_capstrlen = result[0].len;
+
+      return result;
+    }
+
+  /* Fill in the information.  This follows the following scheme
+     (indeces from TEMP for four strings):
+	entry #0: 0, 1, 2, 3	binary: 1111
+	      #1: 0, 1, 3		1101
+	      #2: 0, 2, 3		1011
+	      #3: 0, 3			1001
+     This allows the representation of all possible combinations of
+     capability names in the string.  First generate the strings.  */
+  result[1].str = result[0].str = cp = (char *) (result + *sz);
+#define add(idx) \
+      cp = __mempcpy (__mempcpy (cp, temp[idx].str, temp[idx].len), "/", 1);
+  if (cnt == 2)
+    {
+      add (1);
+      add (0);
+    }
+  else
+    {
+      n = 1 << (cnt - 1);
+      do
+	{
+	  n -= 2;
+
+	  /* We always add the last string.  */
+	  add (cnt - 1);
+
+	  /* Add the strings which have the bit set in N.  */
+	  for (m = cnt - 2; m > 0; --m)
+	    if ((n & (1 << m)) != 0)
+	      add (m);
+
+	  /* Always add the first string.  */
+	  add (0);
+	}
+      while (n != 0);
+    }
+#undef add
+
+  /* Now we are ready to install the string pointers and length.  */
+  for (n = 0; n < (1UL << cnt); ++n)
+    result[n].len = 0;
+  n = cnt;
+  do
+    {
+      size_t mask = 1 << --n;
+
+      rp = result;
+      for (m = 1 << cnt; m > 0; ++rp)
+	if ((--m & mask) != 0)
+	  rp->len += temp[n].len + 1;
+    }
+  while (n != 0);
+
+  /* The first half of the strings all include the first string.  */
+  n = (1 << cnt) - 2;
+  rp = &result[2];
+  while (n != (1UL << (cnt - 1)))
+    {
+      if ((--n & 1) != 0)
+	rp[0].str = rp[-2].str + rp[-2].len;
+      else
+	rp[0].str = rp[-1].str;
+      ++rp;
+    }
+
+  /* The second half starts right after the first part of the string of
+     the corresponding entry in the first half.  */
+  do
+    {
+      rp[0].str = rp[-(1 << (cnt - 1))].str + temp[cnt - 1].len + 1;
+      ++rp;
+    }
+  while (--n != 0);
+
+  /* The maximum string length.  */
+  *max_capstrlen = result[0].len;
+
+  return result;
+}
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 424ca6d..fd72c1b 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -335,23 +335,6 @@ _dl_non_dynamic_init (void)
 	}
 }
 
-
-const struct r_strlenpair *
-internal_function
-_dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
-		      size_t *max_capstrlen)
-{
-  static struct r_strlenpair result;
-  static char buf[1];
-
-  result.str = buf;	/* Does not really matter.  */
-  result.len = 0;
-
-  *sz = 1;
-  return &result;
-}
-
-
 #ifdef DL_SYSINFO_IMPLEMENTATION
 DL_SYSINFO_IMPLEMENTATION
 #endif
diff --git a/elf/dl-sysdep.c b/elf/dl-sysdep.c
index fb0849a..65a9046 100644
--- a/elf/dl-sysdep.c
+++ b/elf/dl-sysdep.c
@@ -44,12 +44,6 @@
 #include <hp-timing.h>
 #include <tls.h>
 
-#ifdef _DL_FIRST_PLATFORM
-# define _DL_FIRST_EXTRA (_DL_FIRST_PLATFORM + _DL_PLATFORMS_COUNT)
-#else
-# define _DL_FIRST_EXTRA _DL_HWCAP_COUNT
-#endif
-
 extern char **_environ attribute_hidden;
 extern char _end[] attribute_hidden;
 
@@ -350,252 +344,4 @@ _dl_show_auxv (void)
     }
 }
 
-
-/* Return an array of useful/necessary hardware capability names.  */
-const struct r_strlenpair *
-internal_function
-_dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
-		      size_t *max_capstrlen)
-{
-  /* Determine how many important bits are set.  */
-  uint64_t masked = GLRO(dl_hwcap) & GLRO(dl_hwcap_mask);
-  size_t cnt = platform != NULL;
-  size_t n, m;
-  size_t total;
-  struct r_strlenpair *temp;
-  struct r_strlenpair *result;
-  struct r_strlenpair *rp;
-  char *cp;
-
-  /* Count the number of bits set in the masked value.  */
-  for (n = 0; (~((1ULL << n) - 1) & masked) != 0; ++n)
-    if ((masked & (1ULL << n)) != 0)
-      ++cnt;
-
-#if (defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO) && defined SHARED
-  /* The system-supplied DSO can contain a note of type 2, vendor "GNU".
-     This gives us a list of names to treat as fake hwcap bits.  */
-
-  const char *dsocaps = NULL;
-  size_t dsocapslen = 0;
-  if (GLRO(dl_sysinfo_map) != NULL)
-    {
-      const ElfW(Phdr) *const phdr = GLRO(dl_sysinfo_map)->l_phdr;
-      const ElfW(Word) phnum = GLRO(dl_sysinfo_map)->l_phnum;
-      for (uint_fast16_t i = 0; i < phnum; ++i)
-	if (phdr[i].p_type == PT_NOTE)
-	  {
-	    const ElfW(Addr) start = (phdr[i].p_vaddr
-				      + GLRO(dl_sysinfo_map)->l_addr);
-	    const struct
-	    {
-	      ElfW(Word) vendorlen;
-	      ElfW(Word) datalen;
-	      ElfW(Word) type;
-	    } *note = (const void *) start;
-	    while ((ElfW(Addr)) (note + 1) - start < phdr[i].p_memsz)
-	      {
-#define ROUND(len) (((len) + sizeof (ElfW(Word)) - 1) & -sizeof (ElfW(Word)))
-		if (note->type == NT_GNU_HWCAP
-		    && note->vendorlen == sizeof "GNU"
-		    && !memcmp ((note + 1), "GNU", sizeof "GNU")
-		    && note->datalen > 2 * sizeof (ElfW(Word)) + 2)
-		  {
-		    const ElfW(Word) *p = ((const void *) (note + 1)
-					   + ROUND (sizeof "GNU"));
-		    cnt += *p++;
-		    ++p;	/* Skip mask word.  */
-		    dsocaps = (const char *) p;
-		    dsocapslen = note->datalen - sizeof *p * 2;
-		    break;
-		  }
-		note = ((const void *) (note + 1)
-			+ ROUND (note->vendorlen) + ROUND (note->datalen));
-#undef ROUND
-	      }
-	    if (dsocaps != NULL)
-	      break;
-	  }
-    }
-#endif
-
-  /* For TLS enabled builds always add 'tls'.  */
-  ++cnt;
-
-  /* Create temporary data structure to generate result table.  */
-  temp = (struct r_strlenpair *) alloca (cnt * sizeof (*temp));
-  m = 0;
-#if (defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO) && defined SHARED
-  if (dsocaps != NULL)
-    {
-      const ElfW(Word) mask = ((const ElfW(Word) *) dsocaps)[-1];
-      GLRO(dl_hwcap) |= (uint64_t) mask << _DL_FIRST_EXTRA;
-      /* Note that we add the dsocaps to the set already chosen by the
-	 LD_HWCAP_MASK environment variable (or default HWCAP_IMPORTANT).
-	 So there is no way to request ignoring an OS-supplied dsocap
-	 string and bit like you can ignore an OS-supplied HWCAP bit.  */
-      GLRO(dl_hwcap_mask) |= (uint64_t) mask << _DL_FIRST_EXTRA;
-      size_t len;
-      for (const char *p = dsocaps; p < dsocaps + dsocapslen; p += len + 1)
-	{
-	  uint_fast8_t bit = *p++;
-	  len = strlen (p);
-
-	  /* Skip entries that are not enabled in the mask word.  */
-	  if (__builtin_expect (mask & ((ElfW(Word)) 1 << bit), 1))
-	    {
-	      temp[m].str = p;
-	      temp[m].len = len;
-	      ++m;
-	    }
-	  else
-	    --cnt;
-	}
-    }
-#endif
-  for (n = 0; masked != 0; ++n)
-    if ((masked & (1ULL << n)) != 0)
-      {
-	temp[m].str = _dl_hwcap_string (n);
-	temp[m].len = strlen (temp[m].str);
-	masked ^= 1ULL << n;
-	++m;
-      }
-  if (platform != NULL)
-    {
-      temp[m].str = platform;
-      temp[m].len = platform_len;
-      ++m;
-    }
-
-  temp[m].str = "tls";
-  temp[m].len = 3;
-  ++m;
-
-  assert (m == cnt);
-
-  /* Determine the total size of all strings together.  */
-  if (cnt == 1)
-    total = temp[0].len + 1;
-  else
-    {
-      total = temp[0].len + temp[cnt - 1].len + 2;
-      if (cnt > 2)
-	{
-	  total <<= 1;
-	  for (n = 1; n + 1 < cnt; ++n)
-	    total += temp[n].len + 1;
-	  if (cnt > 3
-	      && (cnt >= sizeof (size_t) * 8
-		  || total + (sizeof (*result) << 3)
-		     >= (1UL << (sizeof (size_t) * 8 - cnt + 3))))
-	    _dl_signal_error (ENOMEM, NULL, NULL,
-			      N_("cannot create capability list"));
-
-	  total <<= cnt - 3;
-	}
-    }
-
-  /* The result structure: we use a very compressed way to store the
-     various combinations of capability names.  */
-  *sz = 1 << cnt;
-  result = (struct r_strlenpair *) malloc (*sz * sizeof (*result) + total);
-  if (result == NULL)
-    _dl_signal_error (ENOMEM, NULL, NULL,
-		      N_("cannot create capability list"));
-
-  if (cnt == 1)
-    {
-      result[0].str = (char *) (result + *sz);
-      result[0].len = temp[0].len + 1;
-      result[1].str = (char *) (result + *sz);
-      result[1].len = 0;
-      cp = __mempcpy ((char *) (result + *sz), temp[0].str, temp[0].len);
-      *cp = '/';
-      *sz = 2;
-      *max_capstrlen = result[0].len;
-
-      return result;
-    }
-
-  /* Fill in the information.  This follows the following scheme
-     (indeces from TEMP for four strings):
-	entry #0: 0, 1, 2, 3	binary: 1111
-	      #1: 0, 1, 3		1101
-	      #2: 0, 2, 3		1011
-	      #3: 0, 3			1001
-     This allows the representation of all possible combinations of
-     capability names in the string.  First generate the strings.  */
-  result[1].str = result[0].str = cp = (char *) (result + *sz);
-#define add(idx) \
-      cp = __mempcpy (__mempcpy (cp, temp[idx].str, temp[idx].len), "/", 1);
-  if (cnt == 2)
-    {
-      add (1);
-      add (0);
-    }
-  else
-    {
-      n = 1 << (cnt - 1);
-      do
-	{
-	  n -= 2;
-
-	  /* We always add the last string.  */
-	  add (cnt - 1);
-
-	  /* Add the strings which have the bit set in N.  */
-	  for (m = cnt - 2; m > 0; --m)
-	    if ((n & (1 << m)) != 0)
-	      add (m);
-
-	  /* Always add the first string.  */
-	  add (0);
-	}
-      while (n != 0);
-    }
-#undef add
-
-  /* Now we are ready to install the string pointers and length.  */
-  for (n = 0; n < (1UL << cnt); ++n)
-    result[n].len = 0;
-  n = cnt;
-  do
-    {
-      size_t mask = 1 << --n;
-
-      rp = result;
-      for (m = 1 << cnt; m > 0; ++rp)
-	if ((--m & mask) != 0)
-	  rp->len += temp[n].len + 1;
-    }
-  while (n != 0);
-
-  /* The first half of the strings all include the first string.  */
-  n = (1 << cnt) - 2;
-  rp = &result[2];
-  while (n != (1UL << (cnt - 1)))
-    {
-      if ((--n & 1) != 0)
-	rp[0].str = rp[-2].str + rp[-2].len;
-      else
-	rp[0].str = rp[-1].str;
-      ++rp;
-    }
-
-  /* The second half starts right after the first part of the string of
-     the corresponding entry in the first half.  */
-  do
-    {
-      rp[0].str = rp[-(1 << (cnt - 1))].str + temp[cnt - 1].len + 1;
-      ++rp;
-    }
-  while (--n != 0);
-
-  /* The maximum string length.  */
-  *max_capstrlen = result[0].len;
-
-  return result;
-}
-
 #endif
diff --git a/sysdeps/mach/hurd/dl-sysdep.c b/sysdeps/mach/hurd/dl-sysdep.c
index 13b0010..fad388b 100644
--- a/sysdeps/mach/hurd/dl-sysdep.c
+++ b/sysdeps/mach/hurd/dl-sysdep.c
@@ -646,26 +646,6 @@ _dl_show_auxv (void)
 }
 
 
-/* Return an array of useful/necessary hardware capability names.  */
-const struct r_strlenpair *
-internal_function
-_dl_important_hwcaps (const char *platform, size_t platform_len, size_t *sz,
-		      size_t *max_capstrlen)
-{
-  struct r_strlenpair *result;
-
-  /* Return an empty array.  Hurd has no hardware capabilities.  */
-  result = (struct r_strlenpair *) malloc (sizeof (*result));
-  if (result == NULL)
-    _dl_signal_error (ENOMEM, NULL, NULL, "cannot create capability list");
-
-  result[0].str = (char *) result;	/* Does not really matter.  */
-  result[0].len = 0;
-
-  *sz = 1;
-  return result;
-}
-
 void weak_function
 _dl_init_first (int argc, ...)
 {

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

commit 1d1b34df90b1c20ed0c56162e31e912c5b931af2
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 5 10:23:58 2012 -0700

    Add test cases for BZ #14557

diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 23b7753..78b1b93 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,18 @@
+2012-10-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #14557]
+	* Makefile (tests-static): Add tst-cancel24-static,
+	tst-cond8-static tst-mutex8-static, tst-mutexpi8-static,
+	tst-sem11-static and tst-sem12-static.
+	(tests): Likewise.
+	(LDLIBS-tst-cancel24-static): New macro.
+	* tst-cancel24-static.cc: New file.
+	* tst-cond8-static.c: Likewise.
+	* tst-mutex8-static.c: Likewise.
+	* tst-mutexpi8-static.c: Likewise.
+	* tst-sem11-static.c: Likewise.
+	* tst-sem12-static.c: Likewise.
+
 2012-10-05  Siddhesh Poyarekar  <siddhesh@redhat.com>
 
 	[BZ #14417]
diff --git a/nptl/Makefile b/nptl/Makefile
index f21276c..67c2627 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -351,8 +351,12 @@ link-libc-static := $(common-objpfx)libc.a $(static-gnulib) \
 		    $(common-objpfx)libc.a
 
 tests-static += tst-locale1 tst-locale2 tst-stackguard1-static \
-		tst-cancel21-static
-tests += tst-stackguard1-static tst-cancel21-static
+		tst-cancel21-static tst-cancel24-static tst-cond8-static \
+		tst-mutex8-static tst-mutexpi8-static tst-sem11-static \
+		tst-sem12-static
+tests += tst-stackguard1-static tst-cancel21-static tst-cancel24-static \
+	 tst-cond8-static tst-mutex8-static tst-mutexpi8-static \
+	 tst-sem11-static tst-sem12-static
 xtests-static += tst-setuid1-static
 
 # These tests are linked with libc before libpthread
@@ -510,6 +514,7 @@ $(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.a
 endif
 
 LDLIBS-tst-cancel24 = $(no-as-needed) -lstdc++
+LDLIBS-tst-cancel24-static = $(LDLIBS-tst-cancel24)
 
 extra-B-pthread.so = -B$(common-objpfx)nptl/
 $(objpfx)libpthread.so: $(addprefix $(objpfx),$(crti-objs) $(crtn-objs))
diff --git a/nptl/tst-cancel24-static.cc b/nptl/tst-cancel24-static.cc
new file mode 100644
index 0000000..3f97de5
--- /dev/null
+++ b/nptl/tst-cancel24-static.cc
@@ -0,0 +1 @@
+#include "tst-cancel24.cc"
diff --git a/nptl/tst-cond8-static.c b/nptl/tst-cond8-static.c
new file mode 100644
index 0000000..fed35db
--- /dev/null
+++ b/nptl/tst-cond8-static.c
@@ -0,0 +1 @@
+#include "tst-cond8.c"
diff --git a/nptl/tst-mutex8-static.c b/nptl/tst-mutex8-static.c
new file mode 100644
index 0000000..d69ed49
--- /dev/null
+++ b/nptl/tst-mutex8-static.c
@@ -0,0 +1 @@
+#include "tst-mutex8.c"
diff --git a/nptl/tst-mutexpi8-static.c b/nptl/tst-mutexpi8-static.c
new file mode 100644
index 0000000..869e6df
--- /dev/null
+++ b/nptl/tst-mutexpi8-static.c
@@ -0,0 +1 @@
+#include "tst-mutexpi8.c"
diff --git a/nptl/tst-sem11-static.c b/nptl/tst-sem11-static.c
new file mode 100644
index 0000000..09b7698
--- /dev/null
+++ b/nptl/tst-sem11-static.c
@@ -0,0 +1 @@
+#include "tst-sem11.c"
diff --git a/nptl/tst-sem12-static.c b/nptl/tst-sem12-static.c
new file mode 100644
index 0000000..c06349f
--- /dev/null
+++ b/nptl/tst-sem12-static.c
@@ -0,0 +1 @@
+#include "tst-sem12.c"

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

commit bb859b06ddb311005266c3576bc46b1fe751d8d3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 5 10:22:14 2012 -0700

    Set GL(dl_nns) to 1 for vDSO in libc.a

diff --git a/ChangeLog b/ChangeLog
index 090efd0..162c5d7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
 2012-10-05  H.J. Lu  <hongjiu.lu@intel.com>
 
 	[BZ #14557]
+	* elf/setup-vdso.h (setup_vdso): Set GL(dl_nns) to 1 for vDSO
+	if IS_IN_rtld isn't defined.
+
 	* elf/dl-support.c (_dl_sysinfo_map): New.
 	Include "get-dynamic-info.h" and "setup-vdso.h".
 	(_dl_non_dynamic_init): Call setup_vdso.
diff --git a/NEWS b/NEWS
index bd309ba..ce3e360 100644
--- a/NEWS
+++ b/NEWS
@@ -15,7 +15,8 @@ Version 2.17
   14173, 14195, 14237, 14251, 14252, 14283, 14298, 14303, 14307, 14328,
   14331, 14336, 14337, 14347, 14349, 14376, 14417, 14459, 14476, 14477,
   14505, 14510, 14516, 14518, 14519, 14530, 14532, 14538, 14543, 14544,
-  14545, 14562, 14576, 14579, 14583, 14587, 14621, 14638, 14645, 14648.
+  14545, 14557, 14562, 14576, 14579, 14583, 14587, 14621, 14638, 14645,
+  14648.
 
 * Support for STT_GNU_IFUNC symbols added for s390 and s390x.
   Optimized versions of memcpy, memset, and memcmp added for System z10 and
diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
index 1b969a0..f8f348a 100644
--- a/elf/setup-vdso.h
+++ b/elf/setup-vdso.h
@@ -106,6 +106,8 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
       GL(dl_rtld_map).l_next = l;
       l->l_prev = &GL(dl_rtld_map);
       *first_preload = &l->l_next;
+# else
+      GL(dl_nns) = 1;
 # endif
 
       /* We have a prelinked DSO preloaded by the system.  */

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

commit 9cee55856438b714fa1efa45d8b7c1857467f4ca
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Oct 5 10:20:39 2012 -0700

    Set up the data structures for vDSO in libc.a

diff --git a/ChangeLog b/ChangeLog
index 3d3fa6d..090efd0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2012-10-05  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #14557]
+	* elf/dl-support.c (_dl_sysinfo_map): New.
+	Include "get-dynamic-info.h" and "setup-vdso.h".
+	(_dl_non_dynamic_init): Call setup_vdso.
+	* elf/dynamic-link.h: Don't include <assert.h>.
+	(elf_get_dynamic_info): Moved to ...
+	* elf/get-dynamic-info.h: Here.  New file.
+	* elf/dynamic-link.h: Include "get-dynamic-info.h".
+	* elf/rtld.c (dl_main): Break out vDSO setup code into ...
+	* elf/setup-vdso.h: Here.  New file.
+	* elf/rtld.c: Include "setup-vdso.h".
+	(dl_main): Call setup_vdso.
+
 2012-10-05  Joseph Myers  <joseph@codesourcery.com>
 
 	* math/libm-test.inc: List nexttoward, cimag, clog10, conf and
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 2bb468a..424ca6d 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -161,6 +161,11 @@ uintptr_t _dl_sysinfo = DL_SYSINFO_DEFAULT;
 #if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
 /* Address of the ELF headers in the vsyscall page.  */
 const ElfW(Ehdr) *_dl_sysinfo_dso;
+
+struct link_map *_dl_sysinfo_map;
+
+# include "get-dynamic-info.h"
+# include "setup-vdso.h"
 #endif
 
 /* During the program run we must not modify the global data of
@@ -266,6 +271,10 @@ _dl_non_dynamic_init (void)
 
   _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;
 
+  /* Set up the data structures for the system-supplied DSO early,
+     so they can influence _dl_init_paths.  */
+  setup_vdso (NULL, NULL);
+
   /* Initialize the data structures for the search paths for shared
      objects.  */
   _dl_init_paths (getenv ("LD_LIBRARY_PATH"));
diff --git a/elf/dynamic-link.h b/elf/dynamic-link.h
index d982c52..ad30d23 100644
--- a/elf/dynamic-link.h
+++ b/elf/dynamic-link.h
@@ -42,7 +42,6 @@
 int internal_function _dl_try_allocate_static_tls (struct link_map *map);
 
 #include <elf.h>
-#include <assert.h>
 
 #ifdef RESOLVE_MAP
 /* We pass reloc_addr as a pointer to void, as opposed to a pointer to
@@ -88,149 +87,7 @@ elf_machine_lazy_rel (struct link_map *map,
 
 #include <dl-machine.h>
 
-
-/* Read the dynamic section at DYN and fill in INFO with indices DT_*.  */
-#ifndef RESOLVE_MAP
-static
-#else
-auto
-#endif
-inline void __attribute__ ((unused, always_inline))
-elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
-{
-  ElfW(Dyn) *dyn = l->l_ld;
-  ElfW(Dyn) **info;
-#if __ELF_NATIVE_CLASS == 32
-  typedef Elf32_Word d_tag_utype;
-#elif __ELF_NATIVE_CLASS == 64
-  typedef Elf64_Xword d_tag_utype;
-#endif
-
-#ifndef RTLD_BOOTSTRAP
-  if (dyn == NULL)
-    return;
-#endif
-
-  info = l->l_info;
-
-  while (dyn->d_tag != DT_NULL)
-    {
-      if ((d_tag_utype) dyn->d_tag < DT_NUM)
-	info[dyn->d_tag] = dyn;
-      else if (dyn->d_tag >= DT_LOPROC &&
-	       dyn->d_tag < DT_LOPROC + DT_THISPROCNUM)
-	info[dyn->d_tag - DT_LOPROC + DT_NUM] = dyn;
-      else if ((d_tag_utype) DT_VERSIONTAGIDX (dyn->d_tag) < DT_VERSIONTAGNUM)
-	info[VERSYMIDX (dyn->d_tag)] = dyn;
-      else if ((d_tag_utype) DT_EXTRATAGIDX (dyn->d_tag) < DT_EXTRANUM)
-	info[DT_EXTRATAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
-	     + DT_VERSIONTAGNUM] = dyn;
-      else if ((d_tag_utype) DT_VALTAGIDX (dyn->d_tag) < DT_VALNUM)
-	info[DT_VALTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
-	     + DT_VERSIONTAGNUM + DT_EXTRANUM] = dyn;
-      else if ((d_tag_utype) DT_ADDRTAGIDX (dyn->d_tag) < DT_ADDRNUM)
-	info[DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
-	     + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM] = dyn;
-      ++dyn;
-    }
-
-#define DL_RO_DYN_TEMP_CNT	8
-
-#ifndef DL_RO_DYN_SECTION
-  /* Don't adjust .dynamic unnecessarily.  */
-  if (l->l_addr != 0)
-    {
-      ElfW(Addr) l_addr = l->l_addr;
-      int cnt = 0;
-
-# define ADJUST_DYN_INFO(tag) \
-      do								      \
-	if (info[tag] != NULL)						      \
-	  {								      \
-	    if (temp)							      \
-	      {								      \
-		temp[cnt].d_tag = info[tag]->d_tag;			      \
-		temp[cnt].d_un.d_ptr = info[tag]->d_un.d_ptr + l_addr;	      \
-		info[tag] = temp + cnt++;				      \
-	      }								      \
-	    else							      \
-	      info[tag]->d_un.d_ptr += l_addr;				      \
-	  }								      \
-      while (0)
-
-      ADJUST_DYN_INFO (DT_HASH);
-      ADJUST_DYN_INFO (DT_PLTGOT);
-      ADJUST_DYN_INFO (DT_STRTAB);
-      ADJUST_DYN_INFO (DT_SYMTAB);
-# if ! ELF_MACHINE_NO_RELA
-      ADJUST_DYN_INFO (DT_RELA);
-# endif
-# if ! ELF_MACHINE_NO_REL
-      ADJUST_DYN_INFO (DT_REL);
-# endif
-      ADJUST_DYN_INFO (DT_JMPREL);
-      ADJUST_DYN_INFO (VERSYMIDX (DT_VERSYM));
-      ADJUST_DYN_INFO (DT_ADDRTAGIDX (DT_GNU_HASH) + DT_NUM + DT_THISPROCNUM
-		       + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM);
-# undef ADJUST_DYN_INFO
-      assert (cnt <= DL_RO_DYN_TEMP_CNT);
-    }
-#endif
-  if (info[DT_PLTREL] != NULL)
-    {
-#if ELF_MACHINE_NO_RELA
-      assert (info[DT_PLTREL]->d_un.d_val == DT_REL);
-#elif ELF_MACHINE_NO_REL
-      assert (info[DT_PLTREL]->d_un.d_val == DT_RELA);
-#else
-      assert (info[DT_PLTREL]->d_un.d_val == DT_REL
-	      || info[DT_PLTREL]->d_un.d_val == DT_RELA);
-#endif
-    }
-#if ! ELF_MACHINE_NO_RELA
-  if (info[DT_RELA] != NULL)
-    assert (info[DT_RELAENT]->d_un.d_val == sizeof (ElfW(Rela)));
-# endif
-# if ! ELF_MACHINE_NO_REL
-  if (info[DT_REL] != NULL)
-    assert (info[DT_RELENT]->d_un.d_val == sizeof (ElfW(Rel)));
-#endif
-#ifdef RTLD_BOOTSTRAP
-  /* Only the bind now flags are allowed.  */
-  assert (info[VERSYMIDX (DT_FLAGS_1)] == NULL
-	  || (info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val & ~DF_1_NOW) == 0);
-  assert (info[DT_FLAGS] == NULL
-	  || (info[DT_FLAGS]->d_un.d_val & ~DF_BIND_NOW) == 0);
-  /* Flags must not be set for ld.so.  */
-  assert (info[DT_RUNPATH] == NULL);
-  assert (info[DT_RPATH] == NULL);
-#else
-  if (info[DT_FLAGS] != NULL)
-    {
-      /* Flags are used.  Translate to the old form where available.
-	 Since these l_info entries are only tested for NULL pointers it
-	 is ok if they point to the DT_FLAGS entry.  */
-      l->l_flags = info[DT_FLAGS]->d_un.d_val;
-
-      if (l->l_flags & DF_SYMBOLIC)
-	info[DT_SYMBOLIC] = info[DT_FLAGS];
-      if (l->l_flags & DF_TEXTREL)
-	info[DT_TEXTREL] = info[DT_FLAGS];
-      if (l->l_flags & DF_BIND_NOW)
-	info[DT_BIND_NOW] = info[DT_FLAGS];
-    }
-  if (info[VERSYMIDX (DT_FLAGS_1)] != NULL)
-    {
-      l->l_flags_1 = info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val;
-
-      if (l->l_flags_1 & DF_1_NOW)
-	info[DT_BIND_NOW] = info[VERSYMIDX (DT_FLAGS_1)];
-    }
-  if (info[DT_RUNPATH] != NULL)
-    /* If both RUNPATH and RPATH are given, the latter is ignored.  */
-    info[DT_RPATH] = NULL;
-#endif
-}
+#include "get-dynamic-info.h"
 
 #ifdef RESOLVE_MAP
 
diff --git a/elf/get-dynamic-info.h b/elf/get-dynamic-info.h
new file mode 100644
index 0000000..ffac75f
--- /dev/null
+++ b/elf/get-dynamic-info.h
@@ -0,0 +1,161 @@
+/* Read the dynamic section at DYN and fill in INFO with indices DT_*.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <assert.h>
+
+#ifndef RESOLVE_MAP
+static
+#else
+auto
+#endif
+inline void __attribute__ ((unused, always_inline))
+elf_get_dynamic_info (struct link_map *l, ElfW(Dyn) *temp)
+{
+  ElfW(Dyn) *dyn = l->l_ld;
+  ElfW(Dyn) **info;
+#if __ELF_NATIVE_CLASS == 32
+  typedef Elf32_Word d_tag_utype;
+#elif __ELF_NATIVE_CLASS == 64
+  typedef Elf64_Xword d_tag_utype;
+#endif
+
+#ifndef RTLD_BOOTSTRAP
+  if (dyn == NULL)
+    return;
+#endif
+
+  info = l->l_info;
+
+  while (dyn->d_tag != DT_NULL)
+    {
+      if ((d_tag_utype) dyn->d_tag < DT_NUM)
+	info[dyn->d_tag] = dyn;
+      else if (dyn->d_tag >= DT_LOPROC &&
+	       dyn->d_tag < DT_LOPROC + DT_THISPROCNUM)
+	info[dyn->d_tag - DT_LOPROC + DT_NUM] = dyn;
+      else if ((d_tag_utype) DT_VERSIONTAGIDX (dyn->d_tag) < DT_VERSIONTAGNUM)
+	info[VERSYMIDX (dyn->d_tag)] = dyn;
+      else if ((d_tag_utype) DT_EXTRATAGIDX (dyn->d_tag) < DT_EXTRANUM)
+	info[DT_EXTRATAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
+	     + DT_VERSIONTAGNUM] = dyn;
+      else if ((d_tag_utype) DT_VALTAGIDX (dyn->d_tag) < DT_VALNUM)
+	info[DT_VALTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
+	     + DT_VERSIONTAGNUM + DT_EXTRANUM] = dyn;
+      else if ((d_tag_utype) DT_ADDRTAGIDX (dyn->d_tag) < DT_ADDRNUM)
+	info[DT_ADDRTAGIDX (dyn->d_tag) + DT_NUM + DT_THISPROCNUM
+	     + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM] = dyn;
+      ++dyn;
+    }
+
+#define DL_RO_DYN_TEMP_CNT	8
+
+#ifndef DL_RO_DYN_SECTION
+  /* Don't adjust .dynamic unnecessarily.  */
+  if (l->l_addr != 0)
+    {
+      ElfW(Addr) l_addr = l->l_addr;
+      int cnt = 0;
+
+# define ADJUST_DYN_INFO(tag) \
+      do								      \
+	if (info[tag] != NULL)						      \
+	  {								      \
+	    if (temp)							      \
+	      {								      \
+		temp[cnt].d_tag = info[tag]->d_tag;			      \
+		temp[cnt].d_un.d_ptr = info[tag]->d_un.d_ptr + l_addr;	      \
+		info[tag] = temp + cnt++;				      \
+	      }								      \
+	    else							      \
+	      info[tag]->d_un.d_ptr += l_addr;				      \
+	  }								      \
+      while (0)
+
+      ADJUST_DYN_INFO (DT_HASH);
+      ADJUST_DYN_INFO (DT_PLTGOT);
+      ADJUST_DYN_INFO (DT_STRTAB);
+      ADJUST_DYN_INFO (DT_SYMTAB);
+# if ! ELF_MACHINE_NO_RELA
+      ADJUST_DYN_INFO (DT_RELA);
+# endif
+# if ! ELF_MACHINE_NO_REL
+      ADJUST_DYN_INFO (DT_REL);
+# endif
+      ADJUST_DYN_INFO (DT_JMPREL);
+      ADJUST_DYN_INFO (VERSYMIDX (DT_VERSYM));
+      ADJUST_DYN_INFO (DT_ADDRTAGIDX (DT_GNU_HASH) + DT_NUM + DT_THISPROCNUM
+		       + DT_VERSIONTAGNUM + DT_EXTRANUM + DT_VALNUM);
+# undef ADJUST_DYN_INFO
+      assert (cnt <= DL_RO_DYN_TEMP_CNT);
+    }
+#endif
+  if (info[DT_PLTREL] != NULL)
+    {
+#if ELF_MACHINE_NO_RELA
+      assert (info[DT_PLTREL]->d_un.d_val == DT_REL);
+#elif ELF_MACHINE_NO_REL
+      assert (info[DT_PLTREL]->d_un.d_val == DT_RELA);
+#else
+      assert (info[DT_PLTREL]->d_un.d_val == DT_REL
+	      || info[DT_PLTREL]->d_un.d_val == DT_RELA);
+#endif
+    }
+#if ! ELF_MACHINE_NO_RELA
+  if (info[DT_RELA] != NULL)
+    assert (info[DT_RELAENT]->d_un.d_val == sizeof (ElfW(Rela)));
+# endif
+# if ! ELF_MACHINE_NO_REL
+  if (info[DT_REL] != NULL)
+    assert (info[DT_RELENT]->d_un.d_val == sizeof (ElfW(Rel)));
+#endif
+#ifdef RTLD_BOOTSTRAP
+  /* Only the bind now flags are allowed.  */
+  assert (info[VERSYMIDX (DT_FLAGS_1)] == NULL
+	  || (info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val & ~DF_1_NOW) == 0);
+  assert (info[DT_FLAGS] == NULL
+	  || (info[DT_FLAGS]->d_un.d_val & ~DF_BIND_NOW) == 0);
+  /* Flags must not be set for ld.so.  */
+  assert (info[DT_RUNPATH] == NULL);
+  assert (info[DT_RPATH] == NULL);
+#else
+  if (info[DT_FLAGS] != NULL)
+    {
+      /* Flags are used.  Translate to the old form where available.
+	 Since these l_info entries are only tested for NULL pointers it
+	 is ok if they point to the DT_FLAGS entry.  */
+      l->l_flags = info[DT_FLAGS]->d_un.d_val;
+
+      if (l->l_flags & DF_SYMBOLIC)
+	info[DT_SYMBOLIC] = info[DT_FLAGS];
+      if (l->l_flags & DF_TEXTREL)
+	info[DT_TEXTREL] = info[DT_FLAGS];
+      if (l->l_flags & DF_BIND_NOW)
+	info[DT_BIND_NOW] = info[DT_FLAGS];
+    }
+  if (info[VERSYMIDX (DT_FLAGS_1)] != NULL)
+    {
+      l->l_flags_1 = info[VERSYMIDX (DT_FLAGS_1)]->d_un.d_val;
+
+      if (l->l_flags_1 & DF_1_NOW)
+	info[DT_BIND_NOW] = info[VERSYMIDX (DT_FLAGS_1)];
+    }
+  if (info[DT_RUNPATH] != NULL)
+    /* If both RUNPATH and RPATH are given, the latter is ignored.  */
+    info[DT_RPATH] = NULL;
+#endif
+}
diff --git a/elf/rtld.c b/elf/rtld.c
index 8a02645..b0126e5 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -873,6 +873,7 @@ security_init (void)
   _dl_random = NULL;
 }
 
+#include "setup-vdso.h"
 
 /* The library search path.  */
 static const char *library_path attribute_relro;
@@ -1329,102 +1330,9 @@ of this helper program; chances are you did not intend to run this program.\n\
     }
 
   struct link_map **first_preload = &GL(dl_rtld_map).l_next;
-#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
   /* Set up the data structures for the system-supplied DSO early,
      so they can influence _dl_init_paths.  */
-  if (GLRO(dl_sysinfo_dso) != NULL)
-    {
-      /* Do an abridged version of the work _dl_map_object_from_fd would do
-	 to map in the object.  It's already mapped and prelinked (and
-	 better be, since it's read-only and so we couldn't relocate it).
-	 We just want our data structures to describe it as if we had just
-	 mapped and relocated it normally.  */
-      struct link_map *l = _dl_new_object ((char *) "", "", lt_library, NULL,
-					   0, LM_ID_BASE);
-      if (__builtin_expect (l != NULL, 1))
-	{
-	  static ElfW(Dyn) dyn_temp[DL_RO_DYN_TEMP_CNT] attribute_relro;
-
-	  l->l_phdr = ((const void *) GLRO(dl_sysinfo_dso)
-		       + GLRO(dl_sysinfo_dso)->e_phoff);
-	  l->l_phnum = GLRO(dl_sysinfo_dso)->e_phnum;
-	  for (uint_fast16_t i = 0; i < l->l_phnum; ++i)
-	    {
-	      const ElfW(Phdr) *const ph = &l->l_phdr[i];
-	      if (ph->p_type == PT_DYNAMIC)
-		{
-		  l->l_ld = (void *) ph->p_vaddr;
-		  l->l_ldnum = ph->p_memsz / sizeof (ElfW(Dyn));
-		}
-	      else if (ph->p_type == PT_LOAD)
-		{
-		  if (! l->l_addr)
-		    l->l_addr = ph->p_vaddr;
-		  if (ph->p_vaddr + ph->p_memsz >= l->l_map_end)
-		    l->l_map_end = ph->p_vaddr + ph->p_memsz;
-		  if ((ph->p_flags & PF_X)
-			   && ph->p_vaddr + ph->p_memsz >= l->l_text_end)
-		    l->l_text_end = ph->p_vaddr + ph->p_memsz;
-		}
-	      else
-		/* There must be no TLS segment.  */
-		assert (ph->p_type != PT_TLS);
-	    }
-	  l->l_map_start = (ElfW(Addr)) GLRO(dl_sysinfo_dso);
-	  l->l_addr = l->l_map_start - l->l_addr;
-	  l->l_map_end += l->l_addr;
-	  l->l_text_end += l->l_addr;
-	  l->l_ld = (void *) ((ElfW(Addr)) l->l_ld + l->l_addr);
-	  elf_get_dynamic_info (l, dyn_temp);
-	  _dl_setup_hash (l);
-	  l->l_relocated = 1;
-
-	  /* The vDSO is always used.  */
-	  l->l_used = 1;
-
-	  /* Initialize l_local_scope to contain just this map.  This allows
-	     the use of dl_lookup_symbol_x to resolve symbols within the vdso.
-	     So we create a single entry list pointing to l_real as its only
-	     element */
-	  l->l_local_scope[0]->r_nlist = 1;
-	  l->l_local_scope[0]->r_list = &l->l_real;
-
-	  /* Now that we have the info handy, use the DSO image's soname
-	     so this object can be looked up by name.  Note that we do not
-	     set l_name here.  That field gives the file name of the DSO,
-	     and this DSO is not associated with any file.  */
-	  if (l->l_info[DT_SONAME] != NULL)
-	    {
-	      /* Work around a kernel problem.  The kernel cannot handle
-		 addresses in the vsyscall DSO pages in writev() calls.  */
-	      const char *dsoname = ((char *) D_PTR (l, l_info[DT_STRTAB])
-				     + l->l_info[DT_SONAME]->d_un.d_val);
-	      size_t len = strlen (dsoname);
-	      char *copy = malloc (len);
-	      if (copy == NULL)
-		_dl_fatal_printf ("out of memory\n");
-	      l->l_libname->name = l->l_name = memcpy (copy, dsoname, len);
-	    }
-
-	  /* Add the vDSO to the object list.  */
-	  _dl_add_to_namespace_list (l, LM_ID_BASE);
-
-	  /* Rearrange the list so this DSO appears after rtld_map.  */
-	  assert (l->l_next == NULL);
-	  assert (l->l_prev == main_map);
-	  GL(dl_rtld_map).l_next = l;
-	  l->l_prev = &GL(dl_rtld_map);
-	  first_preload = &l->l_next;
-
-	  /* We have a prelinked DSO preloaded by the system.  */
-	  GLRO(dl_sysinfo_map) = l;
-# ifdef NEED_DL_SYSINFO
-	  if (GLRO(dl_sysinfo) == DL_SYSINFO_DEFAULT)
-	    GLRO(dl_sysinfo) = GLRO(dl_sysinfo_dso)->e_entry + l->l_addr;
-# endif
-	}
-    }
-#endif
+  setup_vdso (main_map, &first_preload);
 
 #ifdef DL_SYSDEP_OSCHECK
   DL_SYSDEP_OSCHECK (_dl_fatal_printf);
diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
new file mode 100644
index 0000000..1b969a0
--- /dev/null
+++ b/elf/setup-vdso.h
@@ -0,0 +1,119 @@
+/* Set up the data structures for the system-supplied DSO.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+static inline void __attribute__ ((always_inline))
+setup_vdso (struct link_map *main_map __attribute__ ((unused)),
+	    struct link_map ***first_preload __attribute__ ((unused)))
+{
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
+  if (GLRO(dl_sysinfo_dso) == NULL)
+    return;
+
+  /* Do an abridged version of the work _dl_map_object_from_fd would do
+     to map in the object.  It's already mapped and prelinked (and
+     better be, since it's read-only and so we couldn't relocate it).
+     We just want our data structures to describe it as if we had just
+     mapped and relocated it normally.  */
+  struct link_map *l = _dl_new_object ((char *) "", "", lt_library, NULL,
+				       0, LM_ID_BASE);
+  if (__builtin_expect (l != NULL, 1))
+    {
+      static ElfW(Dyn) dyn_temp[DL_RO_DYN_TEMP_CNT] attribute_relro;
+
+      l->l_phdr = ((const void *) GLRO(dl_sysinfo_dso)
+		   + GLRO(dl_sysinfo_dso)->e_phoff);
+      l->l_phnum = GLRO(dl_sysinfo_dso)->e_phnum;
+      for (uint_fast16_t i = 0; i < l->l_phnum; ++i)
+	{
+	  const ElfW(Phdr) *const ph = &l->l_phdr[i];
+	  if (ph->p_type == PT_DYNAMIC)
+	    {
+	      l->l_ld = (void *) ph->p_vaddr;
+	      l->l_ldnum = ph->p_memsz / sizeof (ElfW(Dyn));
+	    }
+	  else if (ph->p_type == PT_LOAD)
+	    {
+	      if (! l->l_addr)
+		l->l_addr = ph->p_vaddr;
+	      if (ph->p_vaddr + ph->p_memsz >= l->l_map_end)
+		l->l_map_end = ph->p_vaddr + ph->p_memsz;
+	      if ((ph->p_flags & PF_X)
+		  && ph->p_vaddr + ph->p_memsz >= l->l_text_end)
+		l->l_text_end = ph->p_vaddr + ph->p_memsz;
+	    }
+	  else
+	    /* There must be no TLS segment.  */
+	    assert (ph->p_type != PT_TLS);
+	}
+      l->l_map_start = (ElfW(Addr)) GLRO(dl_sysinfo_dso);
+      l->l_addr = l->l_map_start - l->l_addr;
+      l->l_map_end += l->l_addr;
+      l->l_text_end += l->l_addr;
+      l->l_ld = (void *) ((ElfW(Addr)) l->l_ld + l->l_addr);
+      elf_get_dynamic_info (l, dyn_temp);
+      _dl_setup_hash (l);
+      l->l_relocated = 1;
+
+      /* The vDSO is always used.  */
+      l->l_used = 1;
+
+      /* Initialize l_local_scope to contain just this map.  This allows
+	 the use of dl_lookup_symbol_x to resolve symbols within the vdso.
+	 So we create a single entry list pointing to l_real as its only
+	 element */
+      l->l_local_scope[0]->r_nlist = 1;
+      l->l_local_scope[0]->r_list = &l->l_real;
+
+      /* Now that we have the info handy, use the DSO image's soname
+	 so this object can be looked up by name.  Note that we do not
+	 set l_name here.  That field gives the file name of the DSO,
+	 and this DSO is not associated with any file.  */
+      if (l->l_info[DT_SONAME] != NULL)
+	{
+	  /* Work around a kernel problem.  The kernel cannot handle
+	     addresses in the vsyscall DSO pages in writev() calls.  */
+	  const char *dsoname = ((char *) D_PTR (l, l_info[DT_STRTAB])
+				 + l->l_info[DT_SONAME]->d_un.d_val);
+	  size_t len = strlen (dsoname);
+	  char *copy = malloc (len);
+	  if (copy == NULL)
+	    _dl_fatal_printf ("out of memory\n");
+	  l->l_libname->name = l->l_name = memcpy (copy, dsoname, len);
+	}
+
+      /* Add the vDSO to the object list.  */
+      _dl_add_to_namespace_list (l, LM_ID_BASE);
+
+# ifdef IS_IN_rtld
+      /* Rearrange the list so this DSO appears after rtld_map.  */
+      assert (l->l_next == NULL);
+      assert (l->l_prev == main_map);
+      GL(dl_rtld_map).l_next = l;
+      l->l_prev = &GL(dl_rtld_map);
+      *first_preload = &l->l_next;
+# endif
+
+      /* We have a prelinked DSO preloaded by the system.  */
+      GLRO(dl_sysinfo_map) = l;
+# ifdef NEED_DL_SYSINFO
+      if (GLRO(dl_sysinfo) == DL_SYSINFO_DEFAULT)
+	GLRO(dl_sysinfo) = GLRO(dl_sysinfo_dso)->e_entry + l->l_addr;
+# endif
+    }
+#endif
+}

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

Summary of changes:
 ChangeLog                     |   25 ++++
 NEWS                          |    3 +-
 elf/Makefile                  |    2 +-
 elf/dl-hwcaps.c               |  279 +++++++++++++++++++++++++++++++++++++++++
 elf/dl-support.c              |   26 ++---
 elf/dl-sysdep.c               |  254 -------------------------------------
 elf/dynamic-link.h            |  145 +---------------------
 elf/get-dynamic-info.h        |  161 ++++++++++++++++++++++++
 elf/rtld.c                    |   96 +--------------
 elf/setup-vdso.h              |  121 ++++++++++++++++++
 nptl/ChangeLog                |   15 +++
 nptl/Makefile                 |    9 +-
 nptl/tst-cancel24-static.cc   |    1 +
 nptl/tst-cond8-static.c       |    1 +
 nptl/tst-mutex8-static.c      |    1 +
 nptl/tst-mutexpi8-static.c    |    1 +
 nptl/tst-sem11-static.c       |    1 +
 nptl/tst-sem12-static.c       |    1 +
 sysdeps/mach/hurd/dl-sysdep.c |   20 ---
 19 files changed, 629 insertions(+), 533 deletions(-)
 create mode 100644 elf/dl-hwcaps.c
 create mode 100644 elf/get-dynamic-info.h
 create mode 100644 elf/setup-vdso.h
 create mode 100644 nptl/tst-cancel24-static.cc
 create mode 100644 nptl/tst-cond8-static.c
 create mode 100644 nptl/tst-mutex8-static.c
 create mode 100644 nptl/tst-mutexpi8-static.c
 create mode 100644 nptl/tst-sem11-static.c
 create mode 100644 nptl/tst-sem12-static.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]