From 5d42fe85a365517731ce210130febffcd40f0bcd Mon Sep 17 00:00:00 2001 From: Erik van Pienbroek Date: Wed, 2 Jan 2013 23:21:23 +0100 Subject: [PATCH] Made the win64 asm code work properly --- ...crypt-use-correct-asm-code-for-win64.patch | 81 +++++++++++++++++++ mingw-libgcrypt.spec | 10 ++- 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 libgcrypt-use-correct-asm-code-for-win64.patch diff --git a/libgcrypt-use-correct-asm-code-for-win64.patch b/libgcrypt-use-correct-asm-code-for-win64.patch new file mode 100644 index 0000000..8227ac6 --- /dev/null +++ b/libgcrypt-use-correct-asm-code-for-win64.patch @@ -0,0 +1,81 @@ +--- mpi/mpi-internal.h.orig 2013-01-02 12:04:49.634772462 +0100 ++++ mpi/mpi-internal.h 2013-01-02 12:11:41.222744150 +0100 +@@ -168,6 +168,12 @@ + } while (0) + + ++#ifdef _WIN64 ++#define ATTR_ABI __attribute__ ((sysv_abi)) ++#else ++#define ATTR_ABI ++#endif ++ + /*-- mpiutil.c --*/ + #define mpi_alloc_limb_space(n,f) _gcry_mpi_alloc_limb_space((n),(f)) + mpi_ptr_t _gcry_mpi_alloc_limb_space( unsigned nlimbs, int sec ); +@@ -186,7 +192,7 @@ + mpi_limb_t _gcry_mpih_add_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, + mpi_size_t s1_size, mpi_limb_t s2_limb ); + mpi_limb_t _gcry_mpih_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +- mpi_ptr_t s2_ptr, mpi_size_t size); ++ mpi_ptr_t s2_ptr, mpi_size_t size) ATTR_ABI; + mpi_limb_t _gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, + mpi_ptr_t s2_ptr, mpi_size_t s2_size); + +@@ -194,7 +200,7 @@ + mpi_limb_t _gcry_mpih_sub_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, + mpi_size_t s1_size, mpi_limb_t s2_limb ); + mpi_limb_t _gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +- mpi_ptr_t s2_ptr, mpi_size_t size); ++ mpi_ptr_t s2_ptr, mpi_size_t size) ATTR_ABI; + mpi_limb_t _gcry_mpih_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, + mpi_ptr_t s2_ptr, mpi_size_t s2_size); + +@@ -216,9 +222,9 @@ + void _gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx ); + + mpi_limb_t _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +- mpi_size_t s1_size, mpi_limb_t s2_limb); ++ mpi_size_t s1_size, mpi_limb_t s2_limb) ATTR_ABI; + mpi_limb_t _gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +- mpi_size_t s1_size, mpi_limb_t s2_limb); ++ mpi_size_t s1_size, mpi_limb_t s2_limb) ATTR_ABI; + void _gcry_mpih_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, + mpi_size_t size); + mpi_limb_t _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, +@@ -235,7 +241,7 @@ + + /*-- mpih-mul_1.c (or xxx/cpu/ *.S) --*/ + mpi_limb_t _gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +- mpi_size_t s1_size, mpi_limb_t s2_limb); ++ mpi_size_t s1_size, mpi_limb_t s2_limb) ATTR_ABI; + + /*-- mpih-div.c --*/ + mpi_limb_t _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, +@@ -249,9 +255,9 @@ + + /*-- mpih-shift.c --*/ + mpi_limb_t _gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, +- unsigned cnt); ++ unsigned cnt) ATTR_ABI; + mpi_limb_t _gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, +- unsigned cnt); ++ unsigned cnt) ATTR_ABI; + + + /* Define stuff for longlong.h. */ +--- mpi/generic/mpi-asm-defs.h.orig 2013-01-02 15:07:53.540464492 +0100 ++++ mpi/generic/mpi-asm-defs.h 2013-01-02 15:08:16.720633878 +0100 +@@ -1,8 +1,11 @@ + /* This file defines some basic constants for the MPI machinery. We + * need to define the types on a per-CPU basis, so it is done with + * this file here. */ ++#ifdef _WIN64 ++#define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG_LONG) ++#else + #define BYTES_PER_MPI_LIMB (SIZEOF_UNSIGNED_LONG) +- ++#endif + + + diff --git a/mingw-libgcrypt.spec b/mingw-libgcrypt.spec index f25ec94..fb2aa16 100644 --- a/mingw-libgcrypt.spec +++ b/mingw-libgcrypt.spec @@ -4,7 +4,7 @@ Name: mingw-libgcrypt Version: 1.5.0 -Release: 5%{?dist} +Release: 6%{?dist} Summary: MinGW Windows gcrypt encryption library License: LGPLv2+ and GPLv2+ @@ -28,6 +28,10 @@ Patch0: libgcrypt-mingw64-use-correct-datatype-for-GetProcessWorkingSet. # libgcrypt-use-correct-def-file.patch Patch2: libgcrypt-use-correct-def-file.patch +# The ASM code is written for the generic x86_64 target. +# For Win64 some minor changes are needed +Patch3: libgcrypt-use-correct-asm-code-for-win64.patch + BuildArch: noarch BuildRequires: mingw32-filesystem >= 95 @@ -97,6 +101,7 @@ Static library for mingw64-libgcrypt development. %{SOURCE3} %patch0 -p0 -b .win64 %patch2 -p0 -b .def +%patch3 -p0 -b .asm64 %build @@ -163,6 +168,9 @@ rm $RPM_BUILD_ROOT%{mingw64_libdir}/libgcrypt.la %changelog +* Wed Jan 2 2013 Erik van Pienbroek - 1.5.0-6 +- Made the win64 asm code work properly + * Sun Oct 20 2012 Yaakov Selkowitz - 1.5.0-5 - Add static libraries - Fix compile of assembly code for mingw64