From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpout.efficios.com (smtpout.efficios.com [IPv6:2607:5300:400:ed00::31e5]) by sourceware.org (Postfix) with ESMTPS id 84A1B3858D39 for ; Thu, 9 Jan 2025 16:32:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 84A1B3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 84A1B3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:5300:400:ed00::31e5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736440349; cv=none; b=L4wEyhVyUIiLD5o2IBUavjdZLYltpjjBZrDbtiHkIKd7oBFg3YPnZ72v9y+cuz98vtitW+DJKha/F6Qxg6M/ACcxye/ZbQGIvfC7TjzBznIfWRafZcSFkeMhS3Uyyy2Y9o0jpq6sDkSIpTm6VYtzLFvKx1Etd6eleCAe/J01yEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1736440349; c=relaxed/simple; bh=QLoeqkXtHL9gddIPVoxP0UeOTu2ANKrKEPxfFkDfJSs=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=CbMvoBx3+UH7oYYgKsaWQlH8sH4qxm2nXL3PF5ECcGrCsW/lTTF7sq9s/Uv+uhnTT3AvALc4EK8XcuNYvV9jpC7tHFyvdzOxHOtX7zKyBuefUfLzS3GVSBck0a5zX87WFzG1j6qFeJzqTk5b46BuFUYvm1rlUZoQPGjpJK+W0Fs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84A1B3858D39 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=efficios.com header.i=@efficios.com header.a=rsa-sha256 header.s=smtpout1 header.b=Wsg4R3em DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1736440349; bh=QLoeqkXtHL9gddIPVoxP0UeOTu2ANKrKEPxfFkDfJSs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wsg4R3em8I5+QIlv2GzioesQFRftbjrVDiXofyffS2mlUQ15BjuNyAYCfVoyCd8RV rsnTdq2l9ZvZHkiPa4EmmDjraE1W9HCuryChEyj1/AFVvP/uPo+3wbnnNEKH0AlISl 35ii90U83Kj2UlBJNSTthQmD9/+IVR1rDtq6nwR1E7Vq8NGPo7C3XUncActIUGqfCR rGBv9WK1+XQJ+Tg45yZrANLq6ud8EwxWvFhODRAqneqLG5tSAy0k8LgLmVE4c/MDQg ehOtuo5TZfAE6kMkqTCw6hgp1hlA+nrnE2esOHhiepVP2apM3Yzb7L7Go4fZmk4aZC m5P+4NF8ick8Q== Received: from mjeanson-kernel.internal.efficios.com (96-127-217-162.qc.cable.ebox.net [96.127.217.162]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4YTVgd0WFlz1DCP; Thu, 9 Jan 2025 11:32:29 -0500 (EST) From: Michael Jeanson To: libc-alpha@sourceware.org Cc: Michael Jeanson , Florian Weimer , Carlos O'Donell , DJ Delorie , Mathieu Desnoyers Subject: [PATCH v16 4/8] nptl: add rtld_hidden_proto to __rseq_size and __rseq_offset Date: Thu, 9 Jan 2025 16:32:11 +0000 Message-Id: <20250109163215.2343659-5-mjeanson@efficios.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250109163215.2343659-1-mjeanson@efficios.com> References: <20250109163215.2343659-1-mjeanson@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: This allows accessing the internal aliases of __rseq_size and __rseq_offset from ld.so without ifdefs and avoids dynamic symbol binding at run time for both variables. Signed-off-by: Michael Jeanson Reviewed-by: Mathieu Desnoyers --- sysdeps/unix/sysv/linux/dl-rseq-symbols.S | 27 ++++++++++++++++------- sysdeps/unix/sysv/linux/rseq-internal.h | 16 ++++++++------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/sysdeps/unix/sysv/linux/dl-rseq-symbols.S b/sysdeps/unix/sysv/linux/dl-rseq-symbols.S index 353bf657b9..2502a76e50 100644 --- a/sysdeps/unix/sysv/linux/dl-rseq-symbols.S +++ b/sysdeps/unix/sysv/linux/dl-rseq-symbols.S @@ -27,14 +27,18 @@ /* Some targets define a macro to denote the zero register. */ #undef zero -/* Define 2 symbols: '__rseq_size' is public const and '_rseq_size' (an - alias of '__rseq_size') is hidden and writable for internal use by the - dynamic linker which will initialize the value both symbols point to - before copy relocations take place. */ +/* Define 3 symbols: '__rseq_size' is public const and then '_rseq_size' and + '__GI___rseq_size' (both aliases of '__rseq_size') are hidden, '_rseq_size' + is writable for internal use by the dynamic linker which will initialize + the value the symbols point to before copy relocations take place. */ .globl __rseq_size .type __rseq_size, %object .size __rseq_size, 4 + .hidden __GI___rseq_size + .globl __GI___rseq_size + .type __GI___rseq_size, %object + .size __GI___rseq_size, 4 .hidden _rseq_size .globl _rseq_size .type _rseq_size, %object @@ -42,17 +46,23 @@ .section .data.rel.ro .balign 4 __rseq_size: +__GI___rseq_size: _rseq_size: .zero 4 -/* Define 2 symbols: '__rseq_offset' is public const and '_rseq_offset' (an - alias of '__rseq_offset') is hidden and writable for internal use by the - dynamic linker which will initialize the value both symbols point to - before copy relocations take place. */ +/* Define 3 symbols: '__rseq_offset' is public const and then '_rseq_offset' + and '__GI___rseq_offset' (both aliases of '__rseq_offset') are hidden, + '_rseq_offset' is writable for internal use by the dynamic linker which will + initialize the value the symbols point to before copy relocations take + place. */ .globl __rseq_offset .type __rseq_offset, %object .size __rseq_offset, RSEQ_OFFSET_SIZE + .hidden __GI___rseq_offset + .globl __GI___rseq_offset + .type __GI___rseq_offset, %object + .size __GI___rseq_offset, RSEQ_OFFSET_SIZE .hidden _rseq_offset .globl _rseq_offset .type _rseq_offset, %object @@ -60,5 +70,6 @@ _rseq_size: .section .data.rel.ro .balign RSEQ_OFFSET_SIZE __rseq_offset: +__GI___rseq_offset: _rseq_offset: .zero RSEQ_OFFSET_SIZE diff --git a/sysdeps/unix/sysv/linux/rseq-internal.h b/sysdeps/unix/sysv/linux/rseq-internal.h index 6f565581c1..3993431707 100644 --- a/sysdeps/unix/sysv/linux/rseq-internal.h +++ b/sysdeps/unix/sysv/linux/rseq-internal.h @@ -24,6 +24,7 @@ #include #include #include +#include /* Minimum size of the rseq area allocation required by the syscall. The actually used rseq feature size may be less (20 bytes initially). */ @@ -52,19 +53,20 @@ extern unsigned int _rseq_size attribute_hidden; In .data.relro but not yet write-protected. */ extern ptrdiff_t _rseq_offset attribute_hidden; +/* We want to use rtld_hidden_proto in order to call the internal aliases + of __rseq_size and __rseq_offset from ld.so. This avoids dynamic symbol + binding at run time for both variables. */ +rtld_hidden_proto (__rseq_size) +rtld_hidden_proto (__rseq_offset) + #ifdef RSEQ_SIG static inline bool rseq_register_current_thread (struct pthread *self, bool do_rseq) { if (do_rseq) { - unsigned int size; -#if IS_IN (rtld) - /* Use the hidden symbol in ld.so. */ - size = _rseq_size; -#else - size = __rseq_size; -#endif + unsigned int size = __rseq_size; + if (size < RSEQ_AREA_SIZE_INITIAL) /* The initial implementation used only 20 bytes out of 32, but still expected size 32. */ -- 2.39.5