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 hjl/pr14557/map created. glibc-2.16-ports-merge-412-gc02a31d


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, hjl/pr14557/map has been created
        at  c02a31ddd505971ac1fc5c636e6503f629aede19 (commit)

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

commit c02a31ddd505971ac1fc5c636e6503f629aede19
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Sep 28 16:48:50 2012 -0700

    Move _dl_important_hwcaps to dl-hwcaps.c

diff --git a/ChangeLog.pr14557 b/ChangeLog.pr14557
index c67bfdc..655e4de 100644
--- a/ChangeLog.pr14557
+++ b/ChangeLog.pr14557
@@ -1,5 +1,13 @@
 2012-09-28  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* elf/Makefile (routines): Add dl-hwcaps.
+	(elide-routines.os): Likewise.
+	(rtld-routines): Likewise.
+	* 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.
+
 	* elf/dl-open.c (_dl_open): Also allow _ns_loaded == dl_sysinfo_map
 	if SHARED isn't defined.
 
diff --git a/elf/Makefile b/elf/Makefile
index 2eb12d3..c0304d4 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -21,7 +21,7 @@ subdir		:= elf
 
 headers		= elf.h bits/elfclass.h link.h bits/link.h
 routines	= $(dl-routines) dl-support dl-iteratephdr \
-		  dl-addr enbl-secure dl-profstub \
+		  dl-addr enbl-secure dl-profstub dl-hwcaps \
 		  dl-origin dl-libc dl-sym dl-tsd dl-sysdep
 
 # The core dynamic linking functions are in libc for the static and
@@ -33,12 +33,13 @@ dl-routines	= $(addprefix dl-,load cache lookup object reloc deps \
 all-dl-routines = $(dl-routines) $(sysdep-dl-routines)
 # But they are absent from the shared libc, because that code is in ld.so.
 elide-routines.os = $(all-dl-routines) dl-support enbl-secure dl-origin \
-		    dl-sysdep
+		    dl-sysdep dl-hwcaps
 shared-only-routines += dl-caller
 
 # ld.so uses those routines, plus some special stuff for being the program
 # interpreter and operating independent of libc.
-rtld-routines	:= rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
+rtld-routines	:= rtld $(dl-routines) dl-sysdep dl-environ dl-minimal \
+		   dl-hwcaps
 all-rtld-routines = $(rtld-routines) $(sysdep-rtld-routines)
 
 CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables
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 23c4e53..fe967b3 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -340,23 +340,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

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

commit 4f5a0095497f4674e6b900cbfec1a99c7ffc7f03
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Sep 28 16:47:50 2012 -0700

    Add test cases for BZ #14557

diff --git a/nptl/ChangeLog.pr14557 b/nptl/ChangeLog.pr14557
new file mode 100644
index 0000000..367941a
--- /dev/null
+++ b/nptl/ChangeLog.pr14557
@@ -0,0 +1,14 @@
+2012-09-28  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 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.
diff --git a/nptl/Makefile b/nptl/Makefile
index b081b07..c483ffc 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -349,8 +349,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
@@ -508,6 +512,7 @@ $(objpfx)tst-rwlock14: $(common-objpfx)rt/librt.a
 endif
 
 LDLIBS-tst-cancel24 = $(no-as-needed) -lstdc++
+LDLIBS-tst-cancel24-static = $(no-as-needed) -lstdc++
 
 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=b149ad2f05f7de0613b64ac3a7e095b88fd9a752

commit b149ad2f05f7de0613b64ac3a7e095b88fd9a752
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Fri Sep 28 16:44:02 2012 -0700

    Allow _ns_loaded == dl_sysinfo_map in libc.a

diff --git a/ChangeLog.pr14557 b/ChangeLog.pr14557
index b98665c..c67bfdc 100644
--- a/ChangeLog.pr14557
+++ b/ChangeLog.pr14557
@@ -1,5 +1,8 @@
 2012-09-28  H.J. Lu  <hongjiu.lu@intel.com>
 
+	* elf/dl-open.c (_dl_open): Also allow _ns_loaded == dl_sysinfo_map
+	if SHARED isn't defined.
+
 	[BZ #14557]
 	* elf/dl-support.c: Include <assert.h>.
 	(_dl_sysinfo_map): New.
diff --git a/elf/dl-open.c b/elf/dl-open.c
index 0bc447a..e3909cd 100644
--- a/elf/dl-open.c
+++ b/elf/dl-open.c
@@ -632,7 +632,8 @@ no more namespaces available for dlmopen()"));
 		      N_("invalid target namespace in dlmopen()"));
 #ifndef SHARED
   else if ((nsid == LM_ID_BASE || nsid == __LM_ID_CALLER)
-	   && GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL
+	   && (GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL
+	       || GL(dl_ns)[LM_ID_BASE]._ns_loaded == GLRO(dl_sysinfo_map))
 	   && GL(dl_nns) == 0)
     GL(dl_nns) = 1;
 #endif

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

commit 4d5de966ddc29b078982e3122d21bc961f91a1e3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sat Sep 29 07:30:34 2012 -0700

    Set up the data structures for vDSO in libc.a

diff --git a/ChangeLog.pr14557 b/ChangeLog.pr14557
new file mode 100644
index 0000000..b98665c
--- /dev/null
+++ b/ChangeLog.pr14557
@@ -0,0 +1,13 @@
+2012-09-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #14557]
+	* elf/dl-support.c: Include <assert.h>.
+	(_dl_sysinfo_map): New.
+	Incldue "get-dynamic-info.h" and "setup-vdso.h".
+	(_dl_non_dynamic_init): Call setup_vdso.
+	* elf/dynamic-link.h: Remove elf_get_dynamic_info.
+	Include "get-dynamic-info.h".
+	* elf/get-dynamic-info.h: New file.
+	* elf/setup-vdso.h: Likewise.
+	* elf/rtld.c:  Include "setup-vdso.h".
+	(dl_main): Call setup_vdso.
diff --git a/elf/dl-support.c b/elf/dl-support.c
index 2bb468a..23c4e53 100644
--- a/elf/dl-support.c
+++ b/elf/dl-support.c
@@ -33,6 +33,7 @@
 #include <unsecvars.h>
 #include <hp-timing.h>
 #include <stackinfo.h>
+#include <assert.h>
 
 extern char *__progname;
 char **_dl_argv = &__progname;	/* This is checked for some error messages.  */
@@ -161,6 +162,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 +272,14 @@ _dl_non_dynamic_init (void)
 
   _dl_verbose = *(getenv ("LD_WARN") ?: "") == '\0' ? 0 : 1;
 
+#if defined HAVE_AUX_VECTOR \
+    && (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)
+    setup_vdso ();
+#endif
+
   /* 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..bdf7497 100644
--- a/elf/dynamic-link.h
+++ b/elf/dynamic-link.h
@@ -88,149 +88,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..4c928e5
--- /dev/null
+++ b/elf/get-dynamic-info.h
@@ -0,0 +1,142 @@
+/* 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
+}
diff --git a/elf/rtld.c b/elf/rtld.c
index ed5d062..6fbc890 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -873,6 +873,9 @@ security_init (void)
   _dl_random = NULL;
 }
 
+#if defined NEED_DL_SYSINFO || defined NEED_DL_SYSINFO_DSO
+# include "setup-vdso.h"
+#endif
 
 /* The library search path.  */
 static const char *library_path attribute_relro;
@@ -1333,97 +1336,7 @@ of this helper program; chances are you did not intend to run this program.\n\
   /* 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
-	}
-    }
+    setup_vdso (main_map, &first_preload);
 #endif
 
 #ifdef DL_SYSDEP_OSCHECK
diff --git a/elf/setup-vdso.h b/elf/setup-vdso.h
new file mode 100644
index 0000000..5eb070b
--- /dev/null
+++ b/elf/setup-vdso.h
@@ -0,0 +1,117 @@
+/* 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))
+# ifdef IS_IN_rtld
+setup_vdso (struct link_map *main_map, struct link_map ***first_preload)
+# else
+setup_vdso (void)
+# endif
+{
+  /* 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
+    }
+}

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


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]