Message ID | 87y2nrw1za.fsf@oldenburg2.str.redhat.com |
---|---|
State | Committed |
Headers |
Return-Path: <libc-alpha-bounces@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7CDBA3842400; Fri, 10 Jul 2020 20:26:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7CDBA3842400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1594412801; bh=9aZEIEw6peT2FHJCzKt+vpXNW6cNDdOdc1Rs/MfAguA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Ghz/fuPeqtNa8C7+NnXscpiQTDeHIgkeJPHiDNQWo1J6CK/ouJQjZbiSf+dw76YK6 6FocHHkIXH2NMnA9yO9MGbT/RRFQC5wdCEEJeA/RWaiTvlXa6lyX0S4sBX1l1dsZdG 5UUpfohoo26968NfyJuVFEiLq5C4perXIRPgvimo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id B62EA3844044 for <libc-alpha@sourceware.org>; Fri, 10 Jul 2020 20:26:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B62EA3844044 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-nzarsF2WPee3rAYyT8QJ5Q-1; Fri, 10 Jul 2020 16:26:35 -0400 X-MC-Unique: nzarsF2WPee3rAYyT8QJ5Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CB971009441 for <libc-alpha@sourceware.org>; Fri, 10 Jul 2020 20:26:35 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-118.ams2.redhat.com [10.36.113.118]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9684874F44 for <libc-alpha@sourceware.org>; Fri, 10 Jul 2020 20:26:34 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [PATCH] elf: Support at least 32-byte alignment in static dlopen Date: Fri, 10 Jul 2020 22:26:33 +0200 Message-ID: <87y2nrw1za.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <http://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <http://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> From: Florian Weimer via Libc-alpha <libc-alpha@sourceware.org> Reply-To: Florian Weimer <fweimer@redhat.com> Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" <libc-alpha-bounces@sourceware.org> |
Series |
elf: Support at least 32-byte alignment in static dlopen
|
|
Commit Message
Florian Weimer
July 10, 2020, 8:26 p.m. UTC
Otherwise loading a dynamically linked libc with rseq support fails, as result of the __rseq_abi TLS variable, which has an alignment of 32 bytes. --- csu/libc-tls.c | 6 ++++++ 1 file changed, 6 insertions(+)
Comments
On 7/10/20 4:26 PM, Florian Weimer via Libc-alpha wrote: > Otherwise loading a dynamically linked libc with rseq support fails, > as result of the __rseq_abi TLS variable, which has an alignment > of 32 bytes. OK for 2.32. Reviewed-by: Carlos O'Donell <carlos@redhat.com> > --- > csu/libc-tls.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/csu/libc-tls.c b/csu/libc-tls.c > index 06e76bd395..3f1655f264 100644 > --- a/csu/libc-tls.c > +++ b/csu/libc-tls.c > @@ -112,6 +112,12 @@ __libc_setup_tls (void) > size_t tcb_offset; > const ElfW(Phdr) *phdr; > > + /* libc.so with rseq has TLS with 32-byte alignment. Static dlopen > + requires at least 32-byte alignment as well, otherwise loading > + libc.so will always fail. */ > + if (max_align < 32) > + max_align = 32; OK. Same problem as the previous discuss, namely that you'd need to look over all the modules you're going to dlopen first to compute a value that is large enough. All we're doing here is papering over a design problem, but that is OK for 2.32. Eventually we're going to need to do some kind of redesign here to make this more reliable. > + > struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; > > /* Look through the TLS segment if there is any. */ >
On 7/10/20 1:49 PM, Carlos O'Donell via Libc-alpha wrote: > On 7/10/20 4:26 PM, Florian Weimer via Libc-alpha wrote: >> Otherwise loading a dynamically linked libc with rseq support fails, >> as result of the __rseq_abi TLS variable, which has an alignment >> of 32 bytes. > > OK for 2.32. > > Reviewed-by: Carlos O'Donell <carlos@redhat.com> Fixes most of the ARC issues. Tested-by: Vineet Gupta <vgupta@synopsys.com> >> --- >> csu/libc-tls.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/csu/libc-tls.c b/csu/libc-tls.c >> index 06e76bd395..3f1655f264 100644 >> --- a/csu/libc-tls.c >> +++ b/csu/libc-tls.c >> @@ -112,6 +112,12 @@ __libc_setup_tls (void) >> size_t tcb_offset; >> const ElfW(Phdr) *phdr; >> >> + /* libc.so with rseq has TLS with 32-byte alignment. Static dlopen >> + requires at least 32-byte alignment as well, otherwise loading >> + libc.so will always fail. */ >> + if (max_align < 32) >> + max_align = 32; > > OK. Same problem as the previous discuss, namely that you'd need to look > over all the modules you're going to dlopen first to compute a value > that is large enough. All we're doing here is papering over a design problem, > but that is OK for 2.32. Eventually we're going to need to do some kind of > redesign here to make this more reliable. > >> + >> struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; >> >> /* Look through the TLS segment if there is any. */ >> > >
On Fri, Jul 10, 2020 at 1:29 PM Florian Weimer via Libc-alpha <libc-alpha@sourceware.org> wrote: > > Otherwise loading a dynamically linked libc with rseq support fails, > as result of the __rseq_abi TLS variable, which has an alignment > of 32 bytes. Fixes the RV32 regressions: Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Tested-by: Alistair Francis <alistair.francis@wdc.com> Alistair > > --- > csu/libc-tls.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/csu/libc-tls.c b/csu/libc-tls.c > index 06e76bd395..3f1655f264 100644 > --- a/csu/libc-tls.c > +++ b/csu/libc-tls.c > @@ -112,6 +112,12 @@ __libc_setup_tls (void) > size_t tcb_offset; > const ElfW(Phdr) *phdr; > > + /* libc.so with rseq has TLS with 32-byte alignment. Static dlopen > + requires at least 32-byte alignment as well, otherwise loading > + libc.so will always fail. */ > + if (max_align < 32) > + max_align = 32; > + > struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; > > /* Look through the TLS segment if there is any. */ >
* Alistair Francis: > On Fri, Jul 10, 2020 at 1:29 PM Florian Weimer via Libc-alpha > <libc-alpha@sourceware.org> wrote: >> >> Otherwise loading a dynamically linked libc with rseq support fails, >> as result of the __rseq_abi TLS variable, which has an alignment >> of 32 bytes. > > Fixes the RV32 regressions: > > Reviewed-by: Alistair Francis <alistair.francis@wdc.com> > Tested-by: Alistair Francis <alistair.francis@wdc.com> Thanks, now pushed. Florian
diff --git a/csu/libc-tls.c b/csu/libc-tls.c index 06e76bd395..3f1655f264 100644 --- a/csu/libc-tls.c +++ b/csu/libc-tls.c @@ -112,6 +112,12 @@ __libc_setup_tls (void) size_t tcb_offset; const ElfW(Phdr) *phdr; + /* libc.so with rseq has TLS with 32-byte alignment. Static dlopen + requires at least 32-byte alignment as well, otherwise loading + libc.so will always fail. */ + if (max_align < 32) + max_align = 32; + struct link_map *main_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; /* Look through the TLS segment if there is any. */