From patchwork Sat Aug 24 08:16:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kele Zhang <1952088712@qq.com> X-Patchwork-Id: 1976350 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=MPO9EY+5; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=V7Atvi3n; 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 4WrVG02Sklz1yfF for ; Sat, 24 Aug 2024 18:19:04 +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:References:In-Reply-To: Date:Subject:Cc:To:From:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=20t2zUrvejAlDYMGMH5l76VyBHHsLZ/6LqLI1VoF7w4=; b=MPO9EY+5CO7WyP pYcOQDIu3TCx8ujcahOMMjWRs1EQd3+e1h/CQx0avqEpth3U2PkptNtkf7SqORlxX2BBpMoLh4qx2 rgn3yYFRNGhQo6bnxN64nUDf69d/jg9uDBPpJXFRBBa098iKWe+mowLCJym4TYlWehC5p+cPwWx5M q4365Tgn5sawynR6cYQvkgdU+SEJv5rB2X2d4RFmDPaInowGuB3FEd3QH6Cju+7EsErhtIX8FP+RB 2Xu81mUCA5TQxkPPqdT8ak12N2TQ0Li6DcSUEAbk3uId5s9LmFQWAdG+8o1f/QPQCfZLdZbfuNnKR 4ENnsXhoZv2MEamZ/y/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1shlz6-00000001ouh-3pIZ; Sat, 24 Aug 2024 08:18:56 +0000 Received: from out203-205-221-221.mail.qq.com ([203.205.221.221]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1shlz4-00000001otx-2Mek for opensbi@lists.infradead.org; Sat, 24 Aug 2024 08:18:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1724487527; bh=N/wnGZKV4ziN2EksnINowHvVxtvZqws57ij+KysiK9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V7Atvi3nCYfvJMFdNXq/KNjfEnG2DYOKvS4LuAWeoYELhEn1Jp7oadVDC4lixTIvH tBctHNBTVKWj1puni+7qCQhe903UWP5oSUK4SAaWa4l2q9w6fAM9PhaM10T5mghIR8 DjExDck8+dKOGgRqYDxOMNWtwp1Z/dT2ZIR+u1+8= Received: from main2-ubuntu.tail147f4.ts.net ([202.201.15.117]) by newxmesmtplogicsvrszc13-0.qq.com (NewEsmtp) with SMTP id 4AE05E59; Sat, 24 Aug 2024 16:18:46 +0800 X-QQ-mid: xmsmtpt1724487526tafj6jqqm Message-ID: X-QQ-XMAILINFO: N7h1OCCDntujQJtzLmeAL1oSbXwyC+OWESYnp0KWeGeQLLYdlLRV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712@qq.com> To: opensbi@lists.infradead.org Cc: tanyuan@tinylab.org, falcon@tinylab.org, Kele Zhang <1952088712@qq.com> Subject: [PATCH 1/2] Makefile: enable --gc-sections Date: Sat, 24 Aug 2024 16:16:44 +0800 X-OQ-MSGID: <20b74733d522fbf312666bd4fd9e1c12b9073011.1724487146.git.1952088712@qq.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240824_011854_926137_7F90CB5A X-CRM114-Status: UNSURE ( 9.81 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 1.1 (+) 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: The --gc-sections option enables the linker to perform garbage collection of unreferenced code and data, thereby reducing the binary size. The -ffunction-sections option will place each function into a separate section, so it is necessary to add .text.* to the linker script. Content analysis details: (1.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [203.205.221.221 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [203.205.221.221 listed in sa-accredit.habeas.com] 0.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [203.205.221.221 listed in sa-trusted.bondedsender.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [1952088712(at)qq.com] 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [1952088712(at)qq.com] 1.0 RDNS_DYNAMIC Delivered to internal network by host with dynamic-looking rDNS -0.0 T_SCC_BODY_TEXT_LINE No description available. 2.0 HELO_DYNAMIC_IPADDR Relay HELO'd using suspicious hostname (IP addr 1) 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [203.205.221.221 listed in bl.score.senderscore.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 The --gc-sections option enables the linker to perform garbage collection of unreferenced code and data, thereby reducing the binary size. The -ffunction-sections option will place each function into a separate section, so it is necessary to add .text.* to the linker script. Signed-off-by: Kele Zhang <1952088712@qq.com> Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu --- Makefile | 4 ++-- firmware/fw_base.ldS | 1 + firmware/fw_payload.elf.ldS | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9c7fd4d..9abea9f 100644 --- a/Makefile +++ b/Makefile @@ -346,9 +346,9 @@ GENFLAGS += $(libsbiutils-genflags-y) GENFLAGS += $(platform-genflags-y) GENFLAGS += $(firmware-genflags-y) -CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing +CFLAGS = -g -Wall -Werror -ffreestanding -nostdlib -fno-stack-protector -fno-strict-aliasing -ffunction-sections -fdata-sections -Wl,--gc-sections ifneq ($(DEBUG),) -CFLAGS += -O0 +CFLAGS += -O0 -Wl,--print-gc-sections else CFLAGS += -O2 endif diff --git a/firmware/fw_base.ldS b/firmware/fw_base.ldS index fb47984..a33746a 100644 --- a/firmware/fw_base.ldS +++ b/firmware/fw_base.ldS @@ -20,6 +20,7 @@ PROVIDE(_text_start = .); *(.entry) *(.text) + *(.text.*) . = ALIGN(8); PROVIDE(_text_end = .); } diff --git a/firmware/fw_payload.elf.ldS b/firmware/fw_payload.elf.ldS index f1a544b..4e1f011 100644 --- a/firmware/fw_payload.elf.ldS +++ b/firmware/fw_payload.elf.ldS @@ -23,7 +23,7 @@ SECTIONS .payload : { PROVIDE(_payload_start = .); - *(.payload) + KEEP(*(.payload)) . = ALIGN(8); PROVIDE(_payload_end = .); }