diff options
authorMatt Fleming <matt.fleming@intel.com>2013-03-22 13:33:51 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-03-22 13:57:54 +0000
commitbbc178dc9f7431779a8a4572a24e3c3aaf870d07 (patch)
parent37d43cf9dd5dd2d2cef1e86aa651097473fd0b48 (diff)
efi: Fix build with gnu-efi >= 3.0s
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@zytor.com> Cc: Nigel Croxon <nigel.croxon@hp.com> Cc: Peter Jones <pjones@redhat.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
2 files changed, 16 insertions, 3 deletions
diff --git a/efi/efi.h b/efi/efi.h
index 6472d6ab..c5bd7771 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
#include <efi.h>
#include <efilib.h>
#include <efistdarg.h>
diff --git a/efi/vesa.c b/efi/vesa.c
index e3e9e0f7..d259f60a 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