From patchwork Thu Aug 29 20:12:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kele Zhang X-Patchwork-Id: 1978615 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=WpY+me5T; 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=glFCSqad; 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 4Wvsrm3rQ2z1yXd for ; Fri, 30 Aug 2024 06:12:24 +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: 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: List-Owner; bh=1B1dIWvIxUPhAQxpGSG2fti45fys+4uRKNe8Fhyn9jM=; b=WpY+me5T1iRE1Y frQjIsstY7Burv5/NChaUxw6ntq95sR377lfKOPsV6jjNUXdxTR/aQSi/d+1cgL8LjVrbtwngiRCQ 7RJ6kFKxZYZXi457weBg+0C5ZAfeKjud3V1B5By5eMUB6NwuweMPw8i/2I5LrWx6WtpjgUXk0119u NIGNdfQhhC1v3I/SJCn3cjtKRc0WVWgc2QgRWNJjtNG0Kcp9DDV8xqGVrzY1CV0/Z22L1cT9sNFG1 M/6S5ipIkPQCh1MUUUT8bwo8CkhCUCVEDMtdAlj46fPbyJaLXrrvy5ch4v/olMUVYzBwj3pzPbIag 2fXV6wOa1yclGMbJLaFw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjlVB-00000003UjQ-44EW; Thu, 29 Aug 2024 20:12:17 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sjlV8-00000003Ugr-18hp for opensbi@lists.infradead.org; Thu, 29 Aug 2024 20:12:15 +0000 Received: by mail-pl1-x641.google.com with SMTP id d9443c01a7336-201e52ca0caso7549525ad.3 for ; Thu, 29 Aug 2024 13:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724962333; x=1725567133; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6+yYuYet63B5OlRmwoyOPx3h4+yLYBGthBr3VvD5PNs=; b=glFCSqadckUnh+lM2OcU0tec0/OBgivuKAy5URvmIjINz9klwM7Vh6SwRCSIhajpM4 6/9E8gIOJJ34d5OtgPuKi32HEIkQa7rKQR2MFTCt3UVdXl9UjmjxB/TAxOJebFuYv4/q mb4MlxL6tgz4gk4aCaeCToci/xghwYqoGMzcOVV2IIkG5CqsoE8eWoeE9w88KI0XOPht YWWoh3lStgqu6FDy5o9EIiiKanCEUUuNSYbVEEo3cPhEr7N5tEshAS/NDtA0INNZczuS IOAA66q4828HAT/4tcaAl9JLsURRM8lUjF0ZwoUBch6SbxFl3TTrZQYEhyS54JrPdCcv kQ+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724962333; x=1725567133; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6+yYuYet63B5OlRmwoyOPx3h4+yLYBGthBr3VvD5PNs=; b=Zy4lutV0ri688g18ODCbDdc2dER94a8Q4SaCjOq86Q32RaZUbj1WL/+rwF6sL/oOnM DNhndRzUhwPiYLtECxiu4/4uCCN4Ye1Z8JXC0qgQyRPXSv+oQiUwBRdQ+8odYyOOzKoA IwHUtPjHxoAFuL5y6Sz5YsfnfrV7uHWLU9IAr2Iq2RvUcruPw5l0U81SwhjE9gLgnO9f omj9CriGtVPnnJgQMOVLRJMLd8VIdPcqLfBDnVO9JJlJvAxTRknwX72Z94zzcwmE2Zst zLD9eNOtV096bMPbeIVhbGQvsn+V7nUrBjSIJ7TD+KyG3GrDVy5ZSEyPTYR6Kiz/4pvt 2bQw== X-Gm-Message-State: AOJu0YyWcEfFMVGEKfyPKOFecHMQMlacz8JTWFO6W+g97Qx3dO50kw2j nZGypQb6ln45gu8AG+Ayk5UfBBA3bI/DV0oiCBvulnGTO01fRr+6Ea3aVATFMOiA/L8H X-Google-Smtp-Source: AGHT+IHtIj/XplU9XhclSZbDGSwVf2vEl2WyaKMhg3+xc7SCxsOk+w9PjcUAnqEWEr511RXV1xw8ZQ== X-Received: by 2002:a17:902:c94b:b0:202:1176:5e39 with SMTP id d9443c01a7336-2050c4891cdmr35592905ad.56.1724962333090; Thu, 29 Aug 2024 13:12:13 -0700 (PDT) Received: from localhost.localdomain ([2a01:4ff:1f0:1c14::1]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-205152b30fcsm15311515ad.2.2024.08.29.13.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 13:12:12 -0700 (PDT) From: Kele Zhang To: opensbi@lists.infradead.org, wxjstz@126.com, bmeng.cn@gmail.com Cc: tanyuan@tinylab.org, falcon@tinylab.org, Kele Zhang Subject: [PATCH v2 1/1] Makefile: enable --gc-sections Date: Thu, 29 Aug 2024 20:12:10 +0000 Message-Id: <004ed61b6c6743ab87a369bc6202b4b1c50de89d.1724959010.git.zhangcola2003@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240829_131214_332479_292EFC3A X-CRM114-Status: GOOD ( 10.96 ) X-Spam-Score: -1.9 (-) 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.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -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_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 -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.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 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] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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 Signed-off-by: Yuan Tan Signed-off-by: Zhangjin Wu Reviewed-by: Xiang W --- Makefile | 5 +++-- firmware/fw_base.ldS | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e5a0f19..44db5d4 100644 --- a/Makefile +++ b/Makefile @@ -355,9 +355,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 ifneq ($(DEBUG),) -CFLAGS += -O0 +CFLAGS += -O0 -Wl,--print-gc-sections else CFLAGS += -O2 endif @@ -406,6 +406,7 @@ ASFLAGS += $(firmware-asflags-y) ARFLAGS = rcs ELFFLAGS += $(USE_LD_FLAG) +ELFFLAGS += -Wl,--gc-sections ifeq ($(OPENSBI_LD_EXCLUDE_LIBS),y) ELFFLAGS += -Wl,--exclude-libs,ALL 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 = .); }