From 775fdb9f4f954b01876419d0219a8acdfa455fc7 Mon Sep 17 00:00:00 2001 From: Gary Ching-Pang Lin Date: Mon, 9 Nov 2015 09:50:50 -0500 Subject: Cryptlib: Define the va functions for EFIAPI It turned out that my previous crash fix(*) was wrong. We actually always used the gcc built-in va functions instead of the "real" va functions for EFIAPI, and we are just lucky that ERR_add_error_data didn't crash before. This commit copies the va functions from MdePkg/Include/Base.h in edk2 and introdues NO_BUILTIN_VA_FUNCS for x86_64, so that all the x86_64 build will adopt the new va functions. For safety, I also added EFIAPI to all the functions which use va_* to avoid the potential trouble. (*) a7f4b26cc35204165bd04e75c34e8e7aa2a87ecc Signed-off-by: Gary Ching-Pang Lin --- Cryptlib/OpenSSL/Makefile | 3 ++- Cryptlib/OpenSSL/crypto/bio/b_print.c | 8 ++++++++ Cryptlib/OpenSSL/crypto/cryptlib.c | 4 ++++ Cryptlib/OpenSSL/crypto/cryptlib.h | 4 ++++ Cryptlib/OpenSSL/crypto/err/err.c | 4 ---- 5 files changed, 18 insertions(+), 5 deletions(-) (limited to 'Cryptlib/OpenSSL') diff --git a/Cryptlib/OpenSSL/Makefile b/Cryptlib/OpenSSL/Makefile index ab6e7ddf..f8055fd3 100644 --- a/Cryptlib/OpenSSL/Makefile +++ b/Cryptlib/OpenSSL/Makefile @@ -7,7 +7,8 @@ CFLAGS = -ggdb -O0 -I. -I.. -I../Include/ -Icrypto -fno-stack-protector -fno-st ifeq ($(ARCH),x86_64) CFLAGS += -mno-mmx -mno-sse -mno-red-zone -maccumulate-outgoing-args \ - -DEFI_FUNCTION_WRAPPER -DGNU_EFI_USE_MS_ABI -DSIXTY_FOUR_BIT_LONG + -DEFI_FUNCTION_WRAPPER -DGNU_EFI_USE_MS_ABI -DSIXTY_FOUR_BIT_LONG \ + -DNO_BUILTIN_VA_FUNCS endif ifeq ($(ARCH),ia32) CFLAGS += -mno-mmx -mno-sse -mno-red-zone -maccumulate-outgoing-args \ diff --git a/Cryptlib/OpenSSL/crypto/bio/b_print.c b/Cryptlib/OpenSSL/crypto/bio/b_print.c index 9091d56d..4695827e 100644 --- a/Cryptlib/OpenSSL/crypto/bio/b_print.c +++ b/Cryptlib/OpenSSL/crypto/bio/b_print.c @@ -751,7 +751,11 @@ doapr_outch(char **sbuffer, /***************************************************************************/ +#if defined(OPENSSL_SYS_UEFI) +int EFIAPI BIO_printf(BIO *bio, const char *format, ...) +#else int BIO_printf(BIO *bio, const char *format, ...) +#endif { va_list args; int ret; @@ -795,7 +799,11 @@ int BIO_vprintf(BIO *bio, const char *format, va_list args) * closely related to BIO_printf, and we need *some* name prefix ... (XXX the * function should be renamed, but to what?) */ +#if defined(OPENSSL_SYS_UEFI) +int EFIAPI BIO_snprintf(char *buf, size_t n, const char *format, ...) +#else int BIO_snprintf(char *buf, size_t n, const char *format, ...) +#endif { va_list args; int ret; diff --git a/Cryptlib/OpenSSL/crypto/cryptlib.c b/Cryptlib/OpenSSL/crypto/cryptlib.c index ca0e3ccc..0a59342d 100644 --- a/Cryptlib/OpenSSL/crypto/cryptlib.c +++ b/Cryptlib/OpenSSL/crypto/cryptlib.c @@ -962,7 +962,11 @@ void OPENSSL_showfatal(const char *fmta, ...) MessageBox(NULL, buf, _T("OpenSSL: FATAL"), MB_OK | MB_ICONSTOP); } #else +# if defined(OPENSSL_SYS_UEFI) +void EFIAPI OPENSSL_showfatal(const char *fmta, ...) +# else void OPENSSL_showfatal(const char *fmta, ...) +# endif { va_list ap; diff --git a/Cryptlib/OpenSSL/crypto/cryptlib.h b/Cryptlib/OpenSSL/crypto/cryptlib.h index fba180a6..7ca4c99f 100644 --- a/Cryptlib/OpenSSL/crypto/cryptlib.h +++ b/Cryptlib/OpenSSL/crypto/cryptlib.h @@ -100,7 +100,11 @@ extern "C" { void OPENSSL_cpuid_setup(void); extern unsigned int OPENSSL_ia32cap_P[]; +# if defined(OPENSSL_SYS_UEFI) +void EFIAPI OPENSSL_showfatal(const char *fmta, ...); +# else void OPENSSL_showfatal(const char *fmta, ...); +# endif void *OPENSSL_stderr(void); extern int OPENSSL_NONPIC_relocated; diff --git a/Cryptlib/OpenSSL/crypto/err/err.c b/Cryptlib/OpenSSL/crypto/err/err.c index 108b83a9..f98cce6a 100644 --- a/Cryptlib/OpenSSL/crypto/err/err.c +++ b/Cryptlib/OpenSSL/crypto/err/err.c @@ -1085,11 +1085,7 @@ void ERR_add_error_data(int num, ...) va_end(args); } -#if defined(OPENSSL_SYS_UEFI) -void EFIAPI ERR_add_error_vdata(int num, va_list args) -#else void ERR_add_error_vdata(int num, va_list args) -#endif { int i, n, s; char *str, *p, *a; -- cgit v1.2.3