git: 769c49de261f - main - openssl: export only the engine entry points

From: Gordon Tetlow <gordon_at_FreeBSD.org>
Date: Mon, 09 Nov 2026 05:41:16 UTC
The branch main has been updated by gordon:

URL: https://cgit.FreeBSD.org/src/commit/?id=769c49de261fbbd1293adab9188e5099516675cf

commit 769c49de261fbbd1293adab9188e5099516675cf
Author:     Gordon Tetlow <gordon@FreeBSD.org>
AuthorDate: 2026-11-09 05:39:08 +0000
Commit:     Gordon Tetlow <gordon@FreeBSD.org>
CommitDate: 2026-11-09 05:40:49 +0000

    openssl: export only the engine entry points
    
    Upstream links every dynamic engine with a version script,
    engines/<name>.ld, that exports bind_engine and v_check and makes
    everything else local.  FreeBSD's engines had no version script, so
    they exported every global symbol, including _init and _fini.
    loader_attic.so compiles its own copy of crypto/pem/pvkfmt.c and so
    also exported 21 of its functions; 14 of them (b2i_*, i2b_*) have the
    same names as public libcrypto functions.
    
    Add one Version.map for all engines, the same as upstream's, and use it
    from engines/Makefile.inc.
    
    The engines are loaded only with dlopen(), and libcrypto looks up only
    bind_engine and v_check, so hiding the other symbols does not affect
    any consumer.
    
    Tested via tinderbox: capi.so, devcrypto.so and loader_attic.so link
    with --no-undefined-version and export only bind_engine and v_check.
    devcrypto lists the same ciphers as before, and loader_attic loads and
    reads a PVK RSA key through "openssl storeutl -engine loader_attic".
    
    Reviewed by:            ngie
    MFC after:              1 week
    MFC to:                 stable/15
    Event:                  FreeBSD Vendor Summit 2026
    Differential Revision:  https://reviews.freebsd.org/D61273
---
 secure/lib/libcrypto/engines/Makefile.inc | 3 +++
 secure/lib/libcrypto/engines/Version.map  | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/secure/lib/libcrypto/engines/Makefile.inc b/secure/lib/libcrypto/engines/Makefile.inc
index 146c2f794eb6..b6188571f04c 100644
--- a/secure/lib/libcrypto/engines/Makefile.inc
+++ b/secure/lib/libcrypto/engines/Makefile.inc
@@ -3,6 +3,9 @@ LIB_PACKAGE=
 
 SHLIBDIR=	${LIBDIR}/engines-3
 
+# Export only the dynamic-engine entry points, as upstream engines/*.ld do.
+VERSION_MAP=	${.CURDIR:H}/Version.map
+
 LCRYPTO_SRC=	${SRCTOP}/crypto/openssl
 
 CFLAGS+=	-I${LCRYPTO_SRC}/engines
diff --git a/secure/lib/libcrypto/engines/Version.map b/secure/lib/libcrypto/engines/Version.map
new file mode 100644
index 000000000000..7a26b813827b
--- /dev/null
+++ b/secure/lib/libcrypto/engines/Version.map
@@ -0,0 +1,6 @@
+{
+    global:
+        bind_engine;
+        v_check;
+    local: *;
+};