]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Regenerate asm files with -fPIC
authorAndreas Metzler <ametzler@bebt.de>
Sat, 28 Sep 2019 12:28:12 +0000 (14:28 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 28 Sep 2019 19:19:29 +0000 (21:19 +0200)
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>
NEWS
cfg.mk
lib/accelerated/x86/elf/aesni-x86.s

diff --git a/NEWS b/NEWS
index 2a29f50649df0c627022a4f0f675d821a6286e6b..7da09e7fd948e2d58e2fcb7e6681dd1304ef1e5c 100644 (file)
--- 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 ff79dbf2ed2f91e839f3919b1ca297e5a7ac7c89..1eddaac299294a1366c4df8114c21f89d92c10fa 100644 (file)
--- 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
index aaf0bab6350344bba9d4b733187fdff5ffc3113a..6e4860209f8bf30297e1ca4140301caabb489ab2 100644 (file)
@@ -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