Skip to contentSkip to conversation

Makefile: Link with -z noexectack

PATCH In review Tom Rini 2 participants 5 messages Feb 14, 2023 – Feb 24, 2023

Subsystems (2)
lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/2 Makefile: Link with -z noexectack

When moving to gcc-12.2 we started trying to quiet some of the new linker warnings, that are not relevant to us. However, a misunderstanding of the mechanics at play meant that I intentionally omitted passing -z noexecstack to the linker, when we do need to. Add this flag and in turn remove warnings from the linker.

Fixes 1e1c51f8ace8 ("Makefile: link with --no-warn-rwx-segments")
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
Makefile +1 -0
index 54f894dab841..bc1ee94fb74e 100644
@@ -806,6 +806,7 @@ KBUILD_CPPFLAGS += $(KCPPFLAGS)
 KBUILD_AFLAGS += $(KAFLAGS)
 KBUILD_CFLAGS += $(KCFLAGS)
 
+KBUILD_LDFLAGS  += -z noexecstack
 KBUILD_LDFLAGS  += $(call ld-option,--no-warn-rwx-segments)
 
 KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/2 x86: Pass -z execstack for EFI payload flags

To match how we link EFI executables elsewhere, and to silence a linker warning, pass -z execstack here as well.

Cc Bin Meng <[email protected]>
Cc Heinrich Schuchardt <[email protected]>
---
 arch/x86/config.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/config.mk +2 -1
index a4a694ddf313..26ec1af2f0b0 100644
@@ -37,7 +37,8 @@ KBUILD_LDFLAGS += -m $(if $(IS_32BIT),elf_i386,elf_x86_64)
 
 # This is used in the top-level Makefile which does not include
 # KBUILD_LDFLAGS
-LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined -s
+LDFLAGS_EFI_PAYLOAD := -Bsymbolic -Bsymbolic-functions -shared --no-undefined \
+		       -s -zexecstack
 
 OBJCOPYFLAGS_EFI := -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
 	-j .rel -j .rela -j .reloc --strip-all
Signature · 1 line
2.34.1
author
#2 lore raw

Re: [PATCH 2/2] x86: Pass -z execstack for EFI payload flags

Quoted 6 lines · Tom Rini

To match how we link EFI executables elsewhere, and to silence a linker warning, pass -z execstack here as well.

Cc Bin Meng <[email protected]>
Cc Heinrich Schuchardt <[email protected]>

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
Reviewed-by on v1 1/2
#3 lore raw
In reply to Tom Rini
Quoted 7 lines · Tom Rini

When moving to gcc-12.2 we started trying to quiet some of the new linker warnings, that are not relevant to us. However, a misunderstanding of the mechanics at play meant that I intentionally omitted passing -z noexecstack to the linker, when we do need to. Add this flag and in turn remove warnings from the linker.

Quoted 6 lines
Fixes 1e1c51f8ace8 ("Makefile: link with --no-warn-rwx-segments")
---
 Makefile | 1 +
 1 file changed, 1 insertion(+)
author
#4 lore raw
In reply to Tom Rini
Quoted 9 lines · Tom Rini

When moving to gcc-12.2 we started trying to quiet some of the new linker warnings, that are not relevant to us. However, a misunderstanding of the mechanics at play meant that I intentionally omitted passing -z noexecstack to the linker, when we do need to. Add this flag and in turn remove warnings from the linker.

Fixes 1e1c51f8ace8 ("Makefile: link with --no-warn-rwx-segments")

Applied to u-boot/master, thanks!

Signature · 1 line
Tom