From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id A7D4D3858404 for ; Mon, 15 May 2023 14:48:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A7D4D3858404 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ac89e6a5a1so127142641fa.0 for ; Mon, 15 May 2023 07:48:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684162100; x=1686754100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=H8SKUlF5AeHkhSntvYV/CARs03lANPRLi+lKu03gqcg=; b=lX9v07SCpji6oiKD5ZfgHWpskkuALD8Ukf/tiG4SogbM0iAuYi+C/Q7zXgPG+HUlQb WjK0VKZGTD72hMkumNYNBCmVsdD/zC55c+e2psnLFdpxW3gNrxXZmedddQziP2vaJMWk hW5EMBQaWqBif7MSKPJKrhp0g0TGjaACmU0liu3lakxQWehFHc2VX5Clk7G90H9PJTfi mgBpSG3X5JzMuz/d1BpQhmUFYdh7n8plXhzmqykekEFvxVm8GR45RpYdCklNHHO+WnNk F7oByDjnLgmb5k/Of750K+QO1L81qkcNudQeiT5XjDhJQxY5aOt6yhGPPv3G7ukPUVwi eOug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684162100; x=1686754100; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H8SKUlF5AeHkhSntvYV/CARs03lANPRLi+lKu03gqcg=; b=ThEp79GKWpoSaFtxhbbEYVqUxgYj2O586QHWU2ergWCcB90I1ZXsCTU4ATOboEm/jM SYnl8EXEERv7hMRyTZgkeYLSSeRZIgoxXDOSsQqYvWmWojohE5w6dfs2hWCo9M8gsTKW y1i3Min35d19/jCxQ3+a4sKuarMKIoa9nPTYg7blp89BzJKqKClIMfEcYhfYvkOrx/m+ iKKafPF9jgHd9hOmNNkMGSL2KEeJ89mmjFPf35q8GisZHIh1U7wkvH4z2MIVTGi2+gIG FUZAr9wVWzr5e7vnRIxOyYWVcGMGQto4ST2YKOEjpspV/u/MmIZtvlm4iWc09LNSEDOj nQGA== X-Gm-Message-State: AC+VfDwvXFBLlzh6jiwiACeBCJ3fCcf+ogYY6I4ytRcTLBfHSKGhWKxk 01jrujVHQtTQBblkmbg5E0sWjqxxaT0= X-Google-Smtp-Source: ACHHUZ7NFZ/yypXPW5KczHeZrQYnWjCnmAv1mfkSCLDwbpaf/pZsKM9NJYbRB4gxV1CE/0T7Euzt9g== X-Received: by 2002:ac2:46ee:0:b0:4f1:5001:1d9c with SMTP id q14-20020ac246ee000000b004f150011d9cmr7087321lfo.55.1684162099799; Mon, 15 May 2023 07:48:19 -0700 (PDT) Received: from surface-pro-6.. ([194.190.106.50]) by smtp.gmail.com with ESMTPSA id w9-20020a056512098900b004f11e965308sm2643336lft.20.2023.05.15.07.48.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 May 2023 07:48:19 -0700 (PDT) From: Sergey Bugaev To: libc-alpha@sourceware.org Subject: [RFC PATCH 3/6] sys/cdefs.h: Define __TEXT_STARTUP & __TEXT_EXIT Date: Mon, 15 May 2023 17:48:12 +0300 Message-Id: <20230515144815.3939017-4-bugaevc@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230515144815.3939017-1-bugaevc@gmail.com> References: <20230515144815.3939017-1-bugaevc@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE 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: GCC already tries to place functions that it knows will only be called at startup (constructors and main ()) into .text.startup, and those that will only be called at exit (destructors) into .text.exit, to improve cache locality. These contents of these sections then get grouped together during linking. What GCC does not know is that glibc contains a lot of code that is not ELF constructors or destructors (nor main ()), but that is also only executed on startup or exit. To help GCC and the linker group such code together, we can mark it up explicitly. To that end, this patch introduces __TEXT_STARTUP and __TEXT_EXIT macros that can be applied to functions to mark them as startup-only or exit-only, respectively. Signed-off-by: Sergey Bugaev --- include/sys/cdefs.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/sys/cdefs.h b/include/sys/cdefs.h index ef78edda..da866784 100644 --- a/include/sys/cdefs.h +++ b/include/sys/cdefs.h @@ -43,6 +43,9 @@ rtld_hidden_proto (__chk_fail) #endif +#define __TEXT_STARTUP __attribute__ ((section (".text.startup"))) +#define __TEXT_EXIT __attribute__ ((section (".text.exit"))) + #endif /* !defined _ISOMAC */ #endif -- 2.40.1