]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dlopen: introduce _dlopen_loader_ macro to prevent inlining and cloning
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 6 Jul 2026 22:51:50 +0000 (07:51 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 10 Jul 2026 07:35:19 +0000 (16:35 +0900)
When compiler optimization or LTO (Link Time Optimization) is enabled,
dlopen helper functions (such as dlopen_libfoo()) can be aggressively
inlined into their callers or cloned for specific call sites.

While this is beneficial for production builds, it alters or completely
removes the original function symbols from the final executable.
Consequently, this breaks the test (to be added in this series) that
checks whether the dlopen_libfoo() function corresponding to a dlopen
ELF note is actually called.

To resolve this, introduce the `_dlopen_loader_` macro. Under developer
builds, it applies the `_noclone_` and `_noinline_` attributes to guarantee
that helper symbols remain intact and discoverable by the test suite. In
production builds, the macro evaluates to nothing, allowing full compiler
optimization to proceed unimpeded.

45 files changed:
src/basic/compress.c
src/basic/compress.h
src/basic/dlopen-note.h
src/fundamental/macro.h
src/locale/xkbcommon-util.c
src/shared/acl-util.h
src/shared/apparmor-util.c
src/shared/apparmor-util.h
src/shared/blkid-util.h
src/shared/bpf-util.h
src/shared/crypto-util.h
src/shared/cryptsetup-util.h
src/shared/curl-util.h
src/shared/elf-util.c
src/shared/elf-util.h
src/shared/fdisk-util.h
src/shared/gnutls-util.c
src/shared/gnutls-util.h
src/shared/idn-util.h
src/shared/libarchive-util.h
src/shared/libaudit-util.c
src/shared/libaudit-util.h
src/shared/libcrypt-util.c
src/shared/libcrypt-util.h
src/shared/libfido2-util.c
src/shared/libfido2-util.h
src/shared/libmount-util.h
src/shared/microhttpd-util.h
src/shared/module-util.h
src/shared/pam-util.h
src/shared/password-quality-util-passwdqc.c
src/shared/password-quality-util-passwdqc.h
src/shared/password-quality-util-pwquality.c
src/shared/password-quality-util-pwquality.h
src/shared/pcre2-util.c
src/shared/pcre2-util.h
src/shared/pkcs11-util.c
src/shared/pkcs11-util.h
src/shared/qrcode-util.c
src/shared/qrcode-util.h
src/shared/seccomp-util.h
src/shared/selinux-util.h
src/shared/ssl-util.h
src/shared/tpm2-util.c
src/shared/tpm2-util.h

index 350c612eae7b66241fb9ae7213736c06e15d1dd9..5936a13f8e80eef3bda5e52951545e80a69aaf8b 100644 (file)
@@ -47,7 +47,6 @@
 #include "bitfield.h"
 #include "compress.h"
 #include "dlfcn-util.h"
-#include "dlopen-note.h"
 #include "io-util.h"
 #include "log.h"
 #include "string-table.h"
index e7beb330cb4490416fc75b4ea4cf077ac276d29a..52fdf3aa27292030fb1cef12d81615617981e297 100644 (file)
@@ -2,6 +2,7 @@
 #pragma once
 
 #include "basic-forward.h"
+#include "dlopen-note.h"
 
 typedef enum Compression {
         COMPRESSION_NONE,
@@ -80,11 +81,11 @@ int compress_stream(Compression type, int fdf, int fdt, uint64_t max_bytes, uint
 int decompress_stream(Compression type, int fdf, int fdt, uint64_t max_bytes);
 int decompress_stream_by_filename(const char *filename, int fdf, int fdt, uint64_t max_bytes);
 
-int dlopen_xz(int log_level);
-int dlopen_lz4(int log_level);
-int dlopen_zstd(int log_level);
-int dlopen_zlib(int log_level);
-int dlopen_bzip2(int log_level);
+int dlopen_xz(int log_level) _dlopen_loader_;
+int dlopen_lz4(int log_level) _dlopen_loader_;
+int dlopen_zstd(int log_level) _dlopen_loader_;
+int dlopen_zlib(int log_level) _dlopen_loader_;
+int dlopen_bzip2(int log_level) _dlopen_loader_;
 
 static inline const char* default_compression_extension(void) {
         return compression_extension_to_string(DEFAULT_COMPRESSION) ?: "";
index 302dd0999a0a99d96b552f9e3778888ba9160968..41661939a1fab34511ba68b7bd62b6a7efb098ae 100644 (file)
@@ -6,6 +6,16 @@
 #include "basic-forward.h"
 #include "strv.h"
 
+/* Prevent dlopen helper functions (e.g., dlopen_libfoo()) from being inlined or cloned by the compiler/LTO.
+ * This ensures that their specific symbols remain intact in the final executable, allowing the developer
+ * test utility to verify that the functions corresponding to the dlopen ELF notes are actually invoked.
+ * This is restricted to BUILD_MODE_DEVELOPER to avoid degrading production performance. */
+#if BUILD_MODE_DEVELOPER
+#  define _dlopen_loader_ _noclone_ _noinline_
+#else
+#  define _dlopen_loader_
+#endif
+
 /* Avoid invalid priority. */
 #define _DLOPEN_CHECK_PRIORITY_required    1
 #define _DLOPEN_CHECK_PRIORITY_recommended 1
index 12f2aa81dcd8347e4744c6dfe3908bbea2e37cdd..98d43ced317eb3327e5ca046f98dfd8989de5c3e 100644 (file)
 #define _hidden_ __attribute__((__visibility__("hidden")))
 #define _likely_(x) (__builtin_expect(!!(x), 1))
 #define _malloc_ __attribute__((__malloc__))
+#ifdef __clang__
+#  define _noclone_
+#else
+#  define _noclone_ __attribute__((noclone))
+#endif
 #define _noinline_ __attribute__((noinline))
 #define _noreturn_ _Noreturn
 #define _packed_ __attribute__((__packed__))
index 55ff67588e9c9da9b44a1620c86e587d2f272b8d..1f21ba5a06820dddae46362a53de2ec2d1d1e572 100644 (file)
@@ -13,6 +13,7 @@ DLSYM_PROTOTYPE(xkb_context_set_log_fn) = NULL;
 DLSYM_PROTOTYPE(xkb_keymap_new_from_names) = NULL;
 DLSYM_PROTOTYPE(xkb_keymap_unref) = NULL;
 
+_dlopen_loader_
 static int dlopen_xkbcommon(int log_level) {
         static void *xkbcommon_dl = NULL;
 
index c06900008d78f988b08b7908df6d6ea609d376d2..6c29e85135d159efcfa3472deb16e5256175e99d 100644 (file)
@@ -97,7 +97,7 @@ static inline int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask) {
 }
 #endif
 
-int dlopen_libacl(int log_level);
+int dlopen_libacl(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBACL(log_level, priority)                              \
         ({                                                              \
index a2b3179c90e33699649149e61a567b036a3e9f0d..dce21d1e69b5362456b080760da4163e7b436e8d 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "apparmor-util.h"
-#include "dlopen-note.h"
 #include "log.h"
 
 #if HAVE_APPARMOR
index 2d47a341cb9be160cb4533346ff0e5f4e0e1d829..69e937eade3153092189cc9292e80725cf973cb3 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
 #if HAVE_APPARMOR
@@ -30,4 +31,4 @@ static inline bool mac_apparmor_use(void) {
 }
 #endif
 
-int dlopen_libapparmor(int log_level);
+int dlopen_libapparmor(int log_level) _dlopen_loader_;
index 91f6e9c8c29b51eb410c7526f99cd49229c4e5ef..5457fbc28c5c6f3e85cc5ff2ff080dcc5fccae39 100644 (file)
@@ -69,7 +69,7 @@ int blkid_probe_lookup_value_id128(blkid_probe b, const char *field, sd_id128_t
 int blkid_probe_lookup_value_u64(blkid_probe b, const char *field, uint64_t *ret);
 #endif
 
-int dlopen_libblkid(int log_level);
+int dlopen_libblkid(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBBLKID(log_level, priority)                            \
         ({                                                              \
index 88ef204af0ec9e5441d78d71b9cb500135f92f9b..70c7fde3c0588da0dbc26382c7d5c568f3470275 100644 (file)
@@ -94,7 +94,7 @@ static inline int compat_bpf_map_create(
 int bpf_get_error_translated(const void *ptr);
 #endif
 
-int dlopen_bpf(int log_level);
+int dlopen_bpf(int log_level) _dlopen_loader_;
 
 #define DLOPEN_BPF(log_level, priority)                                 \
         ({                                                              \
index f4bf7ed49ed37df310dbd6d37fabde263952e41f..ebf36e2df035d4e4a3b68bc87b987b3ad42afbfb 100644 (file)
@@ -446,7 +446,7 @@ OpenSSLAskPasswordUI* openssl_ask_password_ui_free(OpenSSLAskPasswordUI *ui);
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(OpenSSLAskPasswordUI*, openssl_ask_password_ui_free, NULL);
 #endif
 
-int dlopen_libcrypto(int log_level);
+int dlopen_libcrypto(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBCRYPTO(log_level, priority)                           \
         ({                                                              \
index b1eb3b724e34c0df8d59ef5b3d64062d3855dd29..959f696ca0861ae4c0f4956c0b42955e10cfcbfc 100644 (file)
@@ -99,7 +99,7 @@ int cryptsetup_get_volume_key_id(struct crypt_device *cd, const char *volume_nam
                                  size_t volume_key_size,  char **ret);
 #endif
 
-int dlopen_cryptsetup(int log_level);
+int dlopen_cryptsetup(int log_level) _dlopen_loader_;
 
 #define DLOPEN_CRYPTSETUP(log_level, priority)                          \
         ({                                                              \
index 20f54aae59d92b210d4cc7ec381cf9bbc236dad3..d76f5128eec6829f7831e0af91e7abdb03e1c4cd 100644 (file)
@@ -77,7 +77,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(CURL*, sym_curl_easy_cleanup, curl_easy_
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct curl_slist*, sym_curl_slist_free_all, curl_slist_free_allp, NULL);
 #endif
 
-int dlopen_curl(int log_level);
+int dlopen_curl(int log_level) _dlopen_loader_;
 
 #define DLOPEN_CURL(log_level, priority)                                \
         ({                                                              \
index 9a926e49ed3ee0cde5569cbde8fc270c444ecadd..96e917dee0d314ed2aa526c44317f7476505915d 100644 (file)
@@ -17,7 +17,6 @@
 #include "alloc-util.h"
 #include "coredump-util.h"
 #include "dlfcn-util.h"
-#include "dlopen-note.h"
 #include "elf-util.h"
 #include "errno-util.h"
 #include "escape.h"
index 7ccbec56c6461536780aa2952ba778a371a35a83..4092cdf3033046e6a5722884f4a08361a932edcd 100644 (file)
@@ -1,10 +1,11 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
-int dlopen_dw(int log_level);
-int dlopen_elf(int log_level);
+int dlopen_dw(int log_level) _dlopen_loader_;
+int dlopen_elf(int log_level) _dlopen_loader_;
 
 bool dlopen_dw_has_dwfl_set_sysroot(void);
 
index c34cde1a41e7ec4504fc3d546f447905cc378b58..aa1e188dba4a6b9bf371a6ea7ad48fe1cc2e1863 100644 (file)
@@ -89,7 +89,7 @@ int fdisk_partition_get_attrs_as_uint64(struct fdisk_partition *pa, uint64_t *re
 int fdisk_partition_set_attrs_as_uint64(struct fdisk_partition *pa, uint64_t flags);
 #endif
 
-int dlopen_fdisk(int log_level);
+int dlopen_fdisk(int log_level) _dlopen_loader_;
 
 #define DLOPEN_FDISK(log_level, priority)                               \
         ({                                                              \
index 96460f1e02dfec64b10a5fa77066b2c2a47b2f21..71e360e4077d548b54af940f825a5ba1eb6a3a0b 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include "dlopen-note.h"
 #include "gnutls-util.h"
 #include "log.h"                /* IWYU pragma: keep */
 
index dd0f1d55acb3e136085267ce729639339d2972aa..721ae7bf00bc6f6feee1a95646b53c314aee7d9b 100644 (file)
@@ -1,9 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
-int dlopen_gnutls(int log_level);
+int dlopen_gnutls(int log_level) _dlopen_loader_;
 
 #if HAVE_GNUTLS
 #  ifndef SYSTEMD_CFLAGS_MARKER_LIBGNUTLS
index cf7e8a861789e9d752ff179ccf6a68136f930163..c143317ebfdbc1630d825ec2a012f52a136f1070 100644 (file)
@@ -18,7 +18,7 @@ extern const char *(*sym_idn2_strerror)(int rc) _const_;
 extern DLSYM_PROTOTYPE(idn2_to_unicode_8z8z);
 #endif
 
-int dlopen_idn(int log_level);
+int dlopen_idn(int log_level) _dlopen_loader_;
 
 #define DLOPEN_IDN(log_level, priority)                                 \
         ({                                                              \
index 775ede55b978a8cb41e9b08bf4cae5fe58dde28f..fca7ef206b4d7505038369f5fc936c532848940b 100644 (file)
@@ -85,7 +85,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct archive*, sym_archive_write_free,
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct archive*, sym_archive_read_free, archive_read_freep, NULL);
 #endif
 
-int dlopen_libarchive(int log_level);
+int dlopen_libarchive(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBARCHIVE(log_level, priority)                          \
         ({                                                              \
index 481eda7294e72ebfc1c0e5df55726ea1c6c441f7..1a1975e8038e60df85dce4db09a7095887e833e7 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/netlink.h>
 #include <sys/socket.h>
 
-#include "dlopen-note.h"
 #include "errno-util.h"
 #include "fd-util.h"
 #include "iovec-util.h"
index d16e25df671ba852f22aeccfbfe96a84f7424e4c..d2e827d4796836f4c241a1006b6abdcc2b94b057 100644 (file)
@@ -1,9 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
-int dlopen_libaudit(int log_level);
+int dlopen_libaudit(int log_level) _dlopen_loader_;
 
 #if HAVE_AUDIT
 #  ifndef SYSTEMD_CFLAGS_MARKER_LIBAUDIT
index 0a72e4e25a2283f9785564095e2368482be10e9f..17a2ad746bae2625efae8c5003c77bb18209c725 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "alloc-util.h"
 #include "dlfcn-util.h"
-#include "dlopen-note.h"
 #include "errno-util.h"
 #include "libcrypt-util.h"
 #include "log.h"
index 5c469b662cf02b15acb1693090b81c4280c8378b..56e39d26a1f6427ee2fbb9b8226569ccaef029f6 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
 #if HAVE_LIBCRYPT
@@ -16,6 +17,6 @@ static inline int hash_password(const char *password, char **ret) {
 }
 #endif
 
-int dlopen_libcrypt(int log_level);
+int dlopen_libcrypt(int log_level) _dlopen_loader_;
 
 bool looks_like_hashed_password(const char *s);
index 0276e639533873246e284a23d20708f214a040c4..3824c06bad71f440f568a16c58c8beb51f0e4968 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include "dlopen-note.h"
 #include "libfido2-util.h"
 #include "log.h"
 
index 82705a7f23dd7970cc5c39d556c43ab87de55444..d1b90066dfc6d898cadcbf4c8b83eb82a00c3ebe 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
 #define FIDO2_SALT_SIZE 32U
@@ -16,7 +17,7 @@ typedef enum Fido2EnrollFlags {
         _FIDO2ENROLL_TYPE_INVALID = -EINVAL,
 } Fido2EnrollFlags;
 
-int dlopen_libfido2(int log_level);
+int dlopen_libfido2(int log_level) _dlopen_loader_;
 
 #if HAVE_LIBFIDO2
 #ifndef SYSTEMD_CFLAGS_MARKER_LIBFIDO2
index 20195a13c8b8dc642d2e7319e80248df91c68df2..309798ac0ae67f4f290aec77f4dfbb6f221e8eb4 100644 (file)
@@ -88,7 +88,7 @@ static inline void* sym_mnt_unref_monitor(struct libmnt_monitor *p) {
 
 #endif
 
-int dlopen_libmount(int log_level);
+int dlopen_libmount(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBMOUNT(log_level, priority)                            \
         ({                                                              \
index 524d73b8a2532a64bd4183cceae4edb4ce5d94b7..7b777e2f33c681160602f3917bc0edd57c407cf4 100644 (file)
@@ -137,7 +137,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct MHD_Daemon*, sym_MHD_stop_daemon,
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(struct MHD_Response*, sym_MHD_destroy_response, MHD_destroy_responsep, NULL);
 #endif
 
-int dlopen_microhttpd(int log_level);
+int dlopen_microhttpd(int log_level) _dlopen_loader_;
 
 #define DLOPEN_MICROHTTPD(log_level, priority)                          \
         ({                                                              \
index 59b13d01cfceabbc91203a3f701d3cd2be7ead6c..c315fdaa167e26b6658e506bbbbe168619689d48 100644 (file)
@@ -53,7 +53,7 @@ static inline int module_load_and_warn(struct kmod_ctx *ctx, const char *module,
 
 #endif
 
-int dlopen_libkmod(int log_level);
+int dlopen_libkmod(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBKMOD(log_level, priority)                             \
         ({                                                              \
index 5f23667102db99364aee9b3f0976cf43c4165a67..3f1d765a33602b7f95516059f367d3b08cd7290f 100644 (file)
@@ -110,7 +110,7 @@ int pam_prompt_graceful(pam_handle_t *pamh, int style, char **ret_response, cons
 int pam_putenv_assign(pam_handle_t *pamh, const char *name, const char *value);
 #endif
 
-int dlopen_libpam(int log_level);
+int dlopen_libpam(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBPAM(log_level, priority)                              \
         ({                                                              \
index 15d95b76de0c9ee49ece9fa01b54685a4593be1f..0b9beaa5080d0883f133f10cd4f2eab40c7a8a2c 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include "dlopen-note.h"
 #include "errno-util.h"          /* IWYU pragma: keep */
 #include "log.h"                 /* IWYU pragma: keep */
 #include "password-quality-util-passwdqc.h"
index 2ae00aa620b8625e8ae9528d84e4d56fd16a2fc3..7c9d9e456f02e97de3898259044ca92f4f673164 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
 #if HAVE_PASSWDQC
@@ -8,4 +9,4 @@ int suggest_passwords(void);
 int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
 #endif
 
-int dlopen_passwdqc(int log_level);
+int dlopen_passwdqc(int log_level) _dlopen_loader_;
index e045a43a77c00c322b3bff6d679ea01fd63a816c..202b9d5009cc0b272c3279f7afd0944421ddb38b 100644 (file)
@@ -1,6 +1,5 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
-#include "dlopen-note.h"
 #include "errno-util.h"
 #include "log.h"
 #include "password-quality-util-pwquality.h"
index 468734f590b1773e042bdc062c6e82fe3a041d9d..6499b54ee1ba5abc8e745c9e33a41566a6700ce7 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
 #if HAVE_PWQUALITY
@@ -8,4 +9,4 @@ int suggest_passwords(void);
 int check_password_quality(const char *password, const char *old, const char *username, char **ret_error);
 #endif
 
-int dlopen_pwquality(int log_level);
+int dlopen_pwquality(int log_level) _dlopen_loader_;
index 0523612bd9baccd9fa22d1c82741974538f44dbd..29249a89bd57d6e691189506ca95fee404437504 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include "dlfcn-util.h"
-#include "dlopen-note.h"
 #include "hash-funcs.h"
 #include "log.h"
 #include "pcre2-util.h"
index 6b24dc49824e03806690c3db57d166f3dacbe261..f2691e28e097b42fcfc634cf4f5242b78e960f90 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
 #if HAVE_PCRE2
@@ -47,4 +48,4 @@ typedef enum PatternCompileCase {
 int pattern_compile_and_log(const char *pattern, PatternCompileCase case_, pcre2_code **ret);
 int pattern_matches_and_log(pcre2_code *compiled_pattern, const char *message, size_t size, size_t *ret_ovec);
 
-int dlopen_pcre2(int log_level);
+int dlopen_pcre2(int log_level) _dlopen_loader_;
index a9bf1e5913f70a71144da7675fce741c6ac31c4c..88cdffa4b6128d0680badc0bb5f078f07a8ed062 100644 (file)
@@ -4,7 +4,6 @@
 #include "ask-password-api.h"
 #include "crypto-util.h"
 #include "dlfcn-util.h"
-#include "dlopen-note.h"
 #include "env-util.h"
 #include "escape.h"
 #include "format-table.h"
index 141fd29c338bebb409e02c0362fb8caa0c39ccaa..5ccea4a6c3cd30adc11a48156d45ef4aaf443633 100644 (file)
@@ -11,6 +11,7 @@
 
 #include "ask-password-api.h"
 #include "dlfcn-util.h"
+#include "dlopen-note.h"
 #include "pkcs11-padding.h"
 #include "shared-forward.h"
 
@@ -107,7 +108,7 @@ int pkcs11_crypt_device_callback(
 
 #endif
 
-int dlopen_p11kit(int log_level);
+int dlopen_p11kit(int log_level) _dlopen_loader_;
 
 typedef struct {
         const char *friendly_name;
index 34755ca41fc3ee92c29f974b6b692a8029d7236a..a890124bcec0af5cb16a746650cce9d57d50d2e6 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "ansi-color.h"
 #include "dlfcn-util.h"
-#include "dlopen-note.h"
 #include "locale-util.h"
 #include "log.h"
 #include "strv.h"
index 667ff8e3ff7cc61bd1d9fadbb8e2055f6c558287..5961aa7e47a0cb48f97b51d4e6ec62f006cc0c55 100644 (file)
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#include "dlopen-note.h"
 #include "shared-forward.h"
 
 int print_qrcode_full(
@@ -13,7 +14,7 @@ int print_qrcode_full(
                 unsigned tty_height,
                 bool check_tty);
 
-int dlopen_qrencode(int log_level);
+int dlopen_qrencode(int log_level) _dlopen_loader_;
 
 static inline int print_qrcode(FILE *out, const char *header, const char *string) {
         return print_qrcode_full(out, header, string, UINT_MAX, UINT_MAX, UINT_MAX, UINT_MAX, true);
index 91e6bc886e556f3276970abcccc057f40f13954a..dd692ecfd73026cdb0f0910705079f1481c76ed3 100644 (file)
@@ -169,7 +169,7 @@ static inline bool is_seccomp_available(void) {
 
 #endif
 
-int dlopen_libseccomp(int log_level);
+int dlopen_libseccomp(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBSECCOMP(log_level, priority)                          \
         ({                                                              \
index 5c8181131e8bb31add84838e561b1b2328eb6607..747ad951561572e96e24adcc3d005c31f2333263 100644 (file)
@@ -63,7 +63,7 @@ static inline void freeconp(char **p) {
 
 #endif
 
-int dlopen_libselinux(int log_level);
+int dlopen_libselinux(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBSELINUX(log_level, priority)                          \
         ({                                                              \
index 8d60b16a1e715cd42a429e1539284fb69f89a377..156bda77b8cd65d54937f8bedc5c67f4f888bf5a 100644 (file)
@@ -47,7 +47,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(SSL*, sym_SSL_free, SSL_freep, NULL);
 DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(SSL_CTX*, sym_SSL_CTX_free, SSL_CTX_freep, NULL);
 #endif
 
-int dlopen_libssl(int log_level);
+int dlopen_libssl(int log_level) _dlopen_loader_;
 
 #define DLOPEN_LIBSSL(log_level, priority)                              \
         ({                                                              \
index 854d7fc4c5548e0ac3bc2a6982079e711488df11..788b153c5abe7b4ff41cb06e6e53ec1f20330b6d 100644 (file)
@@ -166,6 +166,7 @@ static DLSYM_PROTOTYPE(Tss2_MU_UINT32_Marshal) = NULL;
 
 static DLSYM_PROTOTYPE(Tss2_RC_Decode) = NULL;
 
+_dlopen_loader_
 static int dlopen_tpm2_esys(int log_level) {
         static void *libtss2_esys_dl = NULL;
         int r;
@@ -229,6 +230,7 @@ static int dlopen_tpm2_esys(int log_level) {
         return 0;
 }
 
+_dlopen_loader_
 static int dlopen_tpm2_rc(int log_level) {
         static void *libtss2_rc_dl = NULL;
 
@@ -239,6 +241,7 @@ static int dlopen_tpm2_rc(int log_level) {
                         DLSYM_ARG(Tss2_RC_Decode));
 }
 
+_dlopen_loader_
 static int dlopen_tpm2_mu(int log_level) {
         static void *libtss2_mu_dl = NULL;
 
@@ -268,6 +271,7 @@ static int dlopen_tpm2_mu(int log_level) {
                         DLSYM_ARG(Tss2_MU_UINT32_Marshal));
 }
 
+_dlopen_loader_
 static int dlopen_tpm2_tcti_device(int log_level) {
         static void *libtss2_tcti_device_dl = NULL;
 
index 63c449a31aa73a7219d74ea84bf1258133df51d3..4d2420ba03c2d17695272a05dcdfec3c05d7f93b 100644 (file)
@@ -46,7 +46,7 @@ static inline bool TPM2_PCR_MASK_VALID(uint32_t pcr_mask) {
 
 #define TPM2_N_HASH_ALGORITHMS 4U
 
-int dlopen_tpm2(int log_level);
+int dlopen_tpm2(int log_level) _dlopen_loader_;
 
 /* tpm2_unseal() returns a bunch of different errors for various flavours of PCR issues, let's group them.
  * Kept outside the HAVE_TPM2 guard as callers switch on these errnos even in builds without TPM2. */