Hi

OpenSSL SNAP-20010920 OpenSSL-x86 configuration currently
builds only with no-asm, assembler version ends up with linker
complaining about multiply defined symbols in libcrypto.a
This is because OpenSSL checks for i386 and __i386 macros,
which is incorrect for GCC. GNU cpp manual documents quite
clearly, that __foo__ style predefined macros are preferred
over other forms.

Here's diff, tested under openbsd:

diff -ru ../openssl-SNAP-20010920-orig/crypto/bn/bn_div.c ./crypto/bn/bn_div.c
--- ../openssl-SNAP-20010920-orig/crypto/bn/bn_div.c    Fri Mar 30 09:00:28 2001
+++ ./crypto/bn/bn_div.c        Sun Sep 23 00:20:18 2001
@@ -130,7 +130,7 @@
 #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) \
     && !defined(PEDANTIC) && !defined(BN_DIV3W)
 # if defined(__GNUC__) && __GNUC__>=2
-#  if defined(__i386)
+#  if defined(__i386) || defined (__i386__)
    /*
     * There were two reasons for implementing this template:
     * - GNU C generates a call to a function (__udivdi3 to be exact)
diff -ru ../openssl-SNAP-20010920-orig/crypto/bn/bn_mul.c ./crypto/bn/bn_mul.c
--- ../openssl-SNAP-20010920-orig/crypto/bn/bn_mul.c    Mon Feb 19 19:01:05 2001
+++ ./crypto/bn/bn_mul.c        Sun Sep 23 00:21:24 2001
@@ -66,7 +66,7 @@
 #include "cryptlib.h"
 #include "bn_lcl.h"

-#if defined(OPENSSL_NO_ASM) || !defined(__i386) /* Assembler implementation exists 
only for x86 */
+#if defined(OPENSSL_NO_ASM) || !(defined(__i386) || defined(__i386__))/* Assembler 
+implementation exists only for x86 */
 /* Here follows specialised variants of bn_add_words() and
    bn_sub_words().  They have the property performing operations on
    arrays of different sizes.  The sizes of those arrays is expressed through
diff -ru ../openssl-SNAP-20010920-orig/crypto/md32_common.h ./crypto/md32_common.h
--- ../openssl-SNAP-20010920-orig/crypto/md32_common.h  Thu Mar  8 17:00:14 2001
+++ ./crypto/md32_common.h      Sun Sep 23 00:22:32 2001
@@ -198,7 +198,7 @@
    *
    *                                   <[EMAIL PROTECTED]>
    */
-#  if defined(__i386)
+#  if defined(__i386) || defined(__i386__)
 #   define ROTATE(a,n) ({ register unsigned int ret;   \
                                asm (                   \
                                "roll %1,%0"            \
@@ -224,7 +224,7 @@
  */
 # if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && 
!defined(OPENSSL_NO_INLINE_ASM)
   /* some GNU C inline assembler templates by <[EMAIL PROTECTED]> */
-#  if defined(__i386) && !defined(I386_ONLY)
+#  if (defined(__i386) || defined(__i386__)) && !defined(I386_ONLY)
 #   define BE_FETCH32(a)       ({ register unsigned int l=(a);\
                                asm (                   \
                                "bswapl %0"             \
diff -ru ../openssl-SNAP-20010920-orig/crypto/md4/md4_locl.h ./crypto/md4/md4_locl.h
--- ../openssl-SNAP-20010920-orig/crypto/md4/md4_locl.h Mon Aug 14 16:05:31 2000
+++ ./crypto/md4/md4_locl.h     Sun Sep 23 00:22:58 2001
@@ -68,7 +68,7 @@
 void md4_block_host_order (MD4_CTX *c, const void *p,int num);
 void md4_block_data_order (MD4_CTX *c, const void *p,int num);

-#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
+#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 /*
  * *_block_host_order is expected to handle aligned data while
  * *_block_data_order - unaligned. As algorithm and host (x86)
diff -ru ../openssl-SNAP-20010920-orig/crypto/md5/md5_locl.h ./crypto/md5/md5_locl.h
--- ../openssl-SNAP-20010920-orig/crypto/md5/md5_locl.h Mon Feb 19 19:01:51 2001
+++ ./crypto/md5/md5_locl.h     Sun Sep 23 00:24:05 2001
@@ -66,7 +66,7 @@
 #endif

 #ifdef MD5_ASM
-# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
+# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 #  define md5_block_host_order md5_block_asm_host_order
 # elif defined(__sparc) && defined(OPENSSL_SYS_ULTRASPARC)
    void md5_block_asm_data_order_aligned (MD5_CTX *c, const MD5_LONG *p,int num);
@@ -77,7 +77,7 @@
 void md5_block_host_order (MD5_CTX *c, const void *p,int num);
 void md5_block_data_order (MD5_CTX *c, const void *p,int num);

-#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
+#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 /*
  * *_block_host_order is expected to handle aligned data while
  * *_block_data_order - unaligned. As algorithm and host (x86)
diff -ru ../openssl-SNAP-20010920-orig/crypto/opensslconf.h.in 
./crypto/opensslconf.h.in
--- ../openssl-SNAP-20010920-orig/crypto/opensslconf.h.in       Fri Mar  2 13:00:24 
2001
+++ ./crypto/opensslconf.h.in   Sun Sep 23 00:24:41 2001
@@ -147,7 +147,7 @@
 #  define DES_PTR
 #  define DES_RISC2
 #  define DES_UNROLL
-#elif defined( i386 )          /* x86 boxes, should be gcc */
+#elif defined(i386) || defined(__i386__)       /* x86 boxes, should be gcc */
 #  define DES_PTR
 #  define DES_RISC1
 #  define DES_UNROLL
diff -ru ../openssl-SNAP-20010920-orig/crypto/ripemd/rmd_locl.h 
./crypto/ripemd/rmd_locl.h
--- ../openssl-SNAP-20010920-orig/crypto/ripemd/rmd_locl.h      Sun Mar 19 15:00:24 
2000
+++ ./crypto/ripemd/rmd_locl.h  Sun Sep 23 00:26:03 2001
@@ -71,7 +71,7 @@
  *                                     <[EMAIL PROTECTED]>
  */
 #ifdef RMD160_ASM
-# if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
+# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 #  define ripemd160_block_host_order ripemd160_block_asm_host_order
 # endif
 #endif
@@ -79,7 +79,7 @@
 void ripemd160_block_host_order (RIPEMD160_CTX *c, const void *p,int num);
 void ripemd160_block_data_order (RIPEMD160_CTX *c, const void *p,int num);

-#if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
+#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 #define ripemd160_block_data_order ripemd160_block_host_order
 #endif

diff -ru ../openssl-SNAP-20010920-orig/crypto/sha/sha_locl.h ./crypto/sha/sha_locl.h
--- ../openssl-SNAP-20010920-orig/crypto/sha/sha_locl.h Thu Mar  8 17:00:36 2001
+++ ./crypto/sha/sha_locl.h     Sun Sep 23 00:25:39 2001
@@ -115,7 +115,7 @@
 # endif

 # ifdef SHA1_ASM
-#  if defined(__i386) || defined(_M_IX86) || defined(__INTEL__)
+#  if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__INTEL__)
 #   define sha1_block_host_order               sha1_block_asm_host_order
 #   define DONT_IMPLEMENT_BLOCK_HOST_ORDER
 #   define sha1_block_data_order               sha1_block_asm_data_order

-v

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to