diff options
author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2022-03-01 18:04:13 +0100 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2022-03-01 22:07:17 +0100 |
commit | ee48779e05831a0ec5e1ba5e7ed5fe92aaca1d9e (patch) | |
tree | 2e1dc1565add0b2dde578d6bdeaac5235ed10612 /src/journal | |
parent | file-hierarchy: Document /sys/fs/cgroup (diff) | |
download | systemd-ee48779e05831a0ec5e1ba5e7ed5fe92aaca1d9e.tar.xz systemd-ee48779e05831a0ec5e1ba5e7ed5fe92aaca1d9e.zip |
shared: Add more dlopen() tests
Add dlopen_dw(), dlopen_elf() and dlopen_pcre2() to the dlopen test.
To enable adding dlopen_pcre2(), we move pcre2-dlopen.h/c from
src/journal to src/shared.
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/meson.build | 2 | ||||
-rw-r--r-- | src/journal/pcre2-dlopen.c | 44 | ||||
-rw-r--r-- | src/journal/pcre2-dlopen.h | 18 |
3 files changed, 0 insertions, 64 deletions
diff --git a/src/journal/meson.build b/src/journal/meson.build index 73265e2c6d..ff9463f7c4 100644 --- a/src/journal/meson.build +++ b/src/journal/meson.build @@ -49,8 +49,6 @@ systemd_cat_sources = files('cat.c') journalctl_sources = files(''' journalctl.c - pcre2-dlopen.c - pcre2-dlopen.h '''.split()) if install_sysconfdir_samples diff --git a/src/journal/pcre2-dlopen.c b/src/journal/pcre2-dlopen.c deleted file mode 100644 index 475d7eb26d..0000000000 --- a/src/journal/pcre2-dlopen.c +++ /dev/null @@ -1,44 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ - -#include "dlfcn-util.h" -#include "log.h" -#include "pcre2-dlopen.h" - -#if HAVE_PCRE2 -static void *pcre2_dl = NULL; - -pcre2_match_data* (*sym_pcre2_match_data_create)(uint32_t, pcre2_general_context *); -void (*sym_pcre2_match_data_free)(pcre2_match_data *); -void (*sym_pcre2_code_free)(pcre2_code *); -pcre2_code* (*sym_pcre2_compile)(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, pcre2_compile_context *); -int (*sym_pcre2_get_error_message)(int, PCRE2_UCHAR *, PCRE2_SIZE); -int (*sym_pcre2_match)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, pcre2_match_data *, pcre2_match_context *); -PCRE2_SIZE* (*sym_pcre2_get_ovector_pointer)(pcre2_match_data *); - -int dlopen_pcre2(void) { - /* So here's something weird: PCRE2 actually renames the symbols exported by the library via C - * macros, so that the exported symbols carry a suffix "_8" but when used from C the suffix is - * gone. In the argument list below we ignore this mangling. Surprisingly (at least to me), we - * actually get away with that. That's because DLSYM_ARG() useses STRINGIFY() to generate a string - * version of the symbol name, and that resolves the macro mapping implicitly already, so that the - * string actually contains the "_8" suffix already due to that and we don't have to append it - * manually anymore. C is weird. 🤯 */ - - return dlopen_many_sym_or_warn( - &pcre2_dl, "libpcre2-8.so.0", LOG_ERR, - DLSYM_ARG(pcre2_match_data_create), - DLSYM_ARG(pcre2_match_data_free), - DLSYM_ARG(pcre2_code_free), - DLSYM_ARG(pcre2_compile), - DLSYM_ARG(pcre2_get_error_message), - DLSYM_ARG(pcre2_match), - DLSYM_ARG(pcre2_get_ovector_pointer)); -} - -#else - -int dlopen_pcre2(void) { - return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), - "PCRE2 support is not compiled in."); -} -#endif diff --git a/src/journal/pcre2-dlopen.h b/src/journal/pcre2-dlopen.h deleted file mode 100644 index 1306334144..0000000000 --- a/src/journal/pcre2-dlopen.h +++ /dev/null @@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -#pragma once - -#if HAVE_PCRE2 - -#define PCRE2_CODE_UNIT_WIDTH 8 -#include <pcre2.h> - -extern pcre2_match_data* (*sym_pcre2_match_data_create)(uint32_t, pcre2_general_context *); -extern void (*sym_pcre2_match_data_free)(pcre2_match_data *); -extern void (*sym_pcre2_code_free)(pcre2_code *); -extern pcre2_code* (*sym_pcre2_compile)(PCRE2_SPTR, PCRE2_SIZE, uint32_t, int *, PCRE2_SIZE *, pcre2_compile_context *); -extern int (*sym_pcre2_get_error_message)(int, PCRE2_UCHAR *, PCRE2_SIZE); -extern int (*sym_pcre2_match)(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, uint32_t, pcre2_match_data *, pcre2_match_context *); -extern PCRE2_SIZE* (*sym_pcre2_get_ovector_pointer)(pcre2_match_data *); -#endif - -int dlopen_pcre2(void); |