From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1792) id 5A612386F82F; Thu, 4 Jan 2024 22:49:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5A612386F82F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1704408588; bh=0U3MKF6sYxUvhboQR702ZWl7VSmboHPZFhf6sdZy/Xs=; h=From:To:Subject:Date:From; b=hdxlL1W1lNn6BUriOXzxUi89ddymWtiZoZ+FDmvZtPyHU1kht9nGmTfGGAiYxqrkN 1jBDNfPWwJI5PyBOVe3yGdAV9AeF1eBljzLPtBhchDKEFE3AMiOru6TOZCKjfbsKiM m9HYpOk9Ayl4uAuB3uxQAPgIWP4ZNq1HBDma80B4= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Samuel Thibault To: glibc-cvs@sourceware.org Subject: [glibc] hurd: Only init early static TLS if it's used to store stack or pointer guards X-Act-Checkin: glibc X-Git-Author: Sergey Bugaev X-Git-Refname: refs/heads/master X-Git-Oldrev: 9eaa0e179962a10db91fe566753fc38623097dbe X-Git-Newrev: 4145de65f696ae06be72fadd67967be556c31ac2 Message-Id: <20240104224948.5A612386F82F@sourceware.org> Date: Thu, 4 Jan 2024 22:49:48 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=4145de65f696ae06be72fadd67967be556c31ac2 commit 4145de65f696ae06be72fadd67967be556c31ac2 Author: Sergey Bugaev Date: Wed Jan 3 20:14:43 2024 +0300 hurd: Only init early static TLS if it's used to store stack or pointer guards This is the case on both x86 architectures, but not on AArch64. Signed-off-by: Sergey Bugaev Message-ID: <20240103171502.1358371-11-bugaevc@gmail.com> Diff: --- sysdeps/mach/hurd/init-first.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sysdeps/mach/hurd/init-first.c b/sysdeps/mach/hurd/init-first.c index 8526191692..26ccd37e55 100644 --- a/sysdeps/mach/hurd/init-first.c +++ b/sysdeps/mach/hurd/init-first.c @@ -38,7 +38,16 @@ extern int __libc_argc attribute_hidden; extern char **__libc_argv attribute_hidden; extern char **_dl_argv; -#ifndef SHARED +#if !defined (SHARED) && (defined (THREAD_SET_STACK_GUARD) || defined (THREAD_SET_POINTER_GUARD)) +/* In the static case, we need to set up TLS early so that the stack + protection guard can be read at from TLS by the GCC-generated snippets, + on architectures that store the guard in TLS and not globally. */ +# define USE_INIT1_TCBHEAD 1 +#else +# define USE_INIT1_TCBHEAD 0 +#endif + +#if USE_INIT1_TCBHEAD static tcbhead_t __init1_tcbhead; #endif @@ -153,9 +162,7 @@ first_init (void) /* Initialize data structures so we can do RPCs. */ __mach_init (); -#ifndef SHARED - /* In the static case, we need to set up TLS early so that the stack - protection guard can be read at from TLS by the GCC-generated snippets. */ +#if USE_INIT1_TCBHEAD _hurd_tls_init (&__init1_tcbhead, 0); #endif