Re-enable below algos, apply patch from upstream list to make that code -fPIC friendly. (rhbz#1069792)

This commit is contained in:
Kyle McMartin 2014-05-22 13:28:35 -04:00
parent 4df13ba77f
commit 45283d138c
3 changed files with 173 additions and 100 deletions

View File

@ -1,98 +0,0 @@
diff --git a/cipher/camellia-arm.S b/cipher/camellia-arm.S
index 255a246..214198b 100644
--- a/cipher/camellia-arm.S
+++ b/cipher/camellia-arm.S
@@ -22,6 +22,7 @@
#if defined(__ARMEL__)
#ifdef HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
+#ifndef __PIC__
.text
@@ -609,5 +610,6 @@ _gcry_camellia_arm_decrypt_block:
.long 0x80808000, 0x00010101, 0x40004040, 0xc7c700c7
.long 0x9e9e9e00, 0x003d3d3d, 0x4f004f4f, 0x9e9e009e
-#endif /*HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS*/
+#endif /*__PIC__*/
+#endif /*HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS*/
#endif /*__ARM_ARCH >= 6*/
diff --git a/cipher/camellia.h b/cipher/camellia.h
index d0e3c18..c8f9556 100644
--- a/cipher/camellia.h
+++ b/cipher/camellia.h
@@ -32,7 +32,7 @@
#include <config.h>
/* USE_ARM_ASM indicates whether to use ARM assembly code. */
# undef USE_ARM_ASM
-# if defined(__ARMEL__)
+# if defined(__ARMEL__) && !defined(__PIC__)
# ifdef HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
# define USE_ARM_ASM 1
# endif
diff --git a/cipher/cast5-arm.S b/cipher/cast5-arm.S
index 57c89b7..23c1c12 100644
--- a/cipher/cast5-arm.S
+++ b/cipher/cast5-arm.S
@@ -22,6 +22,7 @@
#if defined(__ARMEL__)
#ifdef HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
+#ifndef __PIC__
.text
@@ -711,5 +712,6 @@ _gcry_cast5_arm_cbc_dec:
.ltorg
.size _gcry_cast5_arm_cbc_dec,.-_gcry_cast5_arm_cbc_dec;
+#endif /*__PIC__*/
#endif /*HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS*/
#endif /*__ARM_ARCH >= 6*/
diff --git a/cipher/cast5.c b/cipher/cast5.c
index 115e1e6..bf4123e 100644
--- a/cipher/cast5.c
+++ b/cipher/cast5.c
@@ -54,7 +54,7 @@
/* USE_ARM_ASM indicates whether to use ARM assembly code. */
#undef USE_ARM_ASM
-#if defined(__ARMEL__)
+#if defined(__ARMEL__) && !defined(__PIC__)
# ifdef HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
# define USE_ARM_ASM 1
# endif
diff --git a/cipher/rijndael-arm.S b/cipher/rijndael-arm.S
index cea8c51..d5d964f 100644
--- a/cipher/rijndael-arm.S
+++ b/cipher/rijndael-arm.S
@@ -22,6 +22,7 @@
#if defined(__ARMEL__)
#ifdef HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
+#ifndef __PIC__
.text
@@ -849,5 +850,6 @@ _gcry_aes_arm_decrypt_block:
.long 0x6184cb7b, 0x00000055, 0x70b632d5, 0x00000021
.long 0x745c6c48, 0x0000000c, 0x4257b8d0, 0x0000007d
-#endif /*HAVE_COMPATIBLE_GCC_AMD64_PLATFORM_AS*/
+#endif /*__PIC__*/
+#endif /*HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS*/
#endif /*__ARMEL__ */
diff --git a/cipher/rijndael.c b/cipher/rijndael.c
index 8019f0a..1ffc559 100644
--- a/cipher/rijndael.c
+++ b/cipher/rijndael.c
@@ -69,7 +69,7 @@
/* USE_ARM_ASM indicates whether to use ARM assembly code. */
#undef USE_ARM_ASM
-#if defined(__ARMEL__)
+#if defined(__ARMEL__) && !defined(__PIC__)
# ifdef HAVE_COMPATIBLE_GCC_ARM_PLATFORM_AS
# define USE_ARM_ASM 1
# endif

View File

@ -0,0 +1,167 @@
Fix ARM assembly when building __PIC__
From: Jussi Kivilinna <jussi.kivilinna@iki.fi>
* cipher/camellia-arm.S (GET_DATA_POINTER): New.
(_gcry_camellia_arm_encrypt_block): Use GET_DATA_POINTER.
(_gcry_camellia_arm_decrypt_block): Ditto.
* cipher/cast5-arm.S (GET_DATA_POINTER): New.
(_gcry_cast5_arm_encrypt_block, _gcry_cast5_arm_decrypt_block)
(_gcry_cast5_arm_enc_blk2, _gcry_cast5_arm_dec_blk2): Use
GET_DATA_POINTER.
* cipher/rijndael-arm.S (GET_DATA_POINTER): New.
(_gcry_aes_arm_encrypt_block, _gcry_aes_arm_decrypt_block): Use
GET_DATA_POINTER.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
---
cipher/camellia-arm.S | 17 +++++++++++++++--
cipher/cast5-arm.S | 21 +++++++++++++++++----
cipher/rijndael-arm.S | 17 +++++++++++++++--
3 files changed, 47 insertions(+), 8 deletions(-)
diff --git a/cipher/camellia-arm.S b/cipher/camellia-arm.S
index c30d194..cdeaf8b 100644
--- a/cipher/camellia-arm.S
+++ b/cipher/camellia-arm.S
@@ -28,6 +28,19 @@
.syntax unified
.arm
+#ifdef __PIC__
+# define GET_DATA_POINTER(reg, name, rtmp) \
+ ldr reg, 1f; \
+ ldr rtmp, 2f; \
+ b 3f; \
+ 1: .word _GLOBAL_OFFSET_TABLE_-(3f+8); \
+ 2: .word name(GOT); \
+ 3: add reg, pc, reg; \
+ ldr reg, [reg, rtmp];
+#else
+# define GET_DATA_POINTER(reg, name, rtmp) ldr reg, =name
+#endif
+
/* struct camellia_ctx: */
#define key_table 0
@@ -261,7 +274,7 @@ _gcry_camellia_arm_encrypt_block:
*/
push {%r1, %r4-%r11, %ip, %lr};
- ldr RTAB1, =.Lcamellia_sp1110;
+ GET_DATA_POINTER(RTAB1, .Lcamellia_sp1110, RTAB3);
mov RMASK, #0xff;
add RTAB3, RTAB1, #(2 * 4);
push {%r3};
@@ -309,7 +322,7 @@ _gcry_camellia_arm_decrypt_block:
*/
push {%r1, %r4-%r11, %ip, %lr};
- ldr RTAB1, =.Lcamellia_sp1110;
+ GET_DATA_POINTER(RTAB1, .Lcamellia_sp1110, RTAB3);
mov RMASK, #0xff;
add RTAB3, RTAB1, #(2 * 4);
mov RMASK, RMASK, lsl#4 /* byte mask */
diff --git a/cipher/cast5-arm.S b/cipher/cast5-arm.S
index ce7fa93..db96db4 100644
--- a/cipher/cast5-arm.S
+++ b/cipher/cast5-arm.S
@@ -30,6 +30,19 @@
.extern _gcry_cast5_s1to4;
+#ifdef __PIC__
+# define GET_DATA_POINTER(reg, name, rtmp) \
+ ldr reg, 1f; \
+ ldr rtmp, 2f; \
+ b 3f; \
+ 1: .word _GLOBAL_OFFSET_TABLE_-(3f+8); \
+ 2: .word name(GOT); \
+ 3: add reg, pc, reg; \
+ ldr reg, [reg, rtmp];
+#else
+# define GET_DATA_POINTER(reg, name, rtmp) ldr reg, =name
+#endif
+
/* structure of crypto context */
#define Km 0
#define Kr (Km + (16 * 4))
@@ -260,7 +273,7 @@ _gcry_cast5_arm_encrypt_block:
*/
push {%r1, %r4-%r11, %ip, %lr};
- ldr Rs1, =_gcry_cast5_s1to4;
+ GET_DATA_POINTER(Rs1, _gcry_cast5_s1to4, Rs2);
mov RMASK, #(0xff << 2);
add Rs2, Rs1, #(0x100*4);
add Rs3, Rs1, #(0x100*4*2);
@@ -306,7 +319,7 @@ _gcry_cast5_arm_decrypt_block:
*/
push {%r1, %r4-%r11, %ip, %lr};
- ldr Rs1, =_gcry_cast5_s1to4;
+ GET_DATA_POINTER(Rs1, _gcry_cast5_s1to4, Rs2);
mov RMASK, #(0xff << 2);
add Rs2, Rs1, #(0x100 * 4);
add Rs3, Rs1, #(0x100 * 4 * 2);
@@ -500,7 +513,7 @@ _gcry_cast5_arm_enc_blk2:
*/
push {%lr};
- ldr Rs1, =_gcry_cast5_s1to4;
+ GET_DATA_POINTER(Rs1, _gcry_cast5_s1to4, Rs2);
mov RMASK, #(0xff << 2);
add Rs2, Rs1, #(0x100 * 4);
@@ -631,7 +644,7 @@ _gcry_cast5_arm_dec_blk2:
* [RR0, RL0], [RR1, RL1]: dst
*/
- ldr Rs1, =_gcry_cast5_s1to4;
+ GET_DATA_POINTER(Rs1, _gcry_cast5_s1to4, Rs2);
mov RMASK, #(0xff << 2);
add Rs2, Rs1, #(0x100 * 4);
diff --git a/cipher/rijndael-arm.S b/cipher/rijndael-arm.S
index 22c350c..421c3b4 100644
--- a/cipher/rijndael-arm.S
+++ b/cipher/rijndael-arm.S
@@ -28,6 +28,19 @@
.syntax unified
.arm
+#ifdef __PIC__
+# define GET_DATA_POINTER(reg, name, rtmp) \
+ ldr reg, 1f; \
+ ldr rtmp, 2f; \
+ b 3f; \
+ 1: .word _GLOBAL_OFFSET_TABLE_-(3f+8); \
+ 2: .word name(GOT); \
+ 3: add reg, pc, reg; \
+ ldr reg, [reg, rtmp];
+#else
+# define GET_DATA_POINTER(reg, name, rtmp) ldr reg, =name
+#endif
+
/* register macros */
#define CTX %r0
#define RTAB %lr
@@ -249,7 +262,7 @@ _gcry_aes_arm_encrypt_block:
2:
sub %sp, #16;
- ldr RTAB, =.LtableE0;
+ GET_DATA_POINTER(RTAB, .LtableE0, RMASK);
str %r1, [%sp, #4]; /* dst */
mov RMASK, #0xff;
@@ -503,7 +516,7 @@ _gcry_aes_arm_decrypt_block:
2:
sub %sp, #16;
- ldr RTAB, =.LtableD0;
+ GET_DATA_POINTER(RTAB, .LtableD0, RMASK);
mov RMASK, #0xff;
str %r1, [%sp, #4]; /* dst */

View File

@ -1,6 +1,6 @@
Name: libgcrypt Name: libgcrypt
Version: 1.6.1 Version: 1.6.1
Release: 3%{?dist} Release: 4%{?dist}
URL: http://www.gnupg.org/ URL: http://www.gnupg.org/
Source0: libgcrypt-%{version}-hobbled.tar.xz Source0: libgcrypt-%{version}-hobbled.tar.xz
# The original libgcrypt sources now contain potentially patented ECC # The original libgcrypt sources now contain potentially patented ECC
@ -33,7 +33,7 @@ Patch11: libgcrypt-1.6.1-use-poll.patch
Patch13: libgcrypt-1.6.1-mpicoder-gccopt.patch Patch13: libgcrypt-1.6.1-mpicoder-gccopt.patch
# fix tests to work with approved ECC # fix tests to work with approved ECC
Patch14: libgcrypt-1.6.1-ecc-test-fix.patch Patch14: libgcrypt-1.6.1-ecc-test-fix.patch
Patch15: libgcrypt-1.6.1-disable-non-PIC-arm.patch Patch15: libgcrypt-1.6.1-make-arm-asm-fPIC-friendly.patch
%define gcrylibdir %{_libdir} %define gcrylibdir %{_libdir}
@ -185,6 +185,10 @@ exit 0
%doc COPYING %doc COPYING
%changelog %changelog
* Tue May 20 2014 Kyle McMartin <kyle@fedoraproject.org> 1.6.1-4
- Re-enable below algos, apply patch from upstream list to make
that code -fPIC friendly. (rhbz#1069792)
* Mon May 19 2014 Kyle McMartin <kyle@fedoraproject.org> 1.6.1-3 * Mon May 19 2014 Kyle McMartin <kyle@fedoraproject.org> 1.6.1-3
- Disable rijndael, cast5, camellia ARM assembly, as it's non-PIC as - Disable rijndael, cast5, camellia ARM assembly, as it's non-PIC as
presently written, which results in .text relocations in the shared presently written, which results in .text relocations in the shared