From de37652044d51a73e8c65353e8b74a3544c54183 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Fri, 19 May 2017 12:21:18 +0100 Subject: [PATCH] [efi] Prevent EFI code from being linked in to non-EFI builds Ensure that efi_systab is an undefined symbol in non-EFI builds. In particular, this prevents users from incorrectly enabling IMAGE_EFI in a BIOS build of iPXE. Signed-off-by: Michael Brown --- src/interface/efi/efi_init.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/interface/efi/efi_init.c b/src/interface/efi/efi_init.c index cfaff606..ed9707f2 100644 --- a/src/interface/efi/efi_init.c +++ b/src/interface/efi/efi_init.c @@ -32,8 +32,14 @@ EFI_HANDLE efi_image_handle; /** Loaded image protocol for this image */ EFI_LOADED_IMAGE_PROTOCOL *efi_loaded_image; -/** System table passed to entry point */ -EFI_SYSTEM_TABLE *efi_systab; +/** System table passed to entry point + * + * We construct the symbol name efi_systab via the PLATFORM macro. + * This ensures that the symbol is defined only in EFI builds, and so + * prevents EFI code from being incorrectly linked in to a non-EFI + * build. + */ +EFI_SYSTEM_TABLE * _C2 ( PLATFORM, _systab ); /** EFI shutdown is in progress */ int efi_shutdown_in_progress;