grub-core/lib/gnulib/argp.h:529:6: error: ‘_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM’ is an unrecognized format function type [-Werror=format=]
Dear GRUB folks, On Debian sid/unstable with *gcc-12* 12.3.0-7, *gcc-13* 13.2.0-1, and *clang* 1:14.0-55.7, since commit 2b7902459803 (gnulib: Update gnulib version and drop most gnulib patches), I am unable to build GRUB for the platform *coreboot* [1]: ``` $ git clean -dfx && ./configure --with-platform=coreboot && make -j4 default_payload.elf […] *** GRUB2 will be compiled with following components: Platform: i386-coreboot With devmapper support: No (need libdevmapper header) With memory debugging: No With disk cache statistics: No With boot time statistics: No efiemu runtime: Yes grub-mkfont: Yes grub-mount: No (need fuse or fuse3 libraries) starfield theme: No (No DejaVu found) With libzfs support: No (need zfs library) Build-time grub-mkfont: Yes With unifont from /usr/share/fonts/X11/misc/unifont.pcf.gz With liblzma from -llzma (support for XZ-compressed mips images) With stack smashing protector: No *** real0m23,192s user0m15,074s sys 0m6,481s gcc -DHAVE_CONFIG_H -I. -Wall -W -DGRUB_UTIL=1 -D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"util/grub-mkstandalone.c\" -I. -I. -I. -I. -I./include -I./include -I./grub-core/lib/libgcrypt-grub/src/ -I./grub-core/lib/gnulib -I./grub-core/lib/gnulib -D_FILE_OFFSET_BITS=64 -std=gnu99 -fno-common -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label -Wunused-parameter -Wunused-value -Wunused-variable -Wwrite-strings -Wnested-externs -Wstrict-prototypes -Wcast-align -Wextra -Wattributes -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -MT util/grub_mkstandalone-grub-mkstandalone.o -MD -MP -MF util/.deps-util/grub_mkstandalone-grub-mkstandalone.Tpo -c -o util/grub_mkstandalone-grub-mkstandalone.o `test -f 'util/grub-mkstandalone.c' || echo './'`util/grub-mkstandalone.c In file included from util/grub-mkstandalone.c:29: ./grub-core/lib/gnulib/argp.h:529:6: error: ‘_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM’ is an unrecognized format function type [-Werror=format=] 529 | ; | ^ ./grub-core/lib/gnulib/argp.h:537:6: error: ‘_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM’ is an unrecognized format function type [-Werror=format=] 537 | ; | ^ ./grub-core/lib/gnulib/argp.h:555:6: error: ‘_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM’ is an unrecognized format function type [-Werror=format=] 555 | ; | ^ ./grub-core/lib/gnulib/argp.h:564:6: error: ‘_GL_ATTRIBUTE_SPEC_PRINTF_SYSTEM’ is an unrecognized format function type [-Werror=format=] 564 | ; | ^ cc1: all warnings being treated as errors make: *** [Makefile:10872: util/grub_mkstandalone-grub-mkstandalone.o] Fehler 1 ``` Building the default platform first git clean -dfx && ./bootstrap && ./configure && make then the build for the platform *coreboot* succeeds: make clean && ./configure --with-platform=coreboot && make Kind regards, Paul ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel
[PATCH] loader/efi/linux: Implement x86 mixed mode using legacy boot
Recent mixed-mode Linux kernels (i.e., v4.0 or newer) can access EFI runtime services at OS runtime even when the OS was not entered via the EFI stub. This is because, instead of reverting back to the firmware's segment selectors, GDTs and IDTs, the 64-bit kernel simply calls 32-bit runtime services using compatilibity mode (i.e., the same mode used for 32-bit user space) without taking down all interrupt handling, exception handling etc. This means that GRUB's legacy x86 boot mode is sufficient to make use of this: 32-bit i686 builds of GRUB can already boot 64-bit kernels in EFI enlightened mode (but without going via the EFI stub), and provide all the metadata that the OS needs to map the EFI runtime regions and call EFI runtime services successfully. It does mean that GRUB should not attempt to invoke the firmware's LoadImage/StartImage methods on kernel builds that it knows cannot be started natively. So add a check for this in the native EFI boot path, and fall back to legacy x86 mode in such cases. Note that in the general case, booting non-native images of the same native word size (e.g., X64 EFI apps on arm64 firmware) might be supported by means of emulation, so let's only disallow images that use a non-native word size. This will also permit booting i686 kernels on x86_64 builds, although without access to runtime services, as this is not supported by Linux. This change on top of 2.12-rc1 is sufficient to boot ordinary Linux mixed mode builds and get full access to the EFI runtime services. Cc: Daniel Kiper Cc: Steve McIntyre Cc: Julian Andres Klode Signed-off-by: Ard Biesheuvel --- grub-core/loader/efi/linux.c | 5 + include/grub/efi/pe32.h | 6 ++ 2 files changed, 11 insertions(+) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index ed325f2b0aae2d6f..1d0734e295043df7 100644 --- a/grub-core/loader/efi/linux.c +++ b/grub-core/loader/efi/linux.c @@ -120,6 +120,11 @@ grub_arch_efi_linux_load_image_header (grub_file_t file, return grub_error (GRUB_ERR_FILE_READ_ERROR, "failed to read COFF image header"); } + if (lh->pe_image_header.optional_header.magic != GRUB_PE32_NATIVE_MAGIC) +{ + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "non-native image not supported"); +} + /* * Linux kernels built for any architecture are guaranteed to support the * LoadFile2 based initrd loading protocol if the image version is >= 1. diff --git a/include/grub/efi/pe32.h b/include/grub/efi/pe32.h index 101859af1ea64237..4e6e9d254bd35c9b 100644 --- a/include/grub/efi/pe32.h +++ b/include/grub/efi/pe32.h @@ -267,6 +267,12 @@ struct grub_pe32_section_table #define GRUB_PE32_SIGNATURE_SIZE 4 +#if GRUB_TARGET_SIZEOF_VOID_P == 8 +#define GRUB_PE32_NATIVE_MAGIC GRUB_PE32_PE64_MAGIC +#else +#define GRUB_PE32_NATIVE_MAGIC GRUB_PE32_PE32_MAGIC +#endif + struct grub_pe_image_header { /* This is always PE\0\0. */ -- 2.39.2 ___ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel