summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Metzler <ametzler@bebt.de>2019-09-28 14:28:12 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2019-09-28 21:19:29 +0200
commit56b333df895475b202780add2e873c7cf5ade0d3 (patch)
treee8653c6900d6f49a2b1f1d825080fa7ed9ca445b
parent477d44b3a3afffd05b275b9d40e4e66c6b55d68c (diff)
downloadgnutls-56b333df895475b202780add2e873c7cf5ade0d3.tar.gz
Regenerate asm files with -fPIC
CRYPTOGAMS' perl-scripts can produce different output if -fPIC is passed as option. Set -fPIC for the same files as openssl does. Closes #818 Signed-off-by: Andreas Metzler <ametzler@bebt.de>
-rw-r--r--NEWS2
-rw-r--r--cfg.mk30
-rw-r--r--lib/accelerated/x86/elf/aesni-x86.s2
3 files changed, 27 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index 2a29f50649..7da09e7fd9 100644
--- a/NEWS
+++ b/NEWS
@@ -25,6 +25,8 @@ See the end for copying conditions.
** libgnutls: the server now selects the highest TLS protocol version,
if TLS 1.3 is enabled and the client advertises an older protocol version first (#837).
+** libgnutls: fix non-PIC assembly on i386 (#818).
+
** libgnutls: added support for GOST 28147-89 cipher in CNT (GOST counter) mode
and MAC generation based on GOST 28147-89 (IMIT). For description of the
modes see RFC 5830. S-Box is id-tc26-gost-28147-param-Z (TC26Z) defined in
diff --git a/cfg.mk b/cfg.mk
index ff79dbf2ed..1eddaac299 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -143,6 +143,12 @@ ASM_SOURCES_XXX := \
lib/accelerated/x86/XXX/aes-ssse3-x86.s \
lib/accelerated/x86/XXX/aes-ssse3-x86_64.s
+# CRYPTOGAMS' perl-scripts can produce different output if -fPIC
+# is passed as option. List the files that seem to need it:
+PL_NEEDS_FPIC := aesni-x86.pl aes-ssse3-x86.pl e_padlock-x86.pl \
+ ghash-x86.pl sha1-ssse3-x86.pl sha256-ssse3-x86.pl \
+ sha512-ssse3-x86.pl
+
ASM_SOURCES_ELF := $(subst XXX,elf,$(ASM_SOURCES_XXX))
ASM_SOURCES_COFF := $(subst XXX,coff,$(ASM_SOURCES_XXX))
ASM_SOURCES_MACOSX := $(subst XXX,macosx,$(ASM_SOURCES_XXX))
@@ -193,33 +199,43 @@ lib/accelerated/x86/files.mk: $(ASM_SOURCES_ELF)
# Appro's code
lib/accelerated/x86/elf/%.s: devel/perlasm/%.pl .submodule.stamp
- CC=gcc perl $< elf $@.tmp
+ CC=gcc perl $< elf \
+ $(if $(findstring $(<F),$(PL_NEEDS_FPIC)),-fPIC) \
+ $@.tmp
cat $<.license $@.tmp > $@ && rm -f $@.tmp
echo "" >> $@
echo ".section .note.GNU-stack,\"\",%progbits" >> $@
sed -i 's/OPENSSL_ia32cap_P/_gnutls_x86_cpuid_s/g' $@
lib/accelerated/x86/coff/%-x86.s: devel/perlasm/%-x86.pl .submodule.stamp
- CC=gcc perl $< coff $@.tmp
+ CC=gcc perl $< coff \
+ $(if $(findstring $(<F),$(PL_NEEDS_FPIC)),-fPIC) \
+ $@.tmp
cat $<.license $@.tmp > $@ && rm -f $@.tmp
echo "" >> $@
sed -i 's/OPENSSL_ia32cap_P/_gnutls_x86_cpuid_s/g' $@
lib/accelerated/x86/coff/%-x86_64.s: devel/perlasm/%-x86_64.pl .submodule.stamp
- CC=gcc perl $< mingw64 $@.tmp
+ CC=gcc perl $< mingw64 \
+ $(if $(findstring $(<F),$(PL_NEEDS_FPIC)),-fPIC) \
+ $@.tmp
cat $<.license $@.tmp > $@ && rm -f $@.tmp
echo "" >> $@
sed -i 's/OPENSSL_ia32cap_P/_gnutls_x86_cpuid_s/g' $@
lib/accelerated/x86/macosx/%.s: devel/perlasm/%.pl .submodule.stamp
- CC=gcc perl $< macosx $@.tmp
+ CC=gcc perl $< macosx \
+ $(if $(findstring $(<F),$(PL_NEEDS_FPIC)),-fPIC) \
+ $@.tmp
cat $<.license $@.tmp > $@ && rm -f $@.tmp
echo "" >> $@
sed -i 's/OPENSSL_ia32cap_P/_gnutls_x86_cpuid_s/g' $@
lib/accelerated/aarch64/elf/%.s: devel/perlasm/%.pl .submodule.stamp
rm -f $@tmp
- CC=aarch64-linux-gnu-gcc perl $< linux64 $@.tmp
+ CC=aarch64-linux-gnu-gcc perl $< linux64 \
+ $(if $(findstring $(<F),$(PL_NEEDS_FPIC)),-fPIC) \
+ $@.tmp
cat $@.tmp | /usr/bin/perl -ne '/^#(line)?\s*[0-9]+/ or print' > $@.tmp.S
echo "" >> $@.tmp.S
sed -i 's/OPENSSL_armcap_P/_gnutls_arm_cpuid_s/g' $@.tmp.S
@@ -231,7 +247,9 @@ lib/accelerated/aarch64/elf/%.s: devel/perlasm/%.pl .submodule.stamp
lib/accelerated/aarch64/macosx/%.s: devel/perlasm/%.pl .submodule.stamp
rm -f $@tmp
- CC=aarch64-linux-gnu-gcc perl $< ios64 $@.tmp
+ CC=aarch64-linux-gnu-gcc perl $< ios64 \
+ $(if $(findstring $(<F),$(PL_NEEDS_FPIC)),-fPIC) \
+ $@.tmp
cat $@.tmp | /usr/bin/perl -ne '/^#(line)?\s*[0-9]+/ or print' > $@.tmp.S
echo "" >> $@.tmp.S
sed -i 's/OPENSSL_armcap_P/_gnutls_arm_cpuid_s/g' $@.tmp.S
diff --git a/lib/accelerated/x86/elf/aesni-x86.s b/lib/accelerated/x86/elf/aesni-x86.s
index aaf0bab635..6e4860209f 100644
--- a/lib/accelerated/x86/elf/aesni-x86.s
+++ b/lib/accelerated/x86/elf/aesni-x86.s
@@ -2892,7 +2892,7 @@ _aesni_set_encrypt_key:
.L112pic:
popl %ebx
leal .Lkey_const-.L112pic(%ebx),%ebx
- leal _gnutls_x86_cpuid_s,%ebp
+ leal _gnutls_x86_cpuid_s-.Lkey_const(%ebx),%ebp
movups (%eax),%xmm0
xorps %xmm4,%xmm4
movl 4(%ebp),%ebp