From: Christian Storm <christian.st...@siemens.com>

GNU binutils 2.39 introduced a warning for LOAD segments with RWX
permissions. Due to the default Werror, the build fails for non-
x86 machines when using binutils >= 2.39 and gnu-efi <= 3.0.15.
x86 machines didn't have a faulty linker script in the first place.

The gnu-efi commits 98f1250 and 231c763 fix the need for having
--no-warn-rwx-segments on riscv and arm, respectively, and are
included in gnu-efi 3.0.16

Do only apply the linker flag --no-warn-rwx-segments for non-x86
and gnu-efi < 3.0.16 if that flag is supported (binutils >= 2.39).

Signed-off-by: Christian Storm <christian.st...@siemens.com>
---
 Makefile.am  |  6 +-----
 configure.ac | 13 ++++++++-----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index e19d0c3..9bff305 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -239,14 +239,10 @@ efi_ldflags = \
        --warn-common \
        --no-undefined \
        --fatal-warnings \
+       $(LDFLAGS_NO_WARN_RWX_SEGMENTS) \
        -L $(GNUEFI_LIB_DIR) \
        $(GNUEFI_LIB_DIR)/crt0-efi-$(ARCH).o
 
-if !ARCH_IS_X86
-# Suppress RWX segment warnings.
-efi_ldflags += $(LDFLAGS_NO_WARN_RWX_SEGMENTS)
-endif
-
 if ARCH_IS_X86
 objcopy_format = --target=efi-app-$(ARCH)
 else
diff --git a/configure.ac b/configure.ac
index e533fe4..099daed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -119,11 +119,6 @@ AX_CHECK_COMPILE_FLAG([-mgeneral-regs-only],
        [CFLAGS_MGENERAL_REGS_ONLY=])
 AC_SUBST([CFLAGS_MGENERAL_REGS_ONLY])
 
-AX_CHECK_LINK_FLAG([-Wl,--no-warn-rwx-segments],
-       [LDFLAGS_NO_WARN_RWX_SEGMENTS=--no-warn-rwx-segments],
-       [LDFLAGS_NO_WARN_RWX_SEGMENTS=])
-AC_SUBST([LDFLAGS_NO_WARN_RWX_SEGMENTS])
-
 # Checks from autoscan:
 AC_CHECK_FUNCS([getmntent])
 AC_CHECK_FUNCS([memset])
@@ -235,6 +230,14 @@ fi
 AM_CONDITIONAL([OBJCOPY_USE_EFI_APP_TARGET],
               [test -n $OBJCOPY_HAS_EFI_APP_TARGET && test $GNU_EFI_VERSION 
-gt 0])
 
+# Use --no-warn-rwx-segments for gnu-efi version 3.0.15
+# on non-x86 architectures.
+AS_IF([test -z "$ARCH_IS_X86_FALSE" -a $GNU_EFI_VERSION -eq 0],
+       [AX_CHECK_LINK_FLAG([-Wl,--no-warn-rwx-segments],
+               [LDFLAGS_NO_WARN_RWX_SEGMENTS=--no-warn-rwx-segments],
+               [LDFLAGS_NO_WARN_RWX_SEGMENTS=])
+        AC_SUBST([LDFLAGS_NO_WARN_RWX_SEGMENTS])])
+
 AS_IF([test "x$enable_bootloader" != "xno"],
     [
        PKG_CHECK_MODULES(LIBPCI, libpci)
-- 
2.44.0

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to efibootguard-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/ACB457DF-00E7-40FE-BFF0-9C33BD09CA02%40siemens.com.

Reply via email to