From patchwork Tue May 13 16:13:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 348447 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 11083140080 for ; Wed, 14 May 2014 02:13:41 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=eThvoX7SscEo7lLfyxxbV5qKsENLg /Ah+JrKtvADqQ6IZaVbDaJPVXPgxuMZ8wKzffR49/U0+bsu368k6PLG2YRXwGWW0 jxsUO9MNKJ6FK/zDEcp87PeVXyMZQn26o4t5oNYDqzx8XGAmhQcKN+xv+4uuPDgR vyNk99Xg4lWrUA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=ykPxOOGxbvv9emlAVTJ4oDDFjlo=; b=HfX Y9xMNlxE4CS9vFiGxZjH4BLdqiFqy1mTdtCdXp8ghcsT0F4EzqyY1uemPPTvV2ST Ya42zYvVEc1uUW/8zSGwug62F2MwZoQiN2kaL1GuJDeANrwy4c8SEqoxIXwL8QIM rvXcRv01GbwnqX7rhKNct3SbT6zzFv9tCt7le4OU= Received: (qmail 7510 invoked by alias); 13 May 2014 16:13:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 7494 invoked by uid 89); 13 May 2014 16:13:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx2.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Remove last use of USE___THREAD X-Yow: Will it improve my CASH FLOW? Date: Tue, 13 May 2014 18:13:30 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Tested on x86_64-suse-linux, no code change on ld.so. Andreas. * elf/rtld.c (_dl_start_final, _dl_start, init_tls, dl_main): Remove code conditionalized on USE___THREAD. diff --git a/elf/rtld.c b/elf/rtld.c index 9d121dc..87c5ffa 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -300,21 +300,9 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) GL(dl_rtld_map).l_text_end = (ElfW(Addr)) _etext; /* Copy the TLS related data if necessary. */ #ifndef DONT_USE_BOOTSTRAP_MAP -# if USE___THREAD - assert (info->l.l_tls_modid != 0); - GL(dl_rtld_map).l_tls_blocksize = info->l.l_tls_blocksize; - GL(dl_rtld_map).l_tls_align = info->l.l_tls_align; - GL(dl_rtld_map).l_tls_firstbyte_offset = info->l.l_tls_firstbyte_offset; - GL(dl_rtld_map).l_tls_initimage_size = info->l.l_tls_initimage_size; - GL(dl_rtld_map).l_tls_initimage = info->l.l_tls_initimage; - GL(dl_rtld_map).l_tls_offset = info->l.l_tls_offset; - GL(dl_rtld_map).l_tls_modid = 1; -# else -# if NO_TLS_OFFSET != 0 +# if NO_TLS_OFFSET != 0 GL(dl_rtld_map).l_tls_offset = NO_TLS_OFFSET; -# endif # endif - #endif #if HP_TIMING_AVAIL @@ -396,9 +384,6 @@ _dl_start (void *arg) ++cnt) bootstrap_map.l_info[cnt] = 0; # endif -# if USE___THREAD - bootstrap_map.l_tls_modid = 0; -# endif #endif /* Figure out the run-time load address of the dynamic linker itself. */ @@ -412,123 +397,6 @@ _dl_start (void *arg) bootstrap_map.l_tls_offset = NO_TLS_OFFSET; #endif - /* Get the dynamic linker's own program header. First we need the ELF - file header. The `_begin' symbol created by the linker script points - to it. When we have something like GOTOFF relocs, we can use a plain - reference to find the runtime address. Without that, we have to rely - on the `l_addr' value, which is not the value we want when prelinked. */ -#if USE___THREAD - dtv_t initdtv[3]; - ElfW(Ehdr) *ehdr -# ifdef DONT_USE_BOOTSTRAP_MAP - = (ElfW(Ehdr) *) &_begin; -# else -# error This will not work with prelink. - = (ElfW(Ehdr) *) bootstrap_map.l_addr; -# endif - ElfW(Phdr) *phdr = (ElfW(Phdr) *) ((void *) ehdr + ehdr->e_phoff); - size_t cnt = ehdr->e_phnum; /* PT_TLS is usually the last phdr. */ - while (cnt-- > 0) - if (phdr[cnt].p_type == PT_TLS) - { - void *tlsblock; - size_t max_align = MAX (TLS_INIT_TCB_ALIGN, phdr[cnt].p_align); - char *p; - - bootstrap_map.l_tls_blocksize = phdr[cnt].p_memsz; - bootstrap_map.l_tls_align = phdr[cnt].p_align; - if (phdr[cnt].p_align == 0) - bootstrap_map.l_tls_firstbyte_offset = 0; - else - bootstrap_map.l_tls_firstbyte_offset = (phdr[cnt].p_vaddr - & (phdr[cnt].p_align - 1)); - assert (bootstrap_map.l_tls_blocksize != 0); - bootstrap_map.l_tls_initimage_size = phdr[cnt].p_filesz; - bootstrap_map.l_tls_initimage = (void *) (bootstrap_map.l_addr - + phdr[cnt].p_vaddr); - - /* We can now allocate the initial TLS block. This can happen - on the stack. We'll get the final memory later when we - know all about the various objects loaded at startup - time. */ -# if TLS_TCB_AT_TP - tlsblock = alloca (roundup (bootstrap_map.l_tls_blocksize, - TLS_INIT_TCB_ALIGN) - + TLS_INIT_TCB_SIZE - + max_align); -# elif TLS_DTV_AT_TP - tlsblock = alloca (roundup (TLS_INIT_TCB_SIZE, - bootstrap_map.l_tls_align) - + bootstrap_map.l_tls_blocksize - + max_align); -# else - /* In case a model with a different layout for the TCB and DTV - is defined add another #elif here and in the following #ifs. */ -# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" -# endif - /* Align the TLS block. */ - tlsblock = (void *) (((uintptr_t) tlsblock + max_align - 1) - & ~(max_align - 1)); - - /* Initialize the dtv. [0] is the length, [1] the generation - counter. */ - initdtv[0].counter = 1; - initdtv[1].counter = 0; - - /* Initialize the TLS block. */ -# if TLS_TCB_AT_TP - initdtv[2].pointer = tlsblock; -# elif TLS_DTV_AT_TP - bootstrap_map.l_tls_offset = roundup (TLS_INIT_TCB_SIZE, - bootstrap_map.l_tls_align); - initdtv[2].pointer = (char *) tlsblock + bootstrap_map.l_tls_offset; -# else -# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" -# endif - p = __mempcpy (initdtv[2].pointer, bootstrap_map.l_tls_initimage, - bootstrap_map.l_tls_initimage_size); -# ifdef HAVE_BUILTIN_MEMSET - __builtin_memset (p, '\0', (bootstrap_map.l_tls_blocksize - - bootstrap_map.l_tls_initimage_size)); -# else - { - size_t remaining = (bootstrap_map.l_tls_blocksize - - bootstrap_map.l_tls_initimage_size); - while (remaining-- > 0) - *p++ = '\0'; - } -# endif - - /* Install the pointer to the dtv. */ - - /* Initialize the thread pointer. */ -# if TLS_TCB_AT_TP - bootstrap_map.l_tls_offset - = roundup (bootstrap_map.l_tls_blocksize, TLS_INIT_TCB_ALIGN); - - INSTALL_DTV ((char *) tlsblock + bootstrap_map.l_tls_offset, - initdtv); - - const char *lossage = TLS_INIT_TP ((char *) tlsblock - + bootstrap_map.l_tls_offset, 0); -# elif TLS_DTV_AT_TP - INSTALL_DTV (tlsblock, initdtv); - const char *lossage = TLS_INIT_TP (tlsblock, 0); -# else -# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" -# endif - if (__glibc_unlikely (lossage != NULL)) - _dl_fatal_printf ("cannot set up thread-local storage: %s\n", - lossage); - - /* So far this is module number one. */ - bootstrap_map.l_tls_modid = 1; - - /* There can only be one PT_TLS entry. */ - break; - } -#endif /* USE___THREAD */ - #ifdef ELF_MACHINE_BEFORE_RTLD_RELOC ELF_MACHINE_BEFORE_RTLD_RELOC (bootstrap_map.l_info); #endif @@ -772,14 +640,8 @@ cannot allocate TLS data structures for initial thread"); so it knows not to pass this dtv to the normal realloc. */ GL(dl_initial_dtv) = GET_DTV (tcbp); - /* And finally install it for the main thread. If ld.so itself uses - TLS we know the thread pointer was initialized earlier. */ - const char *lossage -#ifdef USE___THREAD - = TLS_INIT_TP (tcbp, USE___THREAD); -#else - = TLS_INIT_TP (tcbp, 0); -#endif + /* And finally install it for the main thread. */ + const char *lossage = TLS_INIT_TP (tcbp, 0); if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); tls_init_tp_called = true; @@ -2249,16 +2111,10 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", into the main thread's TLS area, which we allocated above. */ _dl_allocate_tls_init (tcbp); - /* And finally install it for the main thread. If ld.so itself uses - TLS we know the thread pointer was initialized earlier. */ + /* And finally install it for the main thread. */ if (! tls_init_tp_called) { - const char *lossage -#ifdef USE___THREAD - = TLS_INIT_TP (tcbp, USE___THREAD); -#else - = TLS_INIT_TP (tcbp, 0); -#endif + const char *lossage = TLS_INIT_TP (tcbp, 0); if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);