Skip to content

Commit

Permalink
Use --no-warn-rwx-segments only when needed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
stormc authored and jan-kiszka committed Mar 12, 2024
1 parent c66041f commit b9f2d03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
6 changes: 1 addition & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit b9f2d03

Please sign in to comment.