[PATCH 2/2] Kbuild: link with -z noexecstack and --no-warn-rwx-segments

Sascha Hauer s.hauer at pengutronix.de
Tue Nov 8 02:49:27 PST 2022


Users of GNU ld (BFD) from binutils 2.39+ will observe multiple
instances of a new warning when linking barebox and PBL in the form:

ld: warning: defaultenv/defaultenv-2-dfu.bbenv.o: missing .note.GNU-stack section implies executable stack
ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
ld: warning: .tmp_barebox1 has a LOAD segment with RWX permissions

We don't need executable stack, so disable with -z noexecstack. We also
do not use the permissions from ELF segments, so disable the warning
with --no-warn-rwx-segments.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 Makefile | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Makefile b/Makefile
index 12882ef4cf..de0329c761 100644
--- a/Makefile
+++ b/Makefile
@@ -454,6 +454,10 @@ LDFLAGS_barebox	:= -Map barebox.map
 
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
 LDFLAGS_common += $(call ld-option, --no-dynamic-linker)
+# Avoid 'missing .note.GNU-stack section implies executable stack' warnings on binutils 2.39+
+LDFLAGS_common += -z noexecstack
+# Avoid '... has a LOAD segment with RWX permissions' warnings on binutils 2.39+
+LDFLAGS_common += $(call ld-option,--no-warn-rwx-segments)
 
 LDFLAGS_barebox += $(LDFLAGS_common)
 LDFLAGS_pbl += $(LDFLAGS_common)
-- 
2.30.2




More information about the barebox mailing list