From patchwork Thu May 7 22:30:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 6624 Received: (qmail 48150 invoked by alias); 7 May 2015 22:30: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 48137 invoked by uid 89); 7 May 2015 22:30:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS, TBC autolearn=no version=3.3.2 X-HELO: mail-ob0-f169.google.com MIME-Version: 1.0 X-Received: by 10.202.225.65 with SMTP id y62mr697302oig.78.1431037832541; Thu, 07 May 2015 15:30:32 -0700 (PDT) In-Reply-To: <20150507211000.B2B932C3B91@topped-with-meat.com> References: <20150506203535.48EAF2C3B9D@topped-with-meat.com> <20150507201552.BD89F2C3BA8@topped-with-meat.com> <20150507211000.B2B932C3B91@topped-with-meat.com> Date: Thu, 7 May 2015 15:30:32 -0700 Message-ID: Subject: Re: [COMMITTED PATCH] BZ#18383: Add test case for large alignment in TLS blocks. From: "H.J. Lu" To: Roland McGrath Cc: "GNU C. Library" On Thu, May 7, 2015 at 2:10 PM, Roland McGrath wrote: > The log entry needs the BZ# marker. > > I'm having a hard time finding the calculation in the dynamic-linking case > that corresponds to this piece of __libc_setup_tls. Since there are two > places where the logic should match, we really should make it much more > clear how they relate. If there isn't any obvious refactoring that would > share more of this logic between the two cases, can you at least add a > comment in __libc_setup_tls that points to the implementation of the > matching logic in the dynamic-linking case? > Here is the updated patch. From bfa0232943937b861a482aeed9cbe9f2d90e181e Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 7 May 2015 13:26:34 -0700 Subject: [PATCH] Align TCB offset to the maximum alignment We need to align TCB offset to the maximum alignment for TLS_TCB_AT_TP targets, similar to what _dl_allocate_tls_storage in elf/dl-tls.c does. [BZ #18383] * csu/libc-tls.c (__libc_setup_tls): Align TCB offset to the maximum alignment for TLS_TCB_AT_TP targets. --- csu/libc-tls.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/csu/libc-tls.c b/csu/libc-tls.c index 64d1779..452c1b6 100644 --- a/csu/libc-tls.c +++ b/csu/libc-tls.c @@ -138,7 +138,9 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) to request some surplus that permits dynamic loading of modules with IE-model TLS. */ #if TLS_TCB_AT_TP - tcb_offset = roundup (memsz + GL(dl_tls_static_size), tcbalign); + /* Align the TCB offset to the maximum alignment, similar to what + _dl_allocate_tls_storage in elf/dl-tls.c does. */ + tcb_offset = roundup (memsz + GL(dl_tls_static_size), max_align); tlsblock = __sbrk (tcb_offset + tcbsize + max_align); #elif TLS_DTV_AT_TP tcb_offset = roundup (tcbsize, align ?: 1); -- 1.9.3