From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 525833858D37; Sun, 12 Jul 2020 15:55:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 525833858D37 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc] elf: Support at least 32-byte alignment in static dlopen X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/master X-Git-Oldrev: 43530ba1dc4fccd438fefa26f50977ff6bf284c7 X-Git-Newrev: 48699da1c468543ade14777819bd1b4d652709de Message-Id: <20200712155510.525833858D37@sourceware.org> Date: Sun, 12 Jul 2020 15:55:10 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jul 2020 15:55:10 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=48699da1c468543ade14777819bd1b4d652709de commit 48699da1c468543ade14777819bd1b4d652709de Author: Florian Weimer Date: Sun Jul 12 17:53:58 2020 +0200 elf: Support at least 32-byte alignment in static dlopen 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. Reviewed-by: Carlos O'Donell Tested-by: Vineet Gupta Reviewed-by: Alistair Francis Tested-by: Alistair Francis Diff: --- 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. */