about summary refs log tree commit diff
path: root/support/xdlfcn.c
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2019-06-28 10:15:30 +0200
committerFlorian Weimer <fweimer@redhat.com>2019-06-28 10:15:38 +0200
commit17432d7150bdab3bce2ea66c70ad6c920f54077a (patch)
tree40b7cdb0bc63aeadf880368c1bdf1918d6e159d7 /support/xdlfcn.c
parent5a659ccc0ec217ab02a4c273a1f6d346a359560a (diff)
downloadglibc-17432d7150bdab3bce2ea66c70ad6c920f54077a.tar.gz
glibc-17432d7150bdab3bce2ea66c70ad6c920f54077a.tar.xz
glibc-17432d7150bdab3bce2ea66c70ad6c920f54077a.zip
support: Add xdlvsym function
Diffstat (limited to 'support/xdlfcn.c')
-rw-r--r--support/xdlfcn.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/support/xdlfcn.c b/support/xdlfcn.c
index b2e5c21134..11fe4896d1 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)
 {