Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp586633rdf; Fri, 3 Nov 2023 09:05:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGiMs6b64J4Td2FV9FmVLa3HS7Fql35nHINZdO7b2wpv+POhaaYa7IKWvFPClxSoxJXBOOU X-Received: by 2002:a05:6870:12d0:b0:1e9:b599:1aab with SMTP id 16-20020a05687012d000b001e9b5991aabmr21303990oam.58.1699027517812; Fri, 03 Nov 2023 09:05:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699027517; cv=none; d=google.com; s=arc-20160816; b=kztS7eSJvSsNEba1dmsxxEjDuSus8enwOXff9iN85W8D4HcX1fL8kyMgaTbdKnKWdE h/SpJqBaHYOppuJJUyzG9P5vPJo1NPoTMrdiDBZ6rVVsnQNtLAMjf+YHdtzkxU+HuFqR qod/XAyzJkvAApRZUPzMARyNATwD7BHoOwCjcMNhiBUEy5DIpxJhB26HubhVc8cK7cUr iXfUAveKc0PRx2zIRyqxp9Xld9XOxi2Y7geUpxSFPNwh+1qNNs1+R9I+338K+3SiTCLC jsgWcfjaGdm22vYezzHxwNnNlol5byoxGCuLuC4kAi8XkOj4Ek+stV89oCZ0zJBYTigl 1zeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=xgBF3zi85yFEyPhDBUpKPoMdPO2WR/CLm+LR34GujmE=; fh=NvW3CO3GtIHRKW4YFObS4dEX0yL9bbz2APezTtyZGhQ=; b=Jj61GYc1jjeAo1X67ue/usyRbTPzPjpzZdF5O7Ru4dqewUZOgjBNzqlg4q6xf/YPXe G1xViG+yHcR1uGJi7tI3z1qFbc0ca/TG98CtRhiilXERpcgB9qeJp6UQMT4PzXHgRSEh CZpLsyVYwlfHqUK1mA6W6hjeIGhApZL4H2176fiXlJmx14FYcly/5Ps0J4ugFfDSJ88+ Q3ER9Mlt/OKuPkWuwwf5HbXY6aiEpBhskT6ujooAc/8jiBX4XpfxA0TXdYErPSZo0RpQ IQGH8s4bP5aS8fLB+NNZlGXXz7vtrvcPv8JHVqEEgKieW482euCKmzYERwAJxyOw+RQ/ 4ssg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id uu12-20020a056870ae0c00b001ba6be6f136si770893oab.56.2023.11.03.09.05.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 09:05:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C669D80E4A19; Fri, 3 Nov 2023 09:05:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345319AbjKCQEg (ORCPT + 99 others); Fri, 3 Nov 2023 12:04:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344453AbjKCQEf (ORCPT ); Fri, 3 Nov 2023 12:04:35 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.154.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE9041BC; Fri, 3 Nov 2023 09:04:31 -0700 (PDT) X-QQ-mid: bizesmtp78t1699027456tnrc347s Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 04 Nov 2023 00:04:13 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: mot7IUESEd/O3Ye3RvUm0u0JfDP8ilGw6DJ+bg2ku9yW02xqru4czyWnDR4JC EQdnw8q1TsviTHclgFaJRSxxEJSFDKoZfMUzfWIOoWQW5FI9+0rOhbgL2xFjAIQLOk/WiNb Ze0d8K6zH/AYLaKpQIAtAZG4jS7M72shuT9euUEJaCCA/CcImxoiQrXkdoAg+grDS7lI/xU DnpaZjUvJet9LH1I1tXUT2k+8t0nGwPGjmBS7XYMcEABQ3GlVXZx8/iDCsrMmgIy1Mf4YxT 25ig0IbUsLLwVXn/38HbQVCzou/49TJyeRhZOCpzf0rKiNfEg1KrsIRdd33Cz5XTnn7Ws/O zQ60yzEUchZNK3VB1+XcP3Ha7KKHjs9ib0py4O2 X-QQ-GoodBg: 0 X-BIZMAIL-ID: 6096022325544553150 From: Yuan Tan To: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, luc.vanoostenryck@gmail.com, linux-sparse@vger.kernel.org Cc: linux@weissschuh.net, palmer@rivosinc.com, paul.walmsley@sifive.com, paulburton@kernel.org, paulmck@kernel.org, tim.bird@sony.com, tsbogend@alpha.franken.de, w@1wt.eu, tanyuan@tinylab.org, i@maskray.me Subject: [PATCH v1 13/14] DCE/DSE: add SECTION_NO_KEEP_SUPPORT option Date: Sat, 4 Nov 2023 00:04:10 +0800 Message-Id: <4ad1b8cb7cd54c57e74e877235f64b5be5bbbe8f.1699025537.git.tanyuan@tinylab.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrgz:qybglogicsvrgz5a-1 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 03 Nov 2023 09:05:13 -0700 (PDT) It is able to drop the brute KEEP() keyword for some sections, when the sections are able to link or group together with one of the used sections. Some syscalls are actually orphan sections. SECTION_SHF_LINK_ORDER_SUPPORT or SECTION_SHF_GROUP_SUPPORT creates references for these sections, eliminating the need for the KEEP() directive. Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- include/asm-generic/vmlinux.lds.h | 24 ++++++++++++++++++------ init/Kconfig | 9 +++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index ea8170e11ab1..f10afc42a1ac 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -201,18 +201,30 @@ # endif #endif -#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#ifdef CONFIG_SECTION_NO_KEEP_SUPPORT +#define NO_KEEP(sec) sec +#else +#define NO_KEEP(sec) KEEP(sec) +#endif + +#define _BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _KEEP_, ...) \ _BEGIN_##_label_ = .; \ - KEEP(*(BSEC_MAIN(_sec_))) \ + _KEEP_(*(BSEC_MAIN(_sec_))) \ _END_##_label_ = .; -#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ +#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, ...) \ + _BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, ##__VA_ARGS__, KEEP) + +#define _BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _KEEP_, ...)\ _label_##_BEGIN_ = .; \ - KEEP(*(BSEC_MAIN(_sec_))) \ + _KEEP_(*(BSEC_MAIN(_sec_))) \ _label_##_END_ = .; -#define BOUNDED_SECTION_BY(_sec_, _label_) \ - BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop) +#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, ...) \ + _BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, ##__VA_ARGS__, KEEP) + +#define BOUNDED_SECTION_BY(_sec_, _label_, ...) \ + _BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop, ##__VA_ARGS__, KEEP) #define BOUNDED_SECTION(_sec) BOUNDED_SECTION_BY(_sec, _sec) diff --git a/init/Kconfig b/init/Kconfig index 9599d2de44e8..aeb859e410b2 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1467,6 +1467,13 @@ config HAVE_SECTION_NO_KEEP_SUPPORT depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT || HAVE_SECTION_SHF_GROUP_SUPPORT default y +config SECTION_NO_KEEP_SUPPORT + bool + depends on SECTION_SHF_LINK_ORDER_SUPPORT || SECTION_SHF_GROUP_SUPPORT + default y + help + This option allows some sections unkept so they can be GC + config HAVE_SECTION_SHF_LINK_ORDER_SUPPORT bool depends on AS_IS_GNU && AS_VERSION >= 23500 @@ -1765,6 +1772,7 @@ config RESTRICTED_TRIM_UNUSED_SYSCALLS config SECTION_SHF_LINK_ORDER_SUPPORT bool "Using SHF_LINK_ORDER attribute (EXPERIMENTAL)" if EXPERT depends on HAVE_SECTION_SHF_LINK_ORDER_SUPPORT + select SECTION_NO_KEEP_SUPPORT help Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table like sections in kernel space. @@ -1778,6 +1786,7 @@ config SECTION_SHF_LINK_ORDER_SUPPORT config SECTION_SHF_GROUP_SUPPORT bool "Using SHF_GROUP attribute (EXPERIMENTAL)" if EXPERT depends on HAVE_SECTION_SHF_GROUP_SUPPORT + select SECTION_NO_KEEP_SUPPORT help Say Y here to trim more 'unused' syscalls wrongly kept by __ex_table like sections in kernel space. -- 2.34.1