Implemented workaround for QuicTLS "undefined reference to `gcm_gmult_4bit_*" bug on x86 platform.

This commit is contained in:
LoRd_MuldeR 2025-04-06 14:47:50 +02:00
parent ffb35212ba
commit 1191874c5e
2 changed files with 31 additions and 2 deletions

View File

@ -57,7 +57,7 @@ fi
case "${CC_TARGET}" in
i686-*)
readonly MY_CPU=x86
readonly MY_MARCH=pentium-mmx
readonly MY_MARCH=i586
readonly MY_MTUNE=generic
;;
x86_64-*)
@ -194,7 +194,7 @@ CFLAGS="-march=${MY_MARCH} -mtune=${MY_MTUNE} -DNDEBUG -D_WIN32_WINNT=0x0501 -I$
popd
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# OpenSSL
# OpenSSL / QuicTLS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
printf "\n==================== OpenSSL ====================\n\n"
readonly OSSL_DIR="${WORK_DIR}/openssl"
@ -203,6 +203,7 @@ tar -xvf "${PKGS_DIR}/openssl.tar.gz" --strip-components=1 -C "${OSSL_DIR}"
[[ "${MY_CPU}" == "x64" ]] && readonly ossl_flag="no-sse2" || readonly ossl_flag="386"
[[ "${MY_CPU}" == "x64" ]] && readonly ossl_mngw="mingw64" || readonly ossl_mngw="mingw"
pushd "${OSSL_DIR}"
patch -p1 -b < "${BASE_DIR}/patch/quictls_x86_fix.diff"
./Configure no-hw no-shared no-engine no-capieng no-dso zlib ${ossl_flag} -static -march=${MY_MARCH} -mtune=${MY_MTUNE} -DNDEBUG -D_WIN32_WINNT=0x0501 -I"${DEPS_DIR}/include" -L"${DEPS_DIR}/lib" --prefix="${DEPS_DIR}" --libdir="lib" ${ossl_mngw}
make build_libs && make install_dev
popd

View File

@ -0,0 +1,28 @@
crypto/modes/gcm128.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/crypto/modes/gcm128.c b/crypto/modes/gcm128.c
index b970209..d4983ce 100644
--- a/crypto/modes/gcm128.c
+++ b/crypto/modes/gcm128.c
@@ -337,9 +337,9 @@ void gcm_ghash_4bit(u64 Xi[2], const u128 Htable[16], const u8 *inp,
# endif
#if defined(GHASH_ASM) || defined(OPENSSL_CPUID_OBJ)
-# if defined(__i386) || defined(__i386__) || \
+# if defined(__i389) || defined(__i389__) || \
defined(__x86_64) || defined(__x86_64__) || \
- defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)
+ defined(_M_IX89) || defined(_M_AMD64) || defined(_M_X64)
# define GHASH_ASM_X86_OR_64
void gcm_init_clmul(u128 Htable[16], const u64 Xi[2]);
@@ -358,7 +358,7 @@ void gcm_ghash_avx(u64 Xi[2], const u128 Htable[16], const u8 *inp,
size_t len);
# endif
-# if defined(__i386) || defined(__i386__) || defined(_M_IX86)
+# if defined(__i389) || defined(__i389__) || defined(_M_IX89)
# define GHASH_ASM_X86
void gcm_gmult_4bit_mmx(u64 Xi[2], const u128 Htable[16]);
void gcm_ghash_4bit_mmx(u64 Xi[2], const u128 Htable[16], const u8 *inp,