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>
#include <stdlib.h>
#include <string.h>
+#include <shared/elf-note.h>
#include <shared/missing.h>
#include <shared/util.h>
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)