Makefile: link with --no-warn-rwx-segments

We borrow from the Linux Kernel 0d362be5b142 ("Makefile: link with -z
noexecstack --no-warn-rwx-segments") here to disable the RWX segment
linking warnings. We do not also bring in -z noexecstack as that
requires auditing and using ".note.GNU-stack" on assembly functions
which do need this feature. Further, we now introduce KBUILD_EFILDFLAGS
so that we can also pass --no-warn-rwx-segments when linking EFI
applications, and those do explicitly pass -z execstack.

Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
This commit is contained in:
Tom Rini 2022-12-07 15:49:43 -05:00
parent 259420703b
commit 1e1c51f8ac
2 changed files with 6 additions and 2 deletions

View File

@ -806,6 +806,8 @@ KBUILD_CPPFLAGS += $(KCPPFLAGS)
KBUILD_AFLAGS += $(KAFLAGS) KBUILD_AFLAGS += $(KAFLAGS)
KBUILD_CFLAGS += $(KCFLAGS) KBUILD_CFLAGS += $(KCFLAGS)
KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments)
KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g) KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
# Use UBOOTINCLUDE when you must reference the include/ directory. # Use UBOOTINCLUDE when you must reference the include/ directory.

View File

@ -425,9 +425,11 @@ cmd_efi_objcopy = $(OBJCOPY) -j .header -j .text -j .sdata -j .data -j \
$(obj)/%.efi: $(obj)/%_efi.so $(obj)/%.efi: $(obj)/%_efi.so
$(call cmd,efi_objcopy) $(call cmd,efi_objcopy)
KBUILD_EFILDFLAGS = -nostdlib -zexecstack -znocombreloc -znorelro
KBUILD_EFILDFLAGS += $(call ld-option,--no-warn-rwx-segments)
quiet_cmd_efi_ld = LD $@ quiet_cmd_efi_ld = LD $@
cmd_efi_ld = $(LD) -nostdlib -zexecstack -znocombreloc -T $(EFI_LDS_PATH) \ cmd_efi_ld = $(LD) $(KBUILD_EFILDFLAGS) -T $(EFI_LDS_PATH) \
-shared -Bsymbolic -znorelro -s $^ -o $@ -shared -Bsymbolic -s $^ -o $@
EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS) EFI_LDS_PATH = $(srctree)/arch/$(ARCH)/lib/$(EFI_LDS)