NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-sparc64/61072: sparc64 compat32 libcrypto has undefined symbols and cannot be loaded



>Number:         61072
>Category:       port-sparc64
>Synopsis:       sparc64 compat32 libcrypto has undefined symbols and cannot be loaded
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-sparc64-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Nov 25 05:50:00 +0000 2026
>Originator:     Showta Ishizaki
>Release:        NetBSD 11.1
>Organization:
>Environment:
NetBSD netbsd 11.1 NetBSD 11.1 (GENERIC) #0: Mon Nov  2 16:34:32 UTC 2026  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/sparc64/compile/GENERIC sparc64
>Description:
I was trying a change to libcrypto with cc -m32 on 11.1/sparc64, and a
small program would not link with the 32-bit libcrypto of the release.
If the linker is told to accept it, the program does not start.

/usr/lib/sparc/libcrypto.so.16.0 has undefined references to
des_t4_key_expand, des_t4_cbc_encrypt, des_t4_cbc_decrypt,
des_t4_ede3_cbc_encrypt, des_t4_ede3_cbc_decrypt and
__atomic_is_lock_free. 23 other libraries in /usr/lib/sparc need
libcrypto, libssl, libkrb5, libfetch and libarchive among them.

AES_ASM is defined for this build, so e_des.c and e_des3.c refer to the
T4 code, but arch/sparc/des.inc does not list dest4-sparcv9.S.
arch/sparc64/des.inc does, and the file is the same in both directories.

__atomic_is_lock_free comes from threads_pthread.c.
arch/sparc/crypto.inc defines BROKEN_CLANG_ATOMICS for it only if
MACHINE is sparc, which leaves out the compat build. libc has the
function on sparc but not in the compat32 one, see port-sparc64/58975.

The sparc release does not have the problem. The library built from
-current does.
>How-To-Repeat:
$ cat small.c
#include <stdio.h>
#include <openssl/evp.h>
int main(void){unsigned char d[64];unsigned n=0;
int r=EVP_Digest("abc",3,d,&n,EVP_sha256(),NULL);
printf("r=%d n=%u %02x%02x long=%zu\n",r,n,d[0],d[1],sizeof(long));return !(r==1&&d[0]==0xba);}
$ cc -m32 -o s32 small.c -lcrypto
ld: /usr/lib/../lib/sparc/libcrypto.so: undefined reference to `des_t4_ede3_cbc_decrypt'
ld: /usr/lib/../lib/sparc/libcrypto.so: undefined reference to `des_t4_ede3_cbc_encrypt'
ld: /usr/lib/../lib/sparc/libcrypto.so: undefined reference to `des_t4_key_expand'
ld: /usr/lib/../lib/sparc/libcrypto.so: undefined reference to `des_t4_cbc_encrypt'
ld: /usr/lib/../lib/sparc/libcrypto.so: undefined reference to `__atomic_is_lock_free'
ld: /usr/lib/../lib/sparc/libcrypto.so: undefined reference to `des_t4_cbc_decrypt'
$ cc -m32 -Wl,--allow-shlib-undefined -o s32 small.c -lcrypto
$ ./s32
/usr/lib/sparc/libcrypto.so.16: Undefined symbol "des_t4_ede3_cbc_decrypt" (symnum = 2483)
$ LD_BIND_NOW=1 ./s32
/usr/lib/sparc/libcrypto.so.16: Undefined PLT symbol "des_t4_key_expand" (symnum = 4340)
>Fix:
The diff builds dest4-sparcv9.S, and sets BROKEN_CLANG_ATOMICS without
the condition, as i386 and m68k do.

I cross-built the compat libcrypto from -current of November 24 with and
without it and ran both on 11.1/sparc64 under qemu. Without it small.c
fails as above. With it small.c links and runs, also with LD_BIND_NOW,
the SHA-2, MD5, SM3 and Poly1305 test vectors pass, and DES, 3DES and
AES in ECB and CBC mode give the same results as on amd64. qemu has no
CPU with the DES instructions, so the T4 code itself has not run. For
MACHINE=sparc the library comes out identical with and without it.

--- crypto/external/apache2/openssl/lib/libcrypto/arch/sparc/crypto.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/sparc/crypto.inc
@@ -12,8 +12,6 @@ AFLAGS.sparcv9a-mont.S+= -Wa,-Av9a
 AFLAGS.sparct4-mont.S+= -Wa,-Av9a
 AFLAGS.vis3-mont.S+= -Wa,-Av9a
 
-.if ${MACHINE} == "sparc"
 COPTS.threads_pthread.c += -DBROKEN_CLANG_ATOMICS       # no atomic 64 bit ops
-.endif
 
 .include "../../crypto.inc"
--- crypto/external/apache2/openssl/lib/libcrypto/arch/sparc/des.inc
+++ crypto/external/apache2/openssl/lib/libcrypto/arch/sparc/des.inc
@@ -2,7 +2,8 @@
 
 .if ${MACHINE} == "sparc64"
 .PATH.S: ${.PARSEDIR}
-DES_SRCS = des_enc-sparc.S fcrypt_b.c
+DES_SRCS = des_enc-sparc.S fcrypt_b.c dest4-sparcv9.S
+AFLAGS.dest4-sparcv9.S+= -Wa,-Av9
 CPPFLAGS+=	-DDES_UNROLL -DDES_PTR
 .else
 CPPFLAGS+=	-DDES_UNROLL




Home | Main Index | Thread Index | Old Index