[PATCH] Kbuild: link barebox with -z noexecstack

Ahmad Fatoum ahmad at a3f.at
Wed Nov 2 05:48:42 PDT 2022


We don't care for permission of ELF segments, but GNU ld (BFD)
does and now with binutils 2.39+, it reports:

  ld: warning: defaultenv/defaultenv-2-menu.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

Instead of touching all assembly objects and scripts creating them to
add the section, just set -z noexecstack at link-time. This is already
the LLVM linker (lld) default.

Reported-by: Christian Melki <christian.melki at t2data.com>
Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 26a0999a2e20..e57b8a4a1364 100644
--- a/Makefile
+++ b/Makefile
@@ -450,7 +450,7 @@ KBUILD_CFLAGS_KERNEL :=
 KBUILD_AFLAGS_MODULE := -DMODULE
 KBUILD_CFLAGS_MODULE := -DMODULE
 
-LDFLAGS_barebox	:= -Map barebox.map
+LDFLAGS_barebox	:= -Map barebox.map -z noexecstack
 
 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
 LDFLAGS_barebox += $(call ld-option, --no-dynamic-linker)
-- 
2.37.2




More information about the barebox mailing list