From patchwork Thu Apr 11 10:21:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1083836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=kalray.eu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kalray.eu header.i=@kalray.eu header.b="nxa4YMMj"; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44fxtg45Vhz9ryj for ; Thu, 11 Apr 2019 20:23:05 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id 26D8010141; Thu, 11 Apr 2019 12:22:59 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from zimbra2.kalray.eu (zimbra2.kalray.eu [92.103.151.219]) by helium.openadk.org (Postfix) with ESMTPS id 94AD11013A for ; Thu, 11 Apr 2019 12:22:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 1BE9727E04E2 for ; Thu, 11 Apr 2019 12:22:57 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id MKZERUKvyuD6; Thu, 11 Apr 2019 12:22:56 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id B686F27E04E1; Thu, 11 Apr 2019 12:22:56 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu B686F27E04E1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1554978176; bh=DZkIQdO9CBL8+qwupxQn9Popx79ZmAMEzHbWJ2w9yZc=; h=From:To:Date:Message-Id:MIME-Version; b=nxa4YMMjIqcj3nUR2WviuDytWXCGzt1IpZwUB/P0sUYOGYaBL0uCH2SThQmuB6dCg yRXSGYnt7Jnkt+zV/XRCW0vfmi0pIx9z51dtV3l3xfjm92MuCA6cfMO8xo4Q+2rsWG gJwf+Yxik1yKjmRw/RPSgisddtnxSfgW1IUrKr8U= X-Virus-Scanned: amavisd-new at zimbra2.kalray.eu Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id e2uUBWNxnDxv; Thu, 11 Apr 2019 12:22:56 +0200 (CEST) Received: from junon.lin.mbt.kalray.eu (unknown [192.168.37.161]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id A11F827E04E0; Thu, 11 Apr 2019 12:22:56 +0200 (CEST) From: Yann Sionneau To: devel@uclibc-ng.org Date: Thu, 11 Apr 2019 12:21:57 +0200 Message-Id: <20190411102157.7522-1-ysionneau@kalray.eu> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [uclibc-ng-devel] [PATCH] Fix TLS allocation and loading in !SHARED case X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" For ARCH where shared lib are not supported: - SHARED is not set (!SHARED is true) - __ARCH_HAS_NO_LDSO__ is set so code inside #if !defined __ARCH_HAS_NO_LDSO__ && !defined SHARED is compiled-out. But without a call do _dl_aux_init(), _dl_phdr stays NULL and __libc_setup_tls won't be able to allocate memory for the in-executable TLS and also won't be able to load the initimage from ELF TLS segment. This results in segfault when doing things like "errno = 0" like in tst-cancel15.c for instance in uClibc-ng testsuite. Signed-off-by: Yann Sionneau --- libc/misc/internals/__uClibc_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/misc/internals/__uClibc_main.c b/libc/misc/internals/__uClibc_main.c index 849bca8..affa0ce 100644 --- a/libc/misc/internals/__uClibc_main.c +++ b/libc/misc/internals/__uClibc_main.c @@ -370,7 +370,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc, char **argv, void (*app_init)(void), void (*app_fini)(void), void (*rtld_fini)(void), void *stack_end attribute_unused) { -#if !defined __ARCH_HAS_NO_LDSO__ && !defined SHARED +#ifndef SHARED unsigned long *aux_dat; ElfW(auxv_t) auxvt[AT_EGID + 1]; #endif @@ -396,7 +396,7 @@ void __uClibc_main(int (*main)(int, char **, char **), int argc, __environ = &argv[argc]; } -#if !defined __ARCH_HAS_NO_LDSO__ && !defined SHARED +#ifndef SHARED /* Pull stuff from the ELF header when possible */ memset(auxvt, 0x00, sizeof(auxvt)); aux_dat = (unsigned long*)__environ;