shared: add DLOPEN_* wrapper macros that stamp .note.dlopen on callers
This macro emits an SD_ELF_NOTE_DLOPEN note so that calling sites, and not just libsystemd-shared, get the ELF stamped with the notes documenting the dependency. Currently most of the dlopen notes end up in libsystemd-shared, and executables have no way to document the optional dependencies they need. With this new macro, this issue can be fixed. Co-developed-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -39,11 +39,7 @@ int dlopen_libintl(int log_level) {
|
||||
#else
|
||||
static void *libintl_dl = NULL;
|
||||
|
||||
SD_ELF_NOTE_DLOPEN(
|
||||
"intl",
|
||||
"Support for message translation via gettext",
|
||||
SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED,
|
||||
"libintl.so.8");
|
||||
LIBINTL_NOTE(SD_ELF_NOTE_DLOPEN_PRIORITY_SUGGESTED);
|
||||
|
||||
return dlopen_many_sym_or_warn(
|
||||
&libintl_dl,
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <libintl.h> /* IWYU pragma: export */
|
||||
#include <locale.h> /* IWYU pragma: export */
|
||||
|
||||
#include "sd-dlopen.h" /* IWYU pragma: export */
|
||||
|
||||
#include "basic-forward.h"
|
||||
#include "dlfcn-util.h"
|
||||
|
||||
@@ -14,6 +16,22 @@ extern DLSYM_PROTOTYPE(dgettext) __attribute__((format_arg(2)));
|
||||
|
||||
int dlopen_libintl(int log_level);
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#define DLOPEN_LIBINTL(log_level, priority) dlopen_libintl(log_level)
|
||||
#else
|
||||
#define LIBINTL_NOTE(priority) \
|
||||
SD_ELF_NOTE_DLOPEN("intl", \
|
||||
"Support for message translation via gettext", \
|
||||
priority, \
|
||||
"libintl.so.8")
|
||||
|
||||
#define DLOPEN_LIBINTL(log_level, priority) \
|
||||
({ \
|
||||
LIBINTL_NOTE(priority); \
|
||||
dlopen_libintl(log_level); \
|
||||
})
|
||||
#endif
|
||||
|
||||
typedef enum LocaleVariable {
|
||||
/* We don't list LC_ALL here on purpose. People should be
|
||||
* using LANG instead. */
|
||||
|
||||
Reference in New Issue
Block a user