00db10
Recreation of this upstream commit:
00db10
00db10
commit 3d8c8bff798a15b6dc0ee94d24fc877db9706589
00db10
Author: Andreas Schwab <schwab@suse.de>
00db10
Date:   Tue Mar 25 11:55:52 2014 +0100
00db10
00db10
    Remove last use of USE___THREAD
00db10
00db10
This was done using unifdef -m -UUSE___THREAD elf/rtld.c, followed by a
00db10
manual reindent.
00db10
00db10
diff --git a/elf/rtld.c b/elf/rtld.c
00db10
index b5a859ecff740705..e934ad38db39d343 100644
00db10
--- a/elf/rtld.c
00db10
+++ b/elf/rtld.c
00db10
@@ -382,19 +382,8 @@ _dl_start_final (void *arg, struct dl_start_final_info *info)
00db10
   GL(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext;
00db10
   /* Copy the TLS related data if necessary.  */
00db10
 #ifndef DONT_USE_BOOTSTRAP_MAP
00db10
-# if USE___THREAD
00db10
-  assert (info->l.l_tls_modid != 0);
00db10
-  GL(dl_rtld_map).l_tls_blocksize = info->l.l_tls_blocksize;
00db10
-  GL(dl_rtld_map).l_tls_align = info->l.l_tls_align;
00db10
-  GL(dl_rtld_map).l_tls_firstbyte_offset = info->l.l_tls_firstbyte_offset;
00db10
-  GL(dl_rtld_map).l_tls_initimage_size = info->l.l_tls_initimage_size;
00db10
-  GL(dl_rtld_map).l_tls_initimage = info->l.l_tls_initimage;
00db10
-  GL(dl_rtld_map).l_tls_offset = info->l.l_tls_offset;
00db10
-  GL(dl_rtld_map).l_tls_modid = 1;
00db10
-# else
00db10
-#  if NO_TLS_OFFSET != 0
00db10
+# if NO_TLS_OFFSET != 0
00db10
   GL(dl_rtld_map).l_tls_offset = NO_TLS_OFFSET;
00db10
-#  endif
00db10
 # endif
00db10
 
00db10
 #endif
00db10
@@ -476,9 +465,6 @@ _dl_start (void *arg)
00db10
        ++cnt)
00db10
     bootstrap_map.l_info[cnt] = 0;
00db10
 # endif
00db10
-# if USE___THREAD
00db10
-  bootstrap_map.l_tls_modid = 0;
00db10
-# endif
00db10
 #endif
00db10
 
00db10
   /* Figure out the run-time load address of the dynamic linker itself.  */
00db10
@@ -497,117 +483,6 @@ _dl_start (void *arg)
00db10
      to it.  When we have something like GOTOFF relocs, we can use a plain
00db10
      reference to find the runtime address.  Without that, we have to rely
00db10
      on the `l_addr' value, which is not the value we want when prelinked.  */
00db10
-#if USE___THREAD
00db10
-  dtv_t initdtv[3];
00db10
-  ElfW(Ehdr) *ehdr
00db10
-# ifdef DONT_USE_BOOTSTRAP_MAP
00db10
-    = (ElfW(Ehdr) *) &_begin;
00db10
-# else
00db10
-#  error This will not work with prelink.
00db10
-    = (ElfW(Ehdr) *) bootstrap_map.l_addr;
00db10
-# endif
00db10
-  ElfW(Phdr) *phdr = (ElfW(Phdr) *) ((void *) ehdr + ehdr->e_phoff);
00db10
-  size_t cnt = ehdr->e_phnum;	/* PT_TLS is usually the last phdr.  */
00db10
-  while (cnt-- > 0)
00db10
-    if (phdr[cnt].p_type == PT_TLS)
00db10
-      {
00db10
-	void *tlsblock;
00db10
-	size_t max_align = MAX (TLS_INIT_TCB_ALIGN, phdr[cnt].p_align);
00db10
-	char *p;
00db10
-
00db10
-	bootstrap_map.l_tls_blocksize = phdr[cnt].p_memsz;
00db10
-	bootstrap_map.l_tls_align = phdr[cnt].p_align;
00db10
-	if (phdr[cnt].p_align == 0)
00db10
-	  bootstrap_map.l_tls_firstbyte_offset = 0;
00db10
-	else
00db10
-	  bootstrap_map.l_tls_firstbyte_offset = (phdr[cnt].p_vaddr
00db10
-						  & (phdr[cnt].p_align - 1));
00db10
-	assert (bootstrap_map.l_tls_blocksize != 0);
00db10
-	bootstrap_map.l_tls_initimage_size = phdr[cnt].p_filesz;
00db10
-	bootstrap_map.l_tls_initimage = (void *) (bootstrap_map.l_addr
00db10
-						  + phdr[cnt].p_vaddr);
00db10
-
00db10
-	/* We can now allocate the initial TLS block.  This can happen
00db10
-	   on the stack.  We'll get the final memory later when we
00db10
-	   know all about the various objects loaded at startup
00db10
-	   time.  */
00db10
-# if TLS_TCB_AT_TP
00db10
-	tlsblock = alloca (roundup (bootstrap_map.l_tls_blocksize,
00db10
-				    TLS_INIT_TCB_ALIGN)
00db10
-			   + TLS_INIT_TCB_SIZE
00db10
-			   + max_align);
00db10
-# elif TLS_DTV_AT_TP
00db10
-	tlsblock = alloca (roundup (TLS_INIT_TCB_SIZE,
00db10
-				    bootstrap_map.l_tls_align)
00db10
-			   + bootstrap_map.l_tls_blocksize
00db10
-			   + max_align);
00db10
-# else
00db10
-	/* In case a model with a different layout for the TCB and DTV
00db10
-	   is defined add another #elif here and in the following #ifs.  */
00db10
-#  error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
00db10
-# endif
00db10
-	/* Align the TLS block.  */
00db10
-	tlsblock = (void *) (((uintptr_t) tlsblock + max_align - 1)
00db10
-			     & ~(max_align - 1));
00db10
-
00db10
-	/* Initialize the dtv.  [0] is the length, [1] the generation
00db10
-	   counter.  */
00db10
-	initdtv[0].counter = 1;
00db10
-	initdtv[1].counter = 0;
00db10
-
00db10
-	/* Initialize the TLS block.  */
00db10
-# if TLS_TCB_AT_TP
00db10
-	initdtv[2].pointer = tlsblock;
00db10
-# elif TLS_DTV_AT_TP
00db10
-	bootstrap_map.l_tls_offset = roundup (TLS_INIT_TCB_SIZE,
00db10
-					      bootstrap_map.l_tls_align);
00db10
-	initdtv[2].pointer = (char *) tlsblock + bootstrap_map.l_tls_offset;
00db10
-# else
00db10
-#  error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
00db10
-# endif
00db10
-	p = __mempcpy (initdtv[2].pointer, bootstrap_map.l_tls_initimage,
00db10
-		       bootstrap_map.l_tls_initimage_size);
00db10
-# ifdef HAVE_BUILTIN_MEMSET
00db10
-	__builtin_memset (p, '\0', (bootstrap_map.l_tls_blocksize
00db10
-				    - bootstrap_map.l_tls_initimage_size));
00db10
-# else
00db10
-	{
00db10
-	  size_t remaining = (bootstrap_map.l_tls_blocksize
00db10
-			      - bootstrap_map.l_tls_initimage_size);
00db10
-	  while (remaining-- > 0)
00db10
-	    *p++ = '\0';
00db10
-	}
00db10
-# endif
00db10
-
00db10
-	/* Install the pointer to the dtv.  */
00db10
-
00db10
-	/* Initialize the thread pointer.  */
00db10
-# if TLS_TCB_AT_TP
00db10
-	bootstrap_map.l_tls_offset
00db10
-	  = roundup (bootstrap_map.l_tls_blocksize, TLS_INIT_TCB_ALIGN);
00db10
-
00db10
-	INSTALL_DTV ((char *) tlsblock + bootstrap_map.l_tls_offset,
00db10
-		     initdtv);
00db10
-
00db10
-	const char *lossage = TLS_INIT_TP ((char *) tlsblock
00db10
-					   + bootstrap_map.l_tls_offset, 0);
00db10
-# elif TLS_DTV_AT_TP
00db10
-	INSTALL_DTV (tlsblock, initdtv);
00db10
-	const char *lossage = TLS_INIT_TP (tlsblock, 0);
00db10
-# else
00db10
-#  error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"
00db10
-# endif
00db10
-	if (__builtin_expect (lossage != NULL, 0))
00db10
-	  _dl_fatal_printf ("cannot set up thread-local storage: %s\n",
00db10
-			    lossage);
00db10
-
00db10
-	/* So far this is module number one.  */
00db10
-	bootstrap_map.l_tls_modid = 1;
00db10
-
00db10
-	/* There can only be one PT_TLS entry.  */
00db10
-	break;
00db10
-      }
00db10
-#endif	/* USE___THREAD */
00db10
 
00db10
 #ifdef ELF_MACHINE_BEFORE_RTLD_RELOC
00db10
   ELF_MACHINE_BEFORE_RTLD_RELOC (bootstrap_map.l_info);
00db10
@@ -853,12 +728,7 @@ cannot allocate TLS data structures for initial thread");
00db10
 
00db10
   /* And finally install it for the main thread.  If ld.so itself uses
00db10
      TLS we know the thread pointer was initialized earlier.  */
00db10
-  const char *lossage
00db10
-#ifdef USE___THREAD
00db10
-    = TLS_INIT_TP (tcbp, USE___THREAD);
00db10
-#else
00db10
-    = TLS_INIT_TP (tcbp, 0);
00db10
-#endif
00db10
+  const char *lossage = TLS_INIT_TP (tcbp, 0);
00db10
   if (__builtin_expect (lossage != NULL, 0))
00db10
     _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);
00db10
   tls_init_tp_called = true;
00db10
@@ -2344,11 +2214,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n",
00db10
   if (! tls_init_tp_called)
00db10
     {
00db10
       const char *lossage
00db10
-#ifdef USE___THREAD
00db10
-	= TLS_INIT_TP (tcbp, USE___THREAD);
00db10
-#else
00db10
 	= TLS_INIT_TP (tcbp, 0);
00db10
-#endif
00db10
       if (__builtin_expect (lossage != NULL, 0))
00db10
 	_dl_fatal_printf ("cannot set up thread-local storage: %s\n",
00db10
 			  lossage);