Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp581136rdf; Fri, 3 Nov 2023 08:59:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjHNLeeSwe58UE6JywixHm6wtL2cccYREGkiUBNFyv9KOoOGBn9FN58EkwBLQTxs8U2hNA X-Received: by 2002:a17:90a:1a44:b0:280:24a:9141 with SMTP id 4-20020a17090a1a4400b00280024a9141mr20042791pjl.28.1699027149684; Fri, 03 Nov 2023 08:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699027149; cv=none; d=google.com; s=arc-20160816; b=clAnYRqBFUP6t9d4SxUr7CTEHrQYojt8UMS9XVyNWqrok2wHjbPL8lf5GBmmeureSq iApgPBB+JuHGQEUu7BFEhqGd2zC7b9ponWIIcGAeP8OJ8lU61C/kCOjV5RbjJh15tsZp mkUNxETKfn05E5yP+yTEgA/3DeBb0v5z5mY8yWjMt/CeUE9gmwUjYcIZVkiE4aQI3kwU GY02FeBnLL60R6el0Y4Mnfl0BccxC2akJecl1t4SK56vIWvlEo2AmbNVE1Vm3pg+hsSS jHLt7fJUlAtUlagbBx7d70bheKZPwlQEXRYG5Xg7TcROpYzKhKSLz8J+Pnpa2u1Ng0YR iutw== 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=habd2PNn77ZADV9mcs8dwgbFVKyO7HK9xbC5yXA44+c=; fh=NvW3CO3GtIHRKW4YFObS4dEX0yL9bbz2APezTtyZGhQ=; b=TspPBw+Z9wjsluj50kqAsjo1uPH1IyNMUmDEIJU0/huQ8qX9Myk53FsJyn/ivksO0/ DNzEovVlAD9QXqx/auZlo3Go1+dVukrCefvWPcf0b0urPSW/vLy34myz9Y5TD79k7b+B pWQnAXuV8M05WFRng9I1x65cdtOvTMPI81pW/u/u+MO7GGZrA1wfv/DbsfVjuJ4L/lMx tYEPHx2FLxOR6Xa+FvDq7vSUDKhQ6say/Jam/EXPhM7qzhBJ9VPytIwzKPcyklkLEuXY sKZqAvYkBkx7Mz1w12zgQXeztN0k4j3otFzfNvBF2uTHHMNwQ4khO40i9e/OtisZhIGo sN6A== 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 m11-20020a1709026bcb00b001c9ce2b6b97si1687653plt.198.2023.11.03.08.59.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 08:59:09 -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 12FBA80E4A05; Fri, 3 Nov 2023 08:59:07 -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 S1344165AbjKCP66 (ORCPT + 99 others); Fri, 3 Nov 2023 11:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234328AbjKCP64 (ORCPT ); Fri, 3 Nov 2023 11:58:56 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.65.254]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE78194; Fri, 3 Nov 2023 08:58:51 -0700 (PDT) X-QQ-mid: bizesmtp83t1699027115tqmp7mar Received: from main2-ubuntu.tail147f4.ts.net ( [202.201.15.117]) by bizesmtp.qq.com (ESMTP) with id ; Fri, 03 Nov 2023 23:58:32 +0800 (CST) X-QQ-SSF: 01200000000000B06000000A0000000 X-QQ-FEAT: 3M0okmaRx3gtg4dkowId3SRZK6iJt7bmG/bknUDKf+3ULUZKiHp/tkQ2jHTjZ qCAJtCYV+PBISnAzK2lTT9gQ93lFd4WLGlpACg09bFke2VMU51xGkofztcVkF64kLeB/I40 gt7AiMXFEF2xrMMx0HrXUSXv2jHoH+pff3Xms4oos9d5sxvTKIeoM4HgumgCEXWN1DXMZGG mOnRKFHyB0tdauEDaWiRCJ4WkEsUYt3jBksdkZqXTIOM4Sg1erJZuCIGNrgNzHJvUOE0TQI qfM8VoqG8AKNC9mj7MLM6aOKtJ7PJZrzG9XhTTXhE/GAatyk3aTKEWjcCrmwWhXqp/YBb1k Fal2Ut2duOE5o37lshvTGlRfYJ/VnEvHOdQu3tDN7OWkjvzEFMMskq1oA1G7g== X-QQ-GoodBg: 0 X-BIZMAIL-ID: 4824966276626844455 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 01/14] DCE/DSE: allow keep unique bounded sections Date: Fri, 3 Nov 2023 23:58:30 +0800 Message-Id: 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 08:59:07 -0700 (PDT) From: Zhangjin Wu The bounded sections may break the elimination of some dead code. Some unused syscalls have been wrongly kept by `__ex_table`, we will unique `__ex_table` for every inserting and then remove the unused ones explicitly and eventually, the unused syscalls will be eliminated. In the future, we should find better methods to solve such issue: Some code may use '.pushsection/.popsection' to insert data to a bounded section, use `sys_sendfile` as an example: sys_sendfile: ".pushsection __ex_table,\"\"\n" ... ".long ((" insn ") - .)\n" ... ".popsection" `insn` is an address in `sys_sendfile`, even if no real user uses sys_sendfile, the keeping of __ex_table will become a 'user' and break the elimination of `sys_sendfile`. All of the bounded sections should be uniqued, and we should check if they are the last users of the code, if so, those sections should be removed and the code should be eliminated. Signed-off-by: Zhangjin Wu --- include/asm-generic/vmlinux.lds.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 9c59409104f6..ea8170e11ab1 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -103,6 +103,7 @@ #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L* #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral* #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]* +#define BSEC_MAIN(sec) sec sec##.[0-9a-zA-Z_]* #else #define TEXT_MAIN .text #define DATA_MAIN .data @@ -110,6 +111,7 @@ #define RODATA_MAIN .rodata #define BSS_MAIN .bss #define SBSS_MAIN .sbss +#define BSEC_MAIN(sec) sec #endif /* @@ -201,12 +203,12 @@ #define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _BEGIN_##_label_ = .; \ - KEEP(*(_sec_)) \ + KEEP(*(BSEC_MAIN(_sec_))) \ _END_##_label_ = .; #define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_) \ _label_##_BEGIN_ = .; \ - KEEP(*(_sec_)) \ + KEEP(*(BSEC_MAIN(_sec_))) \ _label_##_END_ = .; #define BOUNDED_SECTION_BY(_sec_, _label_) \ -- 2.34.1