Merge "x86: Fix DT_TEXTREL in assembly code"
diff --git a/crypto/aes/asm/aes-586.S b/crypto/aes/asm/aes-586.S
index f69b7d5..20c0238 100644
--- a/crypto/aes/asm/aes-586.S
+++ b/crypto/aes/asm/aes-586.S
@@ -994,7 +994,8 @@
 	call	.L004pic_point
 .L004pic_point:
 	popl	%ebp
-	leal	OPENSSL_ia32cap_P,%eax
+	leal	_GLOBAL_OFFSET_TABLE_+[.-.L004pic_point](%ebp),%eax
+	movl	OPENSSL_ia32cap_P@GOT(%eax),%eax
 	leal	.LAES_Te-.L004pic_point(%ebp),%ebp
 	leal	764(%esp),%ebx
 	subl	%ebp,%ebx
@@ -2184,7 +2185,8 @@
 	call	.L010pic_point
 .L010pic_point:
 	popl	%ebp
-	leal	OPENSSL_ia32cap_P,%eax
+	leal	_GLOBAL_OFFSET_TABLE_+[.-.L010pic_point](%ebp),%eax
+	movl	OPENSSL_ia32cap_P@GOT(%eax),%eax
 	leal	.LAES_Td-.L010pic_point(%ebp),%ebp
 	leal	764(%esp),%ebx
 	subl	%ebp,%ebx
@@ -2240,7 +2242,8 @@
 	call	.L013pic_point
 .L013pic_point:
 	popl	%ebp
-	leal	OPENSSL_ia32cap_P,%eax
+	leal	_GLOBAL_OFFSET_TABLE_+[.-.L013pic_point](%ebp),%eax
+	movl	OPENSSL_ia32cap_P@GOT(%eax),%eax
 	cmpl	$0,40(%esp)
 	leal	.LAES_Te-.L013pic_point(%ebp),%ebp
 	jne	.L014picked_te
diff --git a/crypto/bn/asm/x86-gf2m.S b/crypto/bn/asm/x86-gf2m.S
index f07843b..9403a5a 100644
--- a/crypto/bn/asm/x86-gf2m.S
+++ b/crypto/bn/asm/x86-gf2m.S
@@ -240,11 +240,15 @@
 .align	16
 bn_GF2m_mul_2x2:
 .L_bn_GF2m_mul_2x2_begin:
-	leal	OPENSSL_ia32cap_P,%edx
+	call	.L000PIC_me_up
+.L000PIC_me_up:
+	popl	%edx
+	leal	_GLOBAL_OFFSET_TABLE_+[.-.L000PIC_me_up](%edx),%edx
+	movl	OPENSSL_ia32cap_P@GOT(%edx),%edx
 	movl	(%edx),%eax
 	movl	4(%edx),%edx
 	testl	$8388608,%eax
-	jz	.L000ialu
+	jz	.L001ialu
 	pushl	%ebp
 	pushl	%ebx
 	pushl	%esi
@@ -279,7 +283,7 @@
 	emms
 	ret
 .align	16
-.L000ialu:
+.L001ialu:
 	pushl	%ebp
 	pushl	%ebx
 	pushl	%esi
diff --git a/crypto/des/asm/crypt586.S b/crypto/des/asm/crypt586.S
index 46c81c4..fb321ba 100644
--- a/crypto/des/asm/crypt586.S
+++ b/crypto/des/asm/crypt586.S
@@ -13,11 +13,15 @@
 
 	xorl	%edi,%edi
 	xorl	%esi,%esi
-	leal	DES_SPtrans,%edx
+	call	.L000PIC_me_up
+.L000PIC_me_up:
+	popl	%edx
+	leal	_GLOBAL_OFFSET_TABLE_+[.-.L000PIC_me_up](%edx),%edx
+	movl	DES_SPtrans@GOT(%edx),%edx
 	pushl	%edx
 	movl	28(%esp),%ebp
 	pushl	$25
-.L000start:
+.L001start:
 
 
 	movl	36(%esp),%eax
@@ -824,7 +828,7 @@
 	movl	%esi,%edi
 	movl	%eax,%esi
 	movl	%ebx,(%esp)
-	jnz	.L000start
+	jnz	.L001start
 
 
 	movl	28(%esp),%edx
diff --git a/import_openssl.sh b/import_openssl.sh
index e02e8c3..77fe198 100755
--- a/import_openssl.sh
+++ b/import_openssl.sh
@@ -149,21 +149,21 @@
   CC=true perl crypto/sha/asm/sha512-mips.pl o32   > crypto/sha/asm/sha256-mips.S
 
   # Generate x86 asm
-  perl crypto/aes/asm/aes-586.pl      elf  > crypto/aes/asm/aes-586.S
-  perl crypto/aes/asm/vpaes-x86.pl    elf  > crypto/aes/asm/vpaes-x86.S
-  perl crypto/aes/asm/aesni-x86.pl    elf  > crypto/aes/asm/aesni-x86.S
-  perl crypto/bn/asm/bn-586.pl        elf  > crypto/bn/asm/bn-586.S
-  perl crypto/bn/asm/co-586.pl        elf  > crypto/bn/asm/co-586.S
-  perl crypto/bn/asm/x86-mont.pl      elf  > crypto/bn/asm/x86-mont.S
-  perl crypto/bn/asm/x86-gf2m.pl      elf  > crypto/bn/asm/x86-gf2m.S
-  perl crypto/modes/asm/ghash-x86.pl  elf  > crypto/modes/asm/ghash-x86.S
-  perl crypto/sha/asm/sha1-586.pl     elf  > crypto/sha/asm/sha1-586.S
-  perl crypto/sha/asm/sha256-586.pl   elf  > crypto/sha/asm/sha256-586.S
-  perl crypto/sha/asm/sha512-586.pl   elf  > crypto/sha/asm/sha512-586.S
-  perl crypto/md5/asm/md5-586.pl      elf  > crypto/md5/asm/md5-586.S
-  perl crypto/des/asm/des-586.pl      elf  > crypto/des/asm/des-586.S
-  perl crypto/des/asm/crypt586.pl     elf  > crypto/des/asm/crypt586.S
-  perl crypto/bf/asm/bf-586.pl        elf  > crypto/bf/asm/bf-586.S
+  perl crypto/aes/asm/aes-586.pl      elf -fPIC  > crypto/aes/asm/aes-586.S
+  perl crypto/aes/asm/vpaes-x86.pl    elf -fPIC  > crypto/aes/asm/vpaes-x86.S
+  perl crypto/aes/asm/aesni-x86.pl    elf -fPIC  > crypto/aes/asm/aesni-x86.S
+  perl crypto/bn/asm/bn-586.pl        elf -fPIC  > crypto/bn/asm/bn-586.S
+  perl crypto/bn/asm/co-586.pl        elf -fPIC  > crypto/bn/asm/co-586.S
+  perl crypto/bn/asm/x86-mont.pl      elf -fPIC  > crypto/bn/asm/x86-mont.S
+  perl crypto/bn/asm/x86-gf2m.pl      elf -fPIC  > crypto/bn/asm/x86-gf2m.S
+  perl crypto/modes/asm/ghash-x86.pl  elf -fPIC  > crypto/modes/asm/ghash-x86.S
+  perl crypto/sha/asm/sha1-586.pl     elf -fPIC  > crypto/sha/asm/sha1-586.S
+  perl crypto/sha/asm/sha256-586.pl   elf -fPIC  > crypto/sha/asm/sha256-586.S
+  perl crypto/sha/asm/sha512-586.pl   elf -fPIC  > crypto/sha/asm/sha512-586.S
+  perl crypto/md5/asm/md5-586.pl      elf -fPIC  > crypto/md5/asm/md5-586.S
+  perl crypto/des/asm/des-586.pl      elf -fPIC  > crypto/des/asm/des-586.S
+  perl crypto/des/asm/crypt586.pl     elf -fPIC  > crypto/des/asm/crypt586.S
+  perl crypto/bf/asm/bf-586.pl        elf -fPIC  > crypto/bf/asm/bf-586.S
 
   # Setup android.testssl directory
   mkdir android.testssl