basic,shared: move dlopen helpers to shared/
This was added in 88d775b734,
with the apparent intent of using in shared/ and the rest of our code.
It doesn't matter much for our code, since libdl is part of glibc anyway,
but moving it removes one linkage from libsystemd. (libshared was already
linking to libdl explicitly).
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include "dlfcn-util.h"
|
||||
|
||||
int dlsym_many_and_warn(void *dl, int level, ...) {
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
/* Tries to resolve a bunch of function symbols, and logs errors about the ones it cannot
|
||||
* resolve. Note that this function possibly modifies the supplied function pointers if the whole
|
||||
* operation fails */
|
||||
|
||||
va_start(ap, level);
|
||||
|
||||
for (;;) {
|
||||
void (**fn)(void);
|
||||
void (*tfn)(void);
|
||||
const char *symbol;
|
||||
|
||||
fn = va_arg(ap, typeof(fn));
|
||||
if (!fn)
|
||||
break;
|
||||
|
||||
symbol = va_arg(ap, typeof(symbol));
|
||||
|
||||
tfn = (typeof(tfn)) dlsym(dl, symbol);
|
||||
if (!tfn) {
|
||||
r = log_full_errno(level,
|
||||
SYNTHETIC_ERRNO(ELIBBAD),
|
||||
"Can't find symbol %s: %s", symbol, dlerror());
|
||||
va_end(ap);
|
||||
return r;
|
||||
}
|
||||
|
||||
*fn = tfn;
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
#pragma once
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(void*, dlclose, NULL);
|
||||
|
||||
int dlsym_many_and_warn(void *dl, int level, ...);
|
||||
|
||||
/* Macro useful for putting together variable/symbol name pairs when calling dlsym_many_and_warn(). Assumes
|
||||
* that each library symbol to resolve will be placed in a variable with the "sym_" prefix, i.e. a symbol
|
||||
* "foobar" is loaded into a variable "sym_foobar". */
|
||||
#define DLSYM_ARG(arg) \
|
||||
&sym_##arg, STRINGIFY(arg)
|
||||
@@ -42,8 +42,6 @@ basic_sources = files('''
|
||||
def.h
|
||||
dirent-util.c
|
||||
dirent-util.h
|
||||
dlfcn-util.c
|
||||
dlfcn-util.h
|
||||
dns-def.h
|
||||
efivars.c
|
||||
efivars.h
|
||||
@@ -396,8 +394,7 @@ libbasic = static_library(
|
||||
libcap,
|
||||
libseccomp,
|
||||
libselinux,
|
||||
libm,
|
||||
libdl],
|
||||
libm],
|
||||
c_args : ['-fvisibility=default'],
|
||||
install : false)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user