Fix "unexpected reloc type 0x03" for ARM shared object (GH #846)

pull/853/head
Jeffrey Walton 2019-05-22 19:00:08 -04:00
parent ce5d5d5c0f
commit 7eaa5837e0
No known key found for this signature in database
GPG Key ID: B36AB348921B1838
4 changed files with 20 additions and 93 deletions

37
sha.cpp
View File

@ -60,7 +60,6 @@
#endif #endif
#if CRYPTOGAMS_ARM_SHA1 || CRYPTOGAMS_ARM_SHA256 || CRYPTOGAMS_ARM_SHA512 #if CRYPTOGAMS_ARM_SHA1 || CRYPTOGAMS_ARM_SHA256 || CRYPTOGAMS_ARM_SHA512
extern "C" unsigned int CRYPTOGAMS_armcaps;
unsigned int CRYPTOGAMS_armcaps = 0; unsigned int CRYPTOGAMS_armcaps = 0;
#endif #endif
@ -72,7 +71,7 @@ extern void SHA256_HashMultipleBlocks_SHANI(word32 *state, const word32 *data, s
#endif #endif
#if CRYPTOGAMS_ARM_SHA1 #if CRYPTOGAMS_ARM_SHA1
extern "C" void sha1_block_data_order(word32* state, const word32 *data, size_t blocks); extern "C" void sha1_block_data_order(word32* state, const word32 *data, size_t blocks, unsigned int caps);
#endif #endif
#if CRYPTOPP_ARM_SHA1_AVAILABLE #if CRYPTOPP_ARM_SHA1_AVAILABLE
@ -84,7 +83,7 @@ extern void SHA256_HashMultipleBlocks_ARMV8(word32 *state, const word32 *data, s
#endif #endif
#if CRYPTOGAMS_ARM_SHA256 #if CRYPTOGAMS_ARM_SHA256
extern "C" void sha256_block_data_order(word32* state, const word32 *data, size_t blocks); extern "C" void sha256_block_data_order(word32* state, const word32 *data, size_t blocks, unsigned int caps);
#endif #endif
#if CRYPTOPP_ARM_SHA512_AVAILABLE #if CRYPTOPP_ARM_SHA512_AVAILABLE
@ -97,7 +96,7 @@ extern void SHA512_HashMultipleBlocks_POWER8(word64 *state, const word64 *data,
#endif #endif
#if CRYPTOGAMS_ARM_SHA512 #if CRYPTOGAMS_ARM_SHA512
extern "C" void sha512_block_data_order(word64* state, const word64 *data, size_t blocks); extern "C" void sha512_block_data_order(word64* state, const word64 *data, size_t blocks, unsigned int caps);
#endif #endif
// We add extern to export table to sha_simd.cpp, but it // We add extern to export table to sha_simd.cpp, but it
@ -315,14 +314,13 @@ void SHA1::Transform(word32 *state, const word32 *data)
if (HasARMv7()) if (HasARMv7())
{ {
static const unsigned int caps = CryptogamsArmCaps(); static const unsigned int caps = CryptogamsArmCaps();
CRYPTOPP_UNUSED(caps);
# if defined(CRYPTOPP_LITTLE_ENDIAN) # if defined(CRYPTOPP_LITTLE_ENDIAN)
word32 dataBuf[16]; word32 dataBuf[16];
ByteReverse(dataBuf, data, SHA1::BLOCKSIZE); ByteReverse(dataBuf, data, SHA1::BLOCKSIZE);
sha1_block_data_order(state, data, 1); sha1_block_data_order(state, data, 1, caps);
# else # else
sha1_block_data_order(state, data, 1); sha1_block_data_order(state, data, 1, caps);
# endif # endif
return; return;
} }
@ -353,10 +351,8 @@ size_t SHA1::HashMultipleBlocks(const word32 *input, size_t length)
#if CRYPTOGAMS_ARM_SHA1 #if CRYPTOGAMS_ARM_SHA1
if (HasARMv7()) if (HasARMv7())
{ {
static const unsigned int caps = CryptogamsArmCaps(); const unsigned int caps = CryptogamsArmCaps();
CRYPTOPP_UNUSED(caps); sha1_block_data_order(m_state, input, length / SHA1::BLOCKSIZE, caps);
sha1_block_data_order(m_state, input, length / SHA1::BLOCKSIZE);
return length & (SHA1::BLOCKSIZE - 1); return length & (SHA1::BLOCKSIZE - 1);
} }
#endif #endif
@ -866,14 +862,13 @@ void SHA256::Transform(word32 *state, const word32 *data)
if (HasARMv7()) if (HasARMv7())
{ {
static const unsigned int caps = CryptogamsArmCaps(); static const unsigned int caps = CryptogamsArmCaps();
CRYPTOPP_UNUSED(caps);
# if defined(CRYPTOPP_LITTLE_ENDIAN) # if defined(CRYPTOPP_LITTLE_ENDIAN)
word32 dataBuf[16]; word32 dataBuf[16];
ByteReverse(dataBuf, data, SHA256::BLOCKSIZE); ByteReverse(dataBuf, data, SHA256::BLOCKSIZE);
sha256_block_data_order(state, data, 1); sha256_block_data_order(state, data, 1, caps);
# else # else
sha256_block_data_order(state, data, 1); sha256_block_data_order(state, data, 1, caps);
# endif # endif
return; return;
} }
@ -919,10 +914,8 @@ size_t SHA256::HashMultipleBlocks(const word32 *input, size_t length)
#if CRYPTOGAMS_ARM_SHA256 #if CRYPTOGAMS_ARM_SHA256
if (HasARMv7()) if (HasARMv7())
{ {
static const unsigned int caps = CryptogamsArmCaps(); const unsigned int caps = CryptogamsArmCaps();
CRYPTOPP_UNUSED(caps); sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE, caps);
sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE);
return length & (SHA256::BLOCKSIZE - 1); return length & (SHA256::BLOCKSIZE - 1);
} }
#endif #endif
@ -986,9 +979,8 @@ size_t SHA224::HashMultipleBlocks(const word32 *input, size_t length)
if (HasARMv7()) if (HasARMv7())
{ {
static const unsigned int caps = CryptogamsArmCaps(); static const unsigned int caps = CryptogamsArmCaps();
CRYPTOPP_UNUSED(caps);
sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE); sha256_block_data_order(m_state, input, length / SHA256::BLOCKSIZE, caps);;
return length & (SHA256::BLOCKSIZE - 1); return length & (SHA256::BLOCKSIZE - 1);
} }
#endif #endif
@ -1352,14 +1344,13 @@ void SHA512::Transform(word64 *state, const word64 *data)
if (HasARMv7()) if (HasARMv7())
{ {
static const unsigned int caps = CryptogamsArmCaps(); static const unsigned int caps = CryptogamsArmCaps();
CRYPTOPP_UNUSED(caps);
# if defined(CRYPTOPP_LITTLE_ENDIAN) # if defined(CRYPTOPP_LITTLE_ENDIAN)
word64 dataBuf[16]; word64 dataBuf[16];
ByteReverse(dataBuf, data, SHA512::BLOCKSIZE); ByteReverse(dataBuf, data, SHA512::BLOCKSIZE);
sha512_block_data_order(state, dataBuf, 1); sha512_block_data_order(state, dataBuf, 1, caps);
# else # else
sha512_block_data_order(state, data, 1); sha512_block_data_order(state, data, 1, caps);
# endif # endif
return; return;
} }

View File

@ -64,10 +64,6 @@
# endif # endif
# endif # endif
# ifndef __ASSEMBLER__
extern unsigned int CRYPTOGAMS_armcaps;
# endif
# define ARMV7_NEON (1<<0) # define ARMV7_NEON (1<<0)
@ JW, MAY 2019: End defines from taken from arm_arch.h @ JW, MAY 2019: End defines from taken from arm_arch.h
@ -88,15 +84,7 @@ extern unsigned int CRYPTOGAMS_armcaps;
.align 5 .align 5
sha1_block_data_order: sha1_block_data_order:
#if __ARM_MAX_ARCH__>=7 #if __ARM_MAX_ARCH__>=7
.Lsha1_block: mov r12,r3
ldr r12,.LCRYPTOGAMS_armcap_loc
# if !defined(_WIN32)
adr r3,.Lsha1_block
ldr r12,[r3,r12] @ CRYPTOGAMS_armcaps
# endif
# if defined(__APPLE__) || defined(_WIN32)
ldr r12,[r12]
# endif
tst r12,#ARMV7_NEON tst r12,#ARMV7_NEON
bne .LNEON bne .LNEON
#endif #endif
@ -557,14 +545,6 @@ sha1_block_data_order:
.LK_20_39:.word 0x6ed9eba1 .LK_20_39:.word 0x6ed9eba1
.LK_40_59:.word 0x8f1bbcdc .LK_40_59:.word 0x8f1bbcdc
.LK_60_79:.word 0xca62c1d6 .LK_60_79:.word 0xca62c1d6
#if __ARM_MAX_ARCH__>=7
.LCRYPTOGAMS_armcap_loc:
# ifdef _WIN32
.word CRYPTOGAMS_armcaps
# else
.word CRYPTOGAMS_armcaps-.Lsha1_block
# endif
#endif
.align 5 .align 5
#if __ARM_MAX_ARCH__>=7 #if __ARM_MAX_ARCH__>=7
@ -1422,7 +1402,3 @@ sha1_block_data_order_neon:
ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,pc} ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,pc}
.size sha1_block_data_order_neon,.-sha1_block_data_order_neon .size sha1_block_data_order_neon,.-sha1_block_data_order_neon
#endif #endif
#if __ARM_MAX_ARCH__>=7
.comm CRYPTOGAMS_armcaps,4,4
#endif

View File

@ -64,10 +64,6 @@
# endif # endif
# endif # endif
# ifndef __ASSEMBLER__
extern unsigned int CRYPTOGAMS_armcaps;
# endif
# define ARMV7_NEON (1<<0) # define ARMV7_NEON (1<<0)
@ JW, MAY 2019: End defines from taken from arm_arch.h @ JW, MAY 2019: End defines from taken from arm_arch.h
@ -103,33 +99,20 @@ K256:
.word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2 .word 0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
.size K256,.-K256 .size K256,.-K256
.word 0 @ terminator .word 0 @ terminator
#if __ARM_MAX_ARCH__>=7
.LCRYPTOGAMS_armcap_loc:
# ifdef _WIN32
.word CRYPTOGAMS_armcaps
# else
.word CRYPTOGAMS_armcaps-.Lsha256_block_data_order
# endif
#endif
.align 5
.align 5
.globl sha256_block_data_order .globl sha256_block_data_order
.type sha256_block_data_order,%function .type sha256_block_data_order,%function
sha256_block_data_order: sha256_block_data_order:
.Lsha256_block_data_order: .Lsha256_block_data_order:
#if __ARM_ARCH__<7 && !defined(__thumb2__) #if __ARM_ARCH__<7 && !defined(__thumb2__)
mov r12,r3
sub r3,pc,#8 @ sha256_block_data_order sub r3,pc,#8 @ sha256_block_data_order
#else #else
mov r12,r3
adr r3,.Lsha256_block_data_order adr r3,.Lsha256_block_data_order
#endif #endif
#if __ARM_MAX_ARCH__>=7 #if __ARM_MAX_ARCH__>=7
ldr r12,.LCRYPTOGAMS_armcap_loc
# if !defined(_WIN32)
ldr r12,[r3,r12] @ CRYPTOGAMS_armcaps
# endif
# if defined(__APPLE__) || defined(_WIN32)
ldr r12,[r12]
# endif
tst r12,#ARMV7_NEON tst r12,#ARMV7_NEON
bne .LNEON bne .LNEON
#endif #endif
@ -2686,7 +2669,3 @@ sha256_block_data_order_neon:
ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,pc} ldmia sp!,{r4,r5,r6,r7,r8,r9,r10,r11,r12,pc}
.size sha256_block_data_order_neon,.-sha256_block_data_order_neon .size sha256_block_data_order_neon,.-sha256_block_data_order_neon
#endif #endif
#if __ARM_MAX_ARCH__>=7
.comm CRYPTOGAMS_armcaps,4,4
#endif

View File

@ -64,10 +64,6 @@
# endif # endif
# endif # endif
# ifndef __ASSEMBLER__
extern unsigned int CRYPTOGAMS_armcaps;
# endif
# define ARMV7_NEON (1<<0) # define ARMV7_NEON (1<<0)
@ JW, MAY 2019: End defines from taken from arm_arch.h @ JW, MAY 2019: End defines from taken from arm_arch.h
@ -138,12 +134,6 @@ K512:
WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817)
.size K512,.-K512 .size K512,.-K512
#if __ARM_MAX_ARCH__>=7 #if __ARM_MAX_ARCH__>=7
.LCRYPTOGAMS_armcap_loc:
# ifdef _WIN32
.word CRYPTOGAMS_armcaps
# else
.word CRYPTOGAMS_armcaps-.Lsha512_block_data_order
# endif
.skip 32-4 .skip 32-4
#else #else
.skip 32 .skip 32
@ -154,18 +144,13 @@ K512:
sha512_block_data_order: sha512_block_data_order:
.Lsha512_block_data_order: .Lsha512_block_data_order:
#if __ARM_ARCH__<7 && !defined(__thumb2__) #if __ARM_ARCH__<7 && !defined(__thumb2__)
mov r12,r3
sub r3,pc,#8 @ sha512_block_data_order sub r3,pc,#8 @ sha512_block_data_order
#else #else
mov r12,r3
adr r3,.Lsha512_block_data_order adr r3,.Lsha512_block_data_order
#endif #endif
#if __ARM_MAX_ARCH__>=7 #if __ARM_MAX_ARCH__>=7
ldr r12,.LCRYPTOGAMS_armcap_loc
# if !defined(_WIN32)
ldr r12,[r3,r12] @ CRYPTOGAMS_armcaps
# endif
# if defined(__APPLE__) || defined(_WIN32)
ldr r12,[r12]
# endif
tst r12,#ARMV7_NEON tst r12,#ARMV7_NEON
bne .LNEON bne .LNEON
#endif #endif
@ -1875,7 +1860,3 @@ sha512_block_data_order_neon:
bx lr @ .word 0xe12fff1e bx lr @ .word 0xe12fff1e
.size sha512_block_data_order_neon,.-sha512_block_data_order_neon .size sha512_block_data_order_neon,.-sha512_block_data_order_neon
#endif #endif
#if __ARM_MAX_ARCH__>=7
.comm CRYPTOGAMS_armcaps,4,4
#endif