Matt Fleming
2013-Jan-08 11:51 UTC
[syslinux] [PATCH][firmware] efi: Fix build with gnu-efi >= 3.0s
From: Matt Fleming <matt.fleming at intel.com> For x86_64 versions of gnu-efi >= 3.0s GNU_EFI_USE_MS_ABI is enabled which turns on the Microsoft ABI, allowing the compiler to do all the work of interfacing with the EFI firmware instead of jumping through uefi_call_wrapper(). Add support to turn this on in the gnu-efi headers, otherwise we'll encounter undefined references to uefi_call_wrapper(). This addresses the simplest case assuming a distribution's gnu-efi was compiled with GNU_EFI_USE_MS_ABI. If you're compiling everything from source and you turn off GNU_EFI_USE_MS_ABI for gnu-efi, you'll also need to turn it off here. Cc: H. Peter Anvin <hpa at zytor.com> Cc: Nigel Croxon <nigel.croxon at hp.com> Cc: Peter Jones <pjones at redhat.com> Signed-off-by: Matt Fleming <matt.fleming at intel.com> --- Folks, is this the correct way to fix this build breakage? I can certainly conceive of ways that this will break if distros start turning off GNU_EFI_USE_MS_ABI even though it's supported by the compiler, but I dunno if it's just a case of "Don't do that then". Thoughts? efi/efi.h | 15 +++++++++++++++ efi/vesa.c | 4 +--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/efi/efi.h b/efi/efi.h index 6472d6a..c5bd777 100644 --- a/efi/efi.h +++ b/efi/efi.h @@ -4,6 +4,21 @@ #include <core.h> #include <sys/types.h> /* needed for off_t */ //#include <syslinux/version.h> /* avoid redefinition of __STDC_VERSION__ */ + +/* + * gnu-efi >= 3.0s enables GNU_EFI_USE_MS_ABI by default, which means + * that we must also enable it if supported by the compiler. Note that + * failing to enable GNU_EFI_USE_MS_ABI if gnu-efi was compiled with + * it on will result in undefined references to uefi_call_wrapper(). + * + * The reason we don't attempt to check the version of gnu-efi we're + * building against is because there's no harm in turning it on for + * older versions - it will just be ignored. + */ +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) + #define GNU_EFI_USE_MS_ABI 1 +#endif + #include <efi.h> #include <efilib.h> #include <efistdarg.h> diff --git a/efi/vesa.c b/efi/vesa.c index 473d3a5..38f8213 100644 --- a/efi/vesa.c +++ b/efi/vesa.c @@ -33,9 +33,7 @@ #include <sys/fpu.h> #include <syslinux/video.h> #include <dprintf.h> -#include <efi.h> -#include <efilib.h> -#include <efistdarg.h> +#include "efi.h" /* We use cp865_8x16.psf as the standard font for EFI implementation * the header file below contains raw data parsed from cp865_8x16.psf */ -- 1.7.11.7
Nigel Croxon
2013-Jan-30 20:18 UTC
[syslinux] [PATCH][firmware] efi: Fix build with gnu-efi >= 3.0s
Hi Matt, Sorry for the delay in answering this patch. The patch does not apply. The efi/efi.h file I have does not match the patch. Your second file efi/vesa.c does exist in my source code. -Nigel On 01/08/2013 06:51 AM, Matt Fleming wrote:> From: Matt Fleming <matt.fleming at intel.com> > > For x86_64 versions of gnu-efi >= 3.0s GNU_EFI_USE_MS_ABI is enabled > which turns on the Microsoft ABI, allowing the compiler to do all the > work of interfacing with the EFI firmware instead of jumping through > uefi_call_wrapper(). > > Add support to turn this on in the gnu-efi headers, otherwise we'll > encounter undefined references to uefi_call_wrapper(). > > This addresses the simplest case assuming a distribution's gnu-efi was > compiled with GNU_EFI_USE_MS_ABI. If you're compiling everything from > source and you turn off GNU_EFI_USE_MS_ABI for gnu-efi, you'll also > need to turn it off here. > > Cc: H. Peter Anvin <hpa at zytor.com> > Cc: Nigel Croxon <nigel.croxon at hp.com> > Cc: Peter Jones <pjones at redhat.com> > Signed-off-by: Matt Fleming <matt.fleming at intel.com> > --- > > Folks, is this the correct way to fix this build breakage? I can > certainly conceive of ways that this will break if distros start > turning off GNU_EFI_USE_MS_ABI even though it's supported by the > compiler, but I dunno if it's just a case of "Don't do that then". > > Thoughts? > > efi/efi.h | 15 +++++++++++++++ > efi/vesa.c | 4 +--- > 2 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/efi/efi.h b/efi/efi.h > index 6472d6a..c5bd777 100644 > --- a/efi/efi.h > +++ b/efi/efi.h > @@ -4,6 +4,21 @@ > #include <core.h> > #include <sys/types.h> /* needed for off_t */ > //#include <syslinux/version.h> /* avoid redefinition of __STDC_VERSION__ */ > + > +/* > + * gnu-efi >= 3.0s enables GNU_EFI_USE_MS_ABI by default, which means > + * that we must also enable it if supported by the compiler. Note that > + * failing to enable GNU_EFI_USE_MS_ABI if gnu-efi was compiled with > + * it on will result in undefined references to uefi_call_wrapper(). > + * > + * The reason we don't attempt to check the version of gnu-efi we're > + * building against is because there's no harm in turning it on for > + * older versions - it will just be ignored. > + */ > +#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) > + #define GNU_EFI_USE_MS_ABI 1 > +#endif > + > #include <efi.h> > #include <efilib.h> > #include <efistdarg.h> > diff --git a/efi/vesa.c b/efi/vesa.c > index 473d3a5..38f8213 100644 > --- a/efi/vesa.c > +++ b/efi/vesa.c > @@ -33,9 +33,7 @@ > #include <sys/fpu.h> > #include <syslinux/video.h> > #include <dprintf.h> > -#include <efi.h> > -#include <efilib.h> > -#include <efistdarg.h> > +#include "efi.h" > /* We use cp865_8x16.psf as the standard font for EFI implementation > * the header file below contains raw data parsed from cp865_8x16.psf > */ >