From 82a0fb328e6fd0dbe14223bd290fc88d13fd5a4d Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 13 Aug 2019 06:45:04 -0400 Subject: [PATCH 1/3] src/boot/efi/shim: elide __attribute__((sysv_abi)) on non-intel archs This attribute is x86-only, so when building on non-intel archs it generates a compiler warning. When building with -Werror this turns into an error, so only include the attribute on intel archs. --- src/boot/efi/shim.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/boot/efi/shim.c b/src/boot/efi/shim.c index 9e072d294f9..8db27547cca 100644 --- a/src/boot/efi/shim.c +++ b/src/boot/efi/shim.c @@ -14,14 +14,20 @@ #include "util.h" #include "shim.h" +#if defined(__x86_64__) || defined(__i386__) +#define __sysv_abi__ __attribute__((sysv_abi)) +#else +#define __sysv_abi__ +#endif + struct ShimLock { - EFI_STATUS __attribute__((sysv_abi)) (*shim_verify) (VOID *buffer, UINT32 size); + EFI_STATUS __sysv_abi__ (*shim_verify) (VOID *buffer, UINT32 size); /* context is actually a struct for the PE header, but it isn't needed so void is sufficient just do define the interface * see shim.c/shim.h and PeHeader.h in the github shim repo */ - EFI_STATUS __attribute__((sysv_abi)) (*generate_hash) (VOID *data, UINT32 datasize, VOID *context, UINT8 *sha256hash, UINT8 *sha1hash); + EFI_STATUS __sysv_abi__ (*generate_hash) (VOID *data, UINT32 datasize, VOID *context, UINT8 *sha256hash, UINT8 *sha1hash); - EFI_STATUS __attribute__((sysv_abi)) (*read_header) (VOID *data, UINT32 datasize, VOID *context); + EFI_STATUS __sysv_abi__ (*read_header) (VOID *data, UINT32 datasize, VOID *context); }; static const EFI_GUID simple_fs_guid = SIMPLE_FILE_SYSTEM_PROTOCOL; From 4287d0832c86a0b6a8ca8fe0163518c8d76cd0f1 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Tue, 13 Aug 2019 07:02:33 -0400 Subject: [PATCH 2/3] src/boot/efi/linux: elide __attribute__((regparm(0))) on non-i386 This attribute is x86_32-only, so when building on non-intel archs it generates a compiler warning. When building with -Werror this turns into an error, so only include the attribute on i386 arch builds. --- src/boot/efi/linux.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/boot/efi/linux.c b/src/boot/efi/linux.c index 5b623f4b71e..00a3551e09a 100644 --- a/src/boot/efi/linux.c +++ b/src/boot/efi/linux.c @@ -6,24 +6,24 @@ #include "linux.h" #include "util.h" -#ifdef __x86_64__ -typedef VOID(*handover_f)(VOID *image, EFI_SYSTEM_TABLE *table, struct boot_params *params); -static VOID linux_efi_handover(EFI_HANDLE image, struct boot_params *params) { - handover_f handover; - - asm volatile ("cli"); - handover = (handover_f)((UINTN)params->hdr.code32_start + 512 + params->hdr.handover_offset); - handover(image, ST, params); -} +#ifdef __i386__ +#define __regparm0__ __attribute__((regparm(0))) #else -typedef VOID(*handover_f)(VOID *image, EFI_SYSTEM_TABLE *table, struct boot_params *params) __attribute__((regparm(0))); +#define __regparm0__ +#endif + +typedef VOID(*handover_f)(VOID *image, EFI_SYSTEM_TABLE *table, struct boot_params *params) __regparm0__; static VOID linux_efi_handover(EFI_HANDLE image, struct boot_params *params) { handover_f handover; + UINTN start = (UINTN)params->hdr.code32_start; - handover = (handover_f)((UINTN)params->hdr.code32_start + params->hdr.handover_offset); +#ifdef __x86_64__ + asm volatile ("cli"); + start += 512; +#endif + handover = (handover_f)(start + params->hdr.handover_offset); handover(image, ST, params); } -#endif EFI_STATUS linux_exec(EFI_HANDLE *image, CHAR8 *cmdline, UINTN cmdline_len, From 4d6c1fce0e2002f6a1c7244b03c9a36e3200c0c6 Mon Sep 17 00:00:00 2001 From: Dan Streetman Date: Mon, 12 Aug 2019 20:34:43 -0400 Subject: [PATCH 3/3] src/boot/efi/meson.build: if meson --werror is true, set gcc -Werror This part of the build does not use the normal meson parameters, so we need to explicitly check for the meson --werror parameter, and if it's true, set the gcc -Werror parameter for this subdir's build. --- src/boot/efi/meson.build | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build index dfec97028b4..b8fd5105d04 100644 --- a/src/boot/efi/meson.build +++ b/src/boot/efi/meson.build @@ -135,6 +135,9 @@ if have_gnu_efi compile_args += ['-mno-sse', '-mno-mmx'] endif + if get_option('werror') == true + compile_args += ['-Werror'] + endif efi_ldflags = ['-T', join_paths(efi_ldsdir, arch_lds),