From patchwork Tue May 6 08:35:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 346079 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 2EBD7141307 for ; Tue, 6 May 2014 18:35:14 +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:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type:content-transfer-encoding; q=dns; s=default; b=Eon0+KqMhIV2g5CPkJiLO+DZ8JFsHhWANYG53faVdTQ a4W3MKsQYnOf6c+S5Vlua7sdUrAAgrezdwWpmOst3jBGJ8tQcyn308oAEpkWsHOY 5VFRTT9Qwvs1gN+pdjEREtFOnkKvvib0ON7Nq0yjgjuVnx0aafJEOHgrJb+MWhGg = 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:cc:subject:references:date:in-reply-to :message-id:mime-version:content-type:content-transfer-encoding; s=default; bh=vQ1nV66cDbd0L0l0B9DF6wcKpC8=; b=eAu+SFyc5YrKXO01L +eJyFuzfU2mpF/IlNeLAQWoa3k7R14kRqQrj7KnU8AKIW/De4I+ghOkgzuZsM4no l6NVieZ5t0PMN5PMi9hIMeeJoN3MydUknhJ04lfEWDjDM/ncBrnA1c3HvT1N3eoJ 8tT+h3OwtnCpFyk1TCBcm/SpvA= Received: (qmail 1825 invoked by alias); 6 May 2014 08:35:09 -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 1813 invoked by uid 89); 6 May 2014 08:35:08 -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: =?utf-8?B?T25kxZllaiBCw61sa2E=?= Cc: Roland McGrath , Mike Frysinger , libc-alpha@sourceware.org Subject: Re: [RFC] killing remaining USE___THREAD use References: <4096104.BXBWkszvSk@vapier> <20140324224059.737BC74484@topped-with-meat.com> <20140325165620.8A54374479@topped-with-meat.com> <87k3bii2df.fsf@igel.home> <20140325180311.C17357449A@topped-with-meat.com> <87bnwuhzr7.fsf@igel.home> <20140329113140.GA14128@domone.podge> <20140424134018.GA15060@domone.podge> X-Yow: Are you still SEXUALLY ACTIVE? Did you BRING th' REINFORCEMENTS? Date: Tue, 06 May 2014 10:35:02 +0200 In-Reply-To: <20140424134018.GA15060@domone.podge> (=?utf-8?Q?=22Ond=C5=99?= =?utf-8?Q?ej_B=C3=ADlka=22's?= message of "Thu, 24 Apr 2014 15:40:18 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Ondřej Bílka writes: > I checked how its bitrotten, it gives following error: > > In file included from rtld.c:376:0: > dynamic-link.h: In function ‘_dl_start’: > dynamic-link.h:179:8: warning: "ELF_MACHINE_NO_RELA" is not defined > [-Wundef] > rtld.c:481:21: error: incompatible types when assigning to type ‘struct > ’ from type ‘void *’ > rtld.c:489:2: error: incompatible type for argument 1 of > ‘__builtin_mempcpy’ > rtld.c:489:2: note: expected ‘void *’ but argument is of type ‘struct > ’ This is easy to fix, but the question remains on what this is intented to do. Andreas. diff --git a/elf/rtld.c b/elf/rtld.c index 9d121dc..45d77e0 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -300,7 +300,6 @@ _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; @@ -309,12 +308,6 @@ _dl_start_final (void *arg, struct dl_start_final_info *info) 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 - GL(dl_rtld_map).l_tls_offset = NO_TLS_OFFSET; -# endif -# endif - #endif #if HP_TIMING_AVAIL @@ -396,9 +389,7 @@ _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. */ @@ -417,15 +408,13 @@ _dl_start (void *arg) 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 +#ifdef DONT_USE_BOOTSTRAP_MAP = (ElfW(Ehdr) *) &_begin; -# else -# error This will not work with prelink. +#else = (ElfW(Ehdr) *) bootstrap_map.l_addr; -# endif +#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) @@ -451,21 +440,21 @@ _dl_start (void *arg) 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 +#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 +#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 +#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 +# 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)); @@ -476,33 +465,34 @@ _dl_start (void *arg) initdtv[1].counter = 0; /* Initialize the TLS block. */ -# if TLS_TCB_AT_TP - initdtv[2].pointer = tlsblock; -# elif TLS_DTV_AT_TP +#if TLS_TCB_AT_TP + initdtv[2].pointer.val = 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, + initdtv[2].pointer.val = (char *) tlsblock + bootstrap_map.l_tls_offset; +#else +# error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" +#endif + initdtv[2].pointer.is_static = true; + p = __mempcpy (initdtv[2].pointer.val, bootstrap_map.l_tls_initimage, bootstrap_map.l_tls_initimage_size); -# ifdef HAVE_BUILTIN_MEMSET +#ifdef HAVE_BUILTIN_MEMSET __builtin_memset (p, '\0', (bootstrap_map.l_tls_blocksize - bootstrap_map.l_tls_initimage_size)); -# else +#else { size_t remaining = (bootstrap_map.l_tls_blocksize - bootstrap_map.l_tls_initimage_size); while (remaining-- > 0) *p++ = '\0'; } -# endif +#endif /* Install the pointer to the dtv. */ /* Initialize the thread pointer. */ -# if TLS_TCB_AT_TP +#if TLS_TCB_AT_TP bootstrap_map.l_tls_offset = roundup (bootstrap_map.l_tls_blocksize, TLS_INIT_TCB_ALIGN); @@ -511,12 +501,12 @@ _dl_start (void *arg) const char *lossage = TLS_INIT_TP ((char *) tlsblock + bootstrap_map.l_tls_offset, 0); -# elif TLS_DTV_AT_TP +#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 +#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); @@ -527,7 +517,6 @@ _dl_start (void *arg) /* 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); @@ -774,12 +763,7 @@ cannot allocate TLS data structures for initial thread"); /* 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 + const char *lossage = TLS_INIT_TP (tcbp, 1); if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage); tls_init_tp_called = true; @@ -2253,12 +2237,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", TLS we know the thread pointer was initialized earlier. */ 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, 1); if (__glibc_unlikely (lossage != NULL)) _dl_fatal_printf ("cannot set up thread-local storage: %s\n", lossage);