Fix aarch64 static linking into shared libraries (see issue #10842 and pull request...
authorRomain Geissler <romain.geissler@amadeus.com>
Fri, 2 Oct 2020 00:07:32 +0000 (00:07 +0000)
committerPauli <paul.dale@oracle.com>
Thu, 22 Oct 2020 02:16:49 +0000 (12:16 +1000)
This tries to fix the following link errors on aarch64 when using OpenSSL
3.0.0 alpha 6, compiling it with "no-shared" and -fPIC in CFLAGS, then
trying to use the resulting OpenSSL static libraries in the build of
elfutils, which embed libcrypto.a into libdebuginfo.so, which hides all
symbols (except the libdebuginfod ones) by default:

/opt/1A/toolchain/aarch64-v4.0.86/lib/gcc/aarch64-1a-linux-gnu/8.4.1/../../../../aarch64-1a-linux-gnu/bin/ld: /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-sha1-armv8.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-sha1-armv8.o): in function `sha1_block_data_order':
(.text+0x0): dangerous relocation: unsupported relocation
/opt/1A/toolchain/aarch64-v4.0.86/lib/gcc/aarch64-1a-linux-gnu/8.4.1/../../../../aarch64-1a-linux-gnu/bin/ld: /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-chacha-armv8.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-chacha-armv8.o): in function `ChaCha20_ctr32':
(.text+0x6c): dangerous relocation: unsupported relocation
/opt/1A/toolchain/aarch64-v4.0.86/lib/gcc/aarch64-1a-linux-gnu/8.4.1/../../../../aarch64-1a-linux-gnu/bin/ld: /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-sha256-armv8.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-sha256-armv8.o): in function `sha256_block_data_order':
(.text+0x0): dangerous relocation: unsupported relocation
/opt/1A/toolchain/aarch64-v4.0.86/lib/gcc/aarch64-1a-linux-gnu/8.4.1/../../../../aarch64-1a-linux-gnu/bin/ld: /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-sha512-armv8.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-sha512-armv8.o): in function `sha512_block_data_order':
(.text+0x0): dangerous relocation: unsupported relocation
/opt/1A/toolchain/aarch64-v4.0.86/lib/gcc/aarch64-1a-linux-gnu/8.4.1/../../../../aarch64-1a-linux-gnu/bin/ld: /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-poly1305-armv8.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-poly1305-armv8.o): in function `poly1305_init':
(.text+0x14): dangerous relocation: unsupported relocation
/workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-poly1305-armv8.o): in function `poly1305_emit_neon':
(.text+0x8e4): relocation truncated to fit: R_AARCH64_CONDBR19 against symbol `poly1305_emit' defined in .text section in /workdir/build/build-pack/build-pack-temporary-static-dependencies/install/lib/libcrypto.a(libcrypto-lib-poly1305-armv8.o)

In poly1305-armv8.pl, hide symbols the same way they are hidden in poly1305-x86_64.pl.

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13056)

crypto/chacha/asm/chacha-armv8.pl
crypto/poly1305/asm/poly1305-armv8.pl
crypto/sha/asm/sha1-armv8.pl
crypto/sha/asm/sha512-armv8.pl

index 41503f03f0476c5808e2ef9981bda59a215b6937..dcdc4a04e367f90b4cf21256b0f1d0da40ce8ee2 100755 (executable)
@@ -135,6 +135,7 @@ $code.=<<___;
 #ifndef        __KERNEL__
 # include "arm_arch.h"
 .extern        OPENSSL_armcap_P
+.hidden        OPENSSL_armcap_P
 #endif
 
 .text
index d2d31fcc273185e3eba8fd0460237b3650bfc419..d2d875ad6c7eaef265caee0346b9eecc72b8cacb 100755 (executable)
@@ -61,10 +61,14 @@ $code.=<<___;
 
 // forward "declarations" are required for Apple
 .extern        OPENSSL_armcap_P
+.hidden        OPENSSL_armcap_P
+.globl poly1305_init
+.hidden        poly1305_init
 .globl poly1305_blocks
+.hidden        poly1305_blocks
 .globl poly1305_emit
+.hidden        poly1305_emit
 
-.globl poly1305_init
 .type  poly1305_init,%function
 .align 5
 poly1305_init:
index 97ffac1fb99882b06c7b683a7405638ffad9deae..cdea8845af85a57df33a3f6b60a1f29684e5d7df 100644 (file)
@@ -178,6 +178,7 @@ $code.=<<___;
 #ifndef        __KERNEL__
 # include "arm_arch.h"
 .extern OPENSSL_armcap_P
+.hidden OPENSSL_armcap_P
 #endif
 
 .text
@@ -323,9 +324,6 @@ $code.=<<___;
 .long  0xca62c1d6,0xca62c1d6,0xca62c1d6,0xca62c1d6     //K_60_79
 .asciz "SHA1 block transform for ARMv8, CRYPTOGAMS by <appro\@openssl.org>"
 .align 2
-#if !defined(__KERNELL__) && !defined(_WIN64)
-.comm  OPENSSL_armcap_P,4,4
-#endif
 ___
 }}}
 
index 9c15496eb0a1881702e1611f2b2b03f596f463e1..6bcff0b7d3f351e3c6d931e5c4e84a45f0fd8480 100644 (file)
@@ -193,6 +193,7 @@ $code.=<<___;
 #ifndef        __KERNEL__
 # include "arm_arch.h"
 .extern        OPENSSL_armcap_P
+.hidden        OPENSSL_armcap_P
 #endif
 
 .text
@@ -829,12 +830,6 @@ $code.=<<___;
 ___
 }
 
-$code.=<<___;
-#if !defined(__KERNEL__) && !defined(_WIN64)
-.comm  OPENSSL_armcap_P,4,4
-#endif
-___
-
 {   my  %opcode = (
        "sha256h"       => 0x5e004000,  "sha256h2"      => 0x5e005000,
        "sha256su0"     => 0x5e282800,  "sha256su1"     => 0x5e006000   );