Fixed Clang 3.4 compiler error on Linux

This commit is contained in:
Jeffrey Walton 2015-12-25 08:00:05 -05:00
parent 6e8d8c4ff9
commit 0e3ee98ff6
5 changed files with 45 additions and 4 deletions

15
cpu.h
View File

@ -278,6 +278,21 @@ inline int GetCacheLineSize()
#define IF0(y)
#define IF1(y) y
// Should be confined to GCC, but its used to help manage Clang 3.4 compiler error.
// Also see LLVM Bug 24232, http://llvm.org/bugs/show_bug.cgi?id=24232 .
#ifndef INTEL_PREFIX
#define INTEL_PREFIX
#endif
#ifndef INTEL_NOPREFIX
#define INTEL_NOPREFIX
#endif
#ifndef ATT_PREFIX
#define ATT_PREFIX
#endif
#ifndef ATT_NOPREFIX
#define ATT_NOPREFIX
#endif
#ifdef CRYPTOPP_GENERATE_X64_MASM
#define ASM_MOD(x, y) ((x) MOD (y))
#define XMMWORD_PTR XMMWORD PTR

View File

@ -735,7 +735,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( add WORD_REG(cx), 16 )
AS2( sub WORD_REG(dx), 1 )
ATT_NOPREFIX
ASJ( jnz, 0, b )
INTEL_NOPREFIX
AS2( movdqa [WORD_REG(si)], xmm0 )
#if CRYPTOPP_BOOL_X32
@ -820,7 +822,9 @@ size_t GCM_Base::AuthenticateBlocks(const byte *data, size_t len)
AS2( add WORD_REG(cx), 16 )
AS2( sub WORD_REG(dx), 1 )
ATT_NOPREFIX
ASJ( jnz, 1, b )
INTEL_NOPREFIX
AS2( movdqa [WORD_REG(si)], xmm0 )
#ifdef __GNUC__

View File

@ -10,8 +10,8 @@
#include "iterhash.h"
#include "secblock.h"
// Clang 3.3 integrated assembler crash on Linux
#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30400))
// Clang 3.3 integrated assembler crash on Linux. Clang 3.4 due to compiler error with .intel_syntax
#if CRYPTOPP_BOOL_X32 || (defined(CRYPTOPP_CLANG_VERSION) && (CRYPTOPP_CLANG_VERSION < 30500))
# define CRYPTOPP_DISABLE_PANAMA_ASM
#endif

View File

@ -651,7 +651,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( movdqa XMMWORD_PTR [L_SUBKEYS+WORD_REG(si)], xmm0)
AS2( add WORD_REG(si), 16)
AS2( cmp WORD_REG(si), 16*12)
ATT_NOPREFIX
ASJ( jl, 0, b)
INTEL_NOPREFIX
// read subkeys 0, 1 and last
AS2( movdqa xmm4, [WORD_REG(ax)+WORD_REG(si)]) // last subkey
@ -673,11 +675,15 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( mov esi, [AS_REG_7+WORD_REG(ax)])
AS2( add WORD_REG(ax), WORD_REG(di))
AS2( cmp WORD_REG(ax), 2048)
ATT_NOPREFIX
ASJ( jl, 9, b)
INTEL_NOPREFIX
AS1( lfence)
AS2( test DWORD PTR [L_LENGTH], 1)
ATT_NOPREFIX
ASJ( jz, 8, f)
INTEL_NOPREFIX
// counter mode one-time setup
AS2( mov WORD_REG(si), [L_INBLOCKS])
@ -751,8 +757,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( mov [L_SAVED_X+0*4], eax)
AS2( mov [L_SAVED_X+1*4], ebx)
AS2( mov [L_SAVED_X+2*4], edi)
ATT_NOPREFIX
ASJ( jmp, 5, f)
INTEL_NOPREFIX
ASL(3)
// non-counter mode per-block setup
AS2( MOVD MM(1), [L_KEY12+0*4]) // 0,1,2,3
@ -802,8 +809,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( add L_REG, [L_KEYS_BEGIN])
AS2( add L_REG, 4*16)
ATT_NOPREFIX
ASJ( jmp, 2, f)
INTEL_NOPREFIX
ASL(1)
// counter-mode per-block setup
AS2( MOVD ecx, MM(2))
@ -830,7 +838,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( add L_REG, [L_KEYS_BEGIN])
AS2( add L_REG, 3*16)
ATT_NOPREFIX
ASJ( jmp, 4, f)
INTEL_NOPREFIX
// in: eax(0,1,2,3), ebx(4,5,6,7), ecx(8,9,10,11), edx(12,13,14,15)
// out: eax, ebx, edi, mm0
@ -877,7 +887,9 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( add L_REG, 32)
AS2( test L_REG, 255)
ATT_NOPREFIX
ASJ( jnz, 2, b)
INTEL_NOPREFIX
AS2( sub L_REG, 16*16)
#define LAST(a, b, c) \
@ -923,16 +935,22 @@ CRYPTOPP_NAKED void CRYPTOPP_FASTCALL Rijndael_Enc_AdvancedProcessBlocks(void *l
AS2( pxor xmm2, [L_LASTROUND])
AS2( movdqu [WORD_REG(bx)], xmm2)
ATT_NOPREFIX
ASJ( jle, 7, f)
INTEL_NOPREFIX
AS2( mov [L_LENGTH], WORD_REG(cx))
AS2( test WORD_REG(cx), 1)
ATT_NOPREFIX
ASJ( jnz, 1, b)
INTEL_NOPREFIX
#if CRYPTOPP_BOOL_X64
AS2( movdqa xmm0, [L_INCREMENTS])
AS2( paddq xmm0, [L_INBLOCKS])
AS2( movdqa [L_INBLOCKS], xmm0)
#endif
ATT_NOPREFIX
ASJ( jmp, 3, b)
INTEL_NOPREFIX
ASL(7)
// erase keys on stack

View File

@ -371,7 +371,9 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
ROUND(14, 1, eax, ecx, edi, edx)
ROUND(15, 1, ecx, eax, edx, edi)
AS2( cmp WORD_REG(si), K_END)
ATT_NOPREFIX
ASJ( jb, 1, b)
INTEL_NOPREFIX
AS2( mov WORD_REG(dx), DATA_SAVE)
AS2( add WORD_REG(dx), 64)
@ -390,7 +392,9 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(word32 *state, const word32
AS2( movdqa [AS_REG_7+1*16], xmm1)
AS2( movdqa [AS_REG_7+0*16], xmm0)
AS2( cmp WORD_REG(dx), DATA_END)
ATT_NOPREFIX
ASJ( jb, 0, b)
INTEL_NOPREFIX
#endif
#if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32