public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland@arm.com>
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	[thread overview]
Message-ID: <20240729143116.1804615-3-mark.rutland@arm.com> (raw)
In-Reply-To: <20240729143116.1804615-1-mark.rutland@arm.com>

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 <mark.rutland@arm.com>
Cc: Andre Przywara <andre.przywara@arm.com>
Cc: Akos Denke <akos.denke@arm.com>
Cc: Luca Fancellu <luca.fancellu@arm.com>
Cc: Marc Zyngier <maz@kernel.org>
---
 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))
 
-- 
2.30.2



  parent reply	other threads:[~2024-07-29 14:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29 14:31 [BOOT-WRAPPER 0/3] Allow use of bare-metal toolchains Mark Rutland
2024-07-29 14:31 ` [BOOT-WRAPPER 1/3] Makefile: rework test-dtc-option Mark Rutland
2024-07-29 14:31 ` Mark Rutland [this message]
2024-07-29 14:31 ` [BOOT-WRAPPER 3/3] configure: allow the use of bare-metal toolchains Mark Rutland
2024-08-02  9:21 ` [BOOT-WRAPPER 0/3] Allow " Marc Zyngier
2024-08-02 10:10 ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240729143116.1804615-3-mark.rutland@arm.com \
    --to=mark.rutland@arm.com \
    --cc=akos.denke@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=luca.fancellu@arm.com \
    --cc=maz@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox