[syslinux:firmware] efi: Fix build with gnu-efi >= 3.0s

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu May 9 03:39:08 PDT 2013


Commit-ID:  bbc178dc9f7431779a8a4572a24e3c3aaf870d07
Gitweb:     http://www.syslinux.org/commit/bbc178dc9f7431779a8a4572a24e3c3aaf870d07
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Fri, 22 Mar 2013 13:33:51 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Fri, 22 Mar 2013 13:57:54 +0000

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 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>

---
 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 e3e9e0f..d259f60 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
  */


More information about the Syslinux-commits mailing list