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