From patchwork Mon Jul 29 14:31:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 13745144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBA59C3DA61 for ; Mon, 29 Jul 2024 14:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6kGh9GoUxNLayUkPZCHukQrE2hG91i9359sBedpe7Hk=; b=EtARInr4CxGf9ukpAyr+f0gsES 7njl2MV4ehUGiZcekH2d26oXl/syVD9EpxmNWMhfgMLfnpRQ+VBmeAlZvZAGvvENxFw99X93/IXm+ 1gGB+COEx49+gLEsG16Ei1Y1w8HwxNsc/eFk7SNgg5eC8QUn27G0HhZoMBAMsmRC84IDi5hz9ngWV 9j1clR6XDwMaJGC8jtjRL/rFrtXFrsllasHrNKO0TCiovRJGBdwANuzpL61K2y5aomHwZNdnYHeia 4x0NPuj73nEMq2PoT701Zl7lVA14/ckDXp+5q0JjXXlJLw0csNPYaBaSFdqlZ0xJVeUhPhJXs7TKK iHRBn2lw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRjJ-0000000BkAX-3QNG; Mon, 29 Jul 2024 14:52:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYRPK-0000000BcCX-2s99 for linux-arm-kernel@lists.infradead.org; Mon, 29 Jul 2024 14:31:28 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0C1D31007; Mon, 29 Jul 2024 07:31:51 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 989173F64C; Mon, 29 Jul 2024 07:31:24 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org Cc: akos.denke@arm.com, andre.przywara@arm.com, luca.fancellu@arm.com, mark.rutland@arm.com, maz@kernel.org Subject: [BOOT-WRAPPER 2/3] Makefile: suppress RWX segment warnings Date: Mon, 29 Jul 2024 15:31:15 +0100 Message-Id: <20240729143116.1804615-3-mark.rutland@arm.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240729143116.1804615-1-mark.rutland@arm.com> References: <20240729143116.1804615-1-mark.rutland@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240729_073126_854732_27A7A847 X-CRM114-Status: UNSURE ( 8.91 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Contemporary versions of GNU LD warn about segments with RWX permissions, which can occur when building the boot-wrapper, e.g. | aarch64-linux-ld: warning: linux-system.axf has a LOAD segment with RWX permissions This is due to sections with RW- and R-X being adjacent, and getting combined into a single segment with RWX permissions: | [mark@lakrids:~/src/boot-wrapper-aarch64]% readelf -l linux-system.axf | | Elf file type is EXEC (Executable file) | Entry point 0x80000000 | There are 4 program headers, starting at offset 64 | | Program Headers: | Type Offset VirtAddr PhysAddr | FileSiz MemSiz Flags Align | LOAD 0x0000000000010000 0x0000000080000000 0x0000000080000000 | 0x0000000000010000 0x0000000000010000 RWE 0x10000 | LOAD 0x0000000000020000 0x0000000080200000 0x0000000080200000 | 0x000000000331b200 0x000000000331b200 RW 0x10000 | LOAD 0x0000000003340000 0x0000000088000000 0x0000000088000000 | 0x0000000000002e05 0x0000000000002e05 RW 0x10000 | GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000 | 0x0000000000000000 0x0000000000000000 RW 0x10 | | Section to Segment mapping: | Segment Sections... | 00 .boot .mbox | 01 .kernel | 02 .dtb | 03 Since the bootwrapper runs with the MMU off, the RWX permissions aren't a problem, and the simplest solution is to suppress the warning with the '--no-warn-rwx-segments' option to LD. Add the necessary logic to suprress the warning when supported by LD. Signed-off-by: Mark Rutland Cc: Andre Przywara Cc: Akos Denke Cc: Luca Fancellu Cc: Marc Zyngier --- Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile.am b/Makefile.am index 6ab5cfd..6ee6afa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,10 @@ define test-dtc-option $(call test-cmd,echo "/dts-v1/;/{};" | $(DTC) $(1) -o /dev/null,$(1),) endef +define test-ld-option +$(call test-cmd,$(LD) $(1) --help,$(1),) +endef + # VE PHYS_OFFSET := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findmem.pl $(KERNEL_DTB)) UART_BASE := $(shell perl -I $(SCRIPT_DIR) $(SCRIPT_DIR)/findbase.pl $(KERNEL_DTB) 0 'arm,pl011') @@ -141,6 +145,7 @@ CFLAGS += -fno-stack-protector CFLAGS += -ffunction-sections -fdata-sections CFLAGS += -fno-pic -fno-pie LDFLAGS += --gc-sections +LDFLAGS += $(call test-ld-option,--no-warn-rwx-segments) OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ))