From patchwork Tue Oct 1 23:05:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kele Zhang X-Patchwork-Id: 1991749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=pU8CU68n; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=WtRGuCkF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XJGNC0lLkz1xsc for ; Wed, 2 Oct 2024 10:46:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HNOsrNxRjn06PqvWglTQsXZ1VM8uFn/ev2E+aJ/Obzk=; b=pU8CU68nsG0Vfq KftgGMeY6e+qPzFOq3vKBItdm/dm8jykZGc+7gqSP1yesF7jUBDcff96+cb4KvjYOWP6J/fupcsnv CPKZmnD9h8JA+9tuFne2vhcmwxQk7XRtxDjaPJUDWEWI8+4d844TObleWUn5ojUGWnSOmDg6f/0io K/JjynsobrgKptGoCUX8UOeGnhEZPVn7G0SRFyKNZulGQnnHtyPLV3CphpiAM0oEfBaoTAAd1PUr1 9gS6zxy7QmpdbQWLsJab+vPqzm7YK/1SCFRJg+G06vV4juzGdqYYEMZMgzdefc7e9LnbYVPFEfzbh Vdbq8wvg2d34te77pfSA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1svnVs-00000004TZT-18Vs; Wed, 02 Oct 2024 00:46:44 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1svlwD-00000004INc-0AJ3 for opensbi@lists.infradead.org; Tue, 01 Oct 2024 23:05:50 +0000 Received: by mail-pj1-x1042.google.com with SMTP id 98e67ed59e1d1-2e09f67bc39so4998293a91.1 for ; Tue, 01 Oct 2024 16:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727823947; x=1728428747; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iec0JD2SQOX1HaJ/GSgdKRXwWOVXsaLqnjKt51jDN+A=; b=WtRGuCkFtMDerzi9rG/0p5f29/4jalzm/mk25nPFPdTS/9BH2ePvLkUIslOQ2awnqB 3hB1OkXaTcdGX1pE5f/PTkbKSCZZZwkHKeSTN/YNAnrTcrU7kua/mZmvhnrDZPoGvliC jiv5U3qfRc86yYDUQCDQZmYKZzMY5xFT0ubhDsx3wBUM4jeiH7SOrXeMhz87gymyMEys kVnCVp2Q9sbb0XOFZOf3XAEFfXtt84ysj+fZR534Ge8GA4wRa3cltJOhaGGbruPh10bw RG17UH2v7GVsPvHMm5O78C9yLdb8F3ua5tzeU90wDrNCzPb285LHbzfJ8/ORc3poDO8M 1PiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727823947; x=1728428747; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iec0JD2SQOX1HaJ/GSgdKRXwWOVXsaLqnjKt51jDN+A=; b=s02PQNOAeTpdB7i3yzzYVcDXnmFILFh0mZ1zIKZ7+kZ9X3JOUSFF+duuBWat0NtOKk IOzC/c/rpnVLonDSh+HW4+joSvtfjPd29Rx4UrWTl5xy/GwFAIh9JMKct96DRzSpprvA 3Y/k/toZgiZCqQGPWCBJYbT1XfESeVB1SDehuGAbPhfOBsfBImNDULiiXeOkYqXbVbtN hnISbXYbKbS2N6lL8nFz9gCyJ/PBjwRHZH7w8BjfydFvvMKgBx6IeTLQqulxjczEZaUD gEA/vuR9R6AFjkJdcUrYM36frXvo8SL+LZadCGj7psn3sPkWo32f/w9eGch5EthsPF+s AbZQ== X-Forwarded-Encrypted: i=1; AJvYcCUm5It1e0DooWudi2CxDUWmW0fkxJgRLuYMlz+ZrcT75q/M4tuFB+rynqjXJYCS5wx9KCbfPNuN@lists.infradead.org X-Gm-Message-State: AOJu0YxVY3hFzCAjO0VSDefWuC9syMsy27LdK7vfjx4tlsrtNt8WyKd5 nZho7aNTAji15apMYDVggRG6Yx+BQkweuXz4PRL8+HD7BTjbdA2o X-Google-Smtp-Source: AGHT+IG5G8OVaqHnn0kMIeYyRwMkVTMGse7KI0IsSUxCpnnWY5eNFm0SZvs+Dp6mZsQJyug6S2xOkw== X-Received: by 2002:a17:90a:a10d:b0:2c9:81fd:4c27 with SMTP id 98e67ed59e1d1-2e184681375mr1548563a91.14.1727823947182; Tue, 01 Oct 2024 16:05:47 -0700 (PDT) Received: from localhost.localdomain ([2a01:4ff:1f0:1c14::1]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2e18f540fe7sm162731a91.8.2024.10.01.16.05.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2024 16:05:46 -0700 (PDT) From: Kele Zhang To: wxjstz@126.com, bmeng.cn@gmail.com, opensbi@lists.infradead.org, jrtc27@jrtc27.com Cc: tanyuan@tinylab.org, falcon@tinylab.org, Kele Zhang Subject: [PATCH v4 0/1] Enable Dead Code Elimination Date: Tue, 1 Oct 2024 23:05:34 +0000 Message-Id: X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241001_160549_146303_27FC95B0 X-CRM114-Status: UNSURE ( 9.28 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.8 (-) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: This patch enables `--gc-sections`. Dead Code Elimination (DCE) can reduce binary size and the attack surface without introducing side effects, and it has been used in the Linux kernel for many years. Content analysis details: (-1.8 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:1042 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [zhangcola2003(at)gmail.com] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [zhangcola2003(at)gmail.com] X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch enables `--gc-sections`. Dead Code Elimination (DCE) can reduce binary size and the attack surface without introducing side effects, and it has been used in the Linux kernel for many years. After testing, enabling DCE does not affect the normal functionality of OpenSBI. --- v1: https://lists.infradead.org/pipermail/opensbi/2024-August/007286.html v2: https://lists.infradead.org/pipermail/opensbi/2024-August/007301.html v3: https://lists.infradead.org/pipermail/opensbi/2024-September/007344.html --- Changes in v2: - Move --gc-sections to ELFFLAGS - Remove redundant KEEP() Changes in v3: - Move --print-gc-sections to ifneq ($(DEBUG),) - Move "ifneq ($(DEBUG),)" to the latter part of the Makefile, ensuring that "ELFFLAGS += $(USE_LD_FLAG)" remains at the beginning. Changes in v4: - fix: replace spaces with tabs for consistent indentation --- Kele Zhang (1): Makefile: enable --gc-sections Makefile | 15 +++++++++------ firmware/fw_base.ldS | 1 + 2 files changed, 10 insertions(+), 6 deletions(-)