From 17432d7150bdab3bce2ea66c70ad6c920f54077a Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Fri, 28 Jun 2019 10:15:30 +0200 Subject: support: Add xdlvsym function --- support/xdlfcn.c | 20 ++++++++++++++++++++ support/xdlfcn.h | 1 + 2 files changed, 21 insertions(+) (limited to 'support') diff --git a/support/xdlfcn.c b/support/xdlfcn.c index b2e5c21..11fe489 100644 --- a/support/xdlfcn.c +++ b/support/xdlfcn.c @@ -51,6 +51,26 @@ xdlsym (void *handle, const char *symbol) return sym; } +void * +xdlvsym (void *handle, const char *symbol, const char *version) +{ + /* Clear any pending errors. */ + dlerror (); + + void *sym = dlvsym (handle, symbol, version); + + if (sym == NULL) + { + const char *error = dlerror (); + if (error != NULL) + FAIL_EXIT1 ("error: dlvsym: %s\n", error); + /* If there was no error, we found a NULL symbol. Return the + NULL value in this case. */ + } + + return sym; +} + void xdlclose (void *handle) { diff --git a/support/xdlfcn.h b/support/xdlfcn.h index c9cd810..7f8d493 100644 --- a/support/xdlfcn.h +++ b/support/xdlfcn.h @@ -27,6 +27,7 @@ __BEGIN_DECLS void *xdlopen (const char *filename, int flags); void *xdlmopen (Lmid_t lmid, const char *filename, int flags); void *xdlsym (void *handle, const char *symbol); +void *xdlvsym (void *handle, const char *symbol, const char *version); void xdlclose (void *handle); __END_DECLS -- cgit v1.1