[BOOT-WRAPPER 2/3] Makefile: suppress RWX segment warnings
Mark Rutland
mark.rutland at arm.com
Mon Jul 29 07:31:15 PDT 2024
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 at 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 at arm.com>
Cc: Andre Przywara <andre.przywara at arm.com>
Cc: Akos Denke <akos.denke at arm.com>
Cc: Luca Fancellu <luca.fancellu at arm.com>
Cc: Marc Zyngier <maz at 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
More information about the linux-arm-kernel
mailing list