]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Add ELF note for openssl library
authorEmil Velikov <emil.l.velikov@gmail.com>
Sun, 8 Feb 2026 12:21:23 +0000 (12:21 +0000)
committerLucas De Marchi <demarchi@kernel.org>
Thu, 7 May 2026 05:57:56 +0000 (00:57 -0500)
Follow the new spec for ELF notes as detailed in
https://systemd.io/ELF_PACKAGE_METADATA/.

We can copy mostly verbatim the macros from systemd codebase.

Example output:

$ meson setup --native-file build-dev.ini -Ddlopen=openssl build
...
    dlopen           : openssl

    features         : +ZSTD +XZ +ZLIB +OPENSSL

$ dlopen-notes.py build/libkmod.so.2
# build/libkmod.so.2
[
  {
    "feature": "openssl",
    "description": "Support for reading module signatures",
    "priority": "suggested",
    "soname": [
      "libcrypto.so.3"
    ]
  }
]

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/420
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
libkmod/libkmod-signature.c

index 6bf25db5ae1eb9bb6ea881ef279d74d68ab3983b..04a29853f9eba3e374601de20d20b5c273f8de98 100644 (file)
@@ -15,6 +15,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <shared/elf-note.h>
 #include <shared/missing.h>
 #include <shared/util.h>
 
@@ -146,12 +147,16 @@ DL_SYMBOL_TABLE(DECLARE_SYM)
 
 static int dlopen_crypto(void)
 {
+#if !DLSYM_LOCALLY_ENABLED
+       return 0;
+#else
        static void *dl;
 
-       if (!DLSYM_LOCALLY_ENABLED)
-               return 0;
+       ELF_NOTE_DLOPEN("openssl", "Support for reading module signatures",
+                       ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED, "libcrypto.so.3");
 
        return dlsym_many(&dl, "libcrypto.so.3", DL_SYMBOL_TABLE(DLSYM_ARG) NULL);
+#endif
 }
 
 static const char *x509_name_to_str(X509_NAME *name)