On 09.03.24 09:00, 'Jan Kiszka' via EFI Boot Guard wrote:
> On 07.03.24 12:09, 'Storm, Christian' via EFI Boot Guard wrote:
>> From: Christian Storm <christian.st...@siemens.com>
>>
>> With gnu-efi >= 3.0.16, the binary format assemblage for
>> arm doesn't work anymore due to lds and crt0 changes.
>>
>> Hence, with gnu-efi >= 3.0.16 and binutils >= 2.38, use the
>> efi-app-${ARCH} target. For gnu-efi == 3.0.15, use the binary
>> assemblage, not needing binutils efi-app target support.
>>
>> Signed-off-by: Christian Storm <christian.st...@siemens.com>
>> ---
>>  Makefile.am  | 17 +++++++++++------
>>  configure.ac | 18 ++++++++++++++++++
>>  2 files changed, 29 insertions(+), 6 deletions(-)
>>
>> diff --git a/Makefile.am b/Makefile.am
>> index 47dfbe5..2e802c3 100644
>> --- a/Makefile.am
>> +++ b/Makefile.am
>> @@ -242,15 +242,20 @@ efi_ldflags = \
>>      -L $(GNUEFI_LIB_DIR) \
>>      $(GNUEFI_LIB_DIR)/crt0-efi-$(ARCH).o
>>  
>> -if ARCH_IS_X86
>> +if !ARCH_IS_X86
>> +# Suppress RWX segment warnings.
>> +efi_ldflags += $(LDFLAGS_NO_WARN_RWX_SEGMENTS)
>> +endif
>> +
>> +if ARCH_IS_ARM
>> +if AARCH64_EFI_APP
>>  objcopy_format = --target=efi-app-$(ARCH)
>>  else
>> -# aarch64's and arm's objcopy don't understand --target 
>> efi-[app|bsdrv|rtdrv],
>> -# hence set subsystem 0xa (EFI application) and binary format.
>>  objcopy_format = -O binary
>>  efi_ldflags += --defsym=EFI_SUBSYSTEM=0xa
>> -# Also suppress RWX segment warnings until we have a better solution
>> -efi_ldflags += $(LDFLAGS_NO_WARN_RWX_SEGMENTS)
>> +endif
>> +else
>> +objcopy_format = --target=efi-app-$(ARCH)
>>  endif
>>  
>>  efi_objects_pre1 = $(efi_sources:.c=.o)
>> @@ -300,7 +305,7 @@ $(efi_solib): $(efi_objects)
>>  
>>  $(efi_loadername): $(efi_solib)
>>      $(AM_V_GEN) $(OBJCOPY) -j .text -j .wdfuncs -j .sdata -j .data -j 
>> .dynamic \
>> -      -j .dynsym -j .rel*  $(objcopy_format) $< $@
>> +      -j .dynsym -j .rodata -j .rel*  $(objcopy_format) $< $@
>>  
>>  $(kernel_stub_solib): $(kernel_stub_objects)
>>      $(AM_V_CCLD)$(LD) $(efi_ldflags) $(kernel_stub_objects) \
>> diff --git a/configure.ac b/configure.ac
>> index eadccd6..2e691c0 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -39,6 +39,7 @@ AC_SYS_LARGEFILE
>>  AC_PROG_CC
>>  AC_CHECK_TOOL(LD, ld)
>>  AC_CHECK_TOOL(OBJCOPY, objcopy)
>> +AC_CHECK_TOOL(GREP, grep)
>>  
>>  dnl Dont try to use things like -std=c99 for efi compilation
>>  GNUEFI_CC=$CC
>> @@ -110,6 +111,7 @@ AM_COND_IF(ARCH_RISCV64, [
>>  AC_SUBST([ARCH])
>>  AC_SUBST([MACHINE_TYPE_NAME])
>>  AM_CONDITIONAL([ARCH_IS_X86], [test "$ARCH" = "ia32" -o "$ARCH" = "x86_64"])
>> +AM_CONDITIONAL([ARCH_IS_ARM], [test "$ARCH" = "arm" -o "$ARCH" = "aarch64"])
>>  
>>  # -mgeneral-regs-only was introduced with gcc-9 to ARM, and RISCV64 does 
>> not support it until now
>>  AX_CHECK_COMPILE_FLAG([-mgeneral-regs-only],
>> @@ -221,6 +223,22 @@ if test "x$PKG_CONFIG" = "xno"; then
>>      AC_MSG_ERROR([You need to install pkg-config])
>>  fi
>>  
>> +# gnu-efi introduced pkg-config with version 3.0.16
>> +# Note: If found, GNUEFI_CFLAGS and GNUEFI_LIBS are
>> +# set which may eventually be used to supersede the
>> +# above manual gnu-efi configuration.
>> +PKG_CHECK_MODULES(GNUEFI, [gnu-efi >= 3.0.16],
>> +              [gnu_efi_has_pkgconfig="yes"],
>> +              [gnu_efi_has_pkgconfig="no"])
>> +
>> +# Note: As of gnu-efi 3.0.16 basing on binutils >= 2.38
>> +# supporting the efi-app-aarch64 target, the objcopy
>> +# binary format assemblage doesn't work anymore due to
>> +# lds and crt0 changes. However, not so with gnu-efi
>> +# 3.0.15 shipped by Debian, hence this conditional.
>> +AM_CONDITIONAL([AARCH64_EFI_APP],
>> +           [$OBJCOPY --info | $GREP -q pei- && test 
>> "x$gnu_efi_has_pkgconfig" = "xyes"])
>> +
>>  AS_IF([test "x$enable_bootloader" != "xno"],
>>      [
>>      PKG_CHECK_MODULES(LIBPCI, libpci)
> 
> Thanks, applied.
> 

Breaks riscv64:
https://github.com/siemens/efibootguard/actions/runs/8213164991/job/22464232480

Jan

-- 
Siemens AG, Technology
Linux Expert Center

-- 
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/59abfdf7-ba41-4b7e-b88a-f1e3598b699d%40siemens.com.

Reply via email to