From: David Woodhouse <david.woodho...@intel.com>

Instead of patching OpenSSL to add EFIAPI to the one varargs function we
actually *noticed* breakage in, let's fix the problem in a more coherent
way by undefining NO_BUILTIN_VA_FUNCS.

That way, the VA_START and similar macros will actually do the right
thing for non-EFIAPI functions, which is to use the GCC builtins.

It's still fairly broken elsewhere in the tree, with the VA_START macro
being used from both EFIAPI and non-EFIAPI functions — and being broken
in the latter case. We probably ought to make EFIAPI a no-op everywhere
and add -mabi=ms to the GCC builds. But that's a project for another day.
For now, just fix the OpenSSL build in a cleaner fashion.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: David Woodhouse <david.woodho...@intel.com>
Tested-by: Laszlo Ersek <ler...@redhat.com>
Reviewed-by: Laszlo Ersek <ler...@redhat.com>
Reviewed-by: Qin Long <qin.l...@intel.com>
---
 .../Library/OpensslLib/EDKII_openssl-1.0.2d.patch  | 34 ----------------------
 CryptoPkg/Library/OpensslLib/OpensslLib.inf        |  2 +-
 2 files changed, 1 insertion(+), 35 deletions(-)

diff --git a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2d.patch 
b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2d.patch
index a89565c..9fb5516 100644
--- a/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2d.patch
+++ b/CryptoPkg/Library/OpensslLib/EDKII_openssl-1.0.2d.patch
@@ -357,37 +357,3 @@ diff U3 crypto/opensslconf.h crypto/opensslconf.h
  #endif
  
  #if defined(HEADER_RC4_LOCL_H) && !defined(CONFIG_HEADER_RC4_LOCL_H)
-diff U3 crypto/err/err.c crypto/err/err.c
---- crypto/err/err.c
-+++ crypto/err/err.c
-@@ -1072,7 +1072,12 @@ void ERR_set_error_data(char *data, int flags)
-     es->err_data_flags[i] = flags;
- }
- 
-+/* Add EFIAPI for UEFI version. */
-+#if defined(OPENSSL_SYS_UEFI)
-+void EFIAPI ERR_add_error_data(int num, ...)
-+#else
- void ERR_add_error_data(int num, ...)
-+#endif
- {
-     va_list args;
-     va_start(args, num);
-diff U3 crypto/err/err.h crypto/err/err.h
---- crypto/err/err.h
-+++ crypto/err/err.h
-@@ -344,7 +344,14 @@ void ERR_print_errors_fp(FILE *fp);
- # ifndef OPENSSL_NO_BIO
- void ERR_print_errors(BIO *bp);
- # endif
-+
-+/* Add EFIAPI for UEFI version. */
-+#if defined(OPENSSL_SYS_UEFI)
-+void EFIAPI ERR_add_error_data(int num, ...);
-+#else
- void ERR_add_error_data(int num, ...);
-+#endif
-+
- void ERR_add_error_vdata(int num, va_list args);
- void ERR_load_strings(int lib, ERR_STRING_DATA str[]);
- void ERR_unload_strings(int lib, ERR_STRING_DATA str[]);
diff --git a/CryptoPkg/Library/OpensslLib/OpensslLib.inf 
b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
index 28d3aec..fb63f92 100644
--- a/CryptoPkg/Library/OpensslLib/OpensslLib.inf
+++ b/CryptoPkg/Library/OpensslLib/OpensslLib.inf
@@ -901,7 +901,7 @@
   INTEL:*_*_IPF_CC_FLAGS    = -U_WIN32 -U_WIN64 -U_MSC_VER -U__ICC 
$(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) /w -DSIXTY_FOUR_BIT
 
   GCC:*_*_IA32_CC_FLAGS     = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
$(OPENSSL_EXFLAGS) -w -DTHIRTY_TWO_BIT
-  GCC:*_*_X64_CC_FLAGS      = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
$(OPENSSL_EXFLAGS) -w -DSIXTY_FOUR_BIT_LONG
+  GCC:*_*_X64_CC_FLAGS      = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
$(OPENSSL_EXFLAGS) -w -DSIXTY_FOUR_BIT_LONG -UNO_BUILTIN_VA_FLAGS
   GCC:*_*_IPF_CC_FLAGS      = -U_WIN32 -U_WIN64 $(OPENSSL_FLAGS) 
$(OPENSSL_EXFLAGS) -w -DSIXTY_FOUR_BIT_LONG
   GCC:*_*_ARM_CC_FLAGS      = $(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) -w 
-DTHIRTY_TWO_BIT
   GCC:*_*_AARCH64_CC_FLAGS  = $(OPENSSL_FLAGS) $(OPENSSL_EXFLAGS) -w 
-DSIXTY_FOUR_BIT_LONG
-- 
2.4.3

-- 
David Woodhouse                            Open Source Technology Centre
david.woodho...@intel.com                              Intel Corporation

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to