e354a5
commit 94b63e66206a9ad38872a9136a623ce73cf7c858
e354a5
Author: Florian Weimer <fweimer@redhat.com>
e354a5
Date:   Thu Feb 7 09:02:00 2019 +0100
e354a5
e354a5
    support: Implement xdlmopen
e354a5
    
e354a5
    Put xdlmopen into its own file, to avoid disturbing static linking
e354a5
    tests (where dlmopen pulls in additional code).
e354a5
e354a5
diff --git a/support/Makefile b/support/Makefile
e354a5
index 5808a42dce87151f..895b83a426369b0c 100644
e354a5
--- a/support/Makefile
e354a5
+++ b/support/Makefile
e354a5
@@ -86,6 +86,7 @@ libsupport-routines = \
e354a5
   xconnect \
e354a5
   xcopy_file_range \
e354a5
   xdlfcn \
e354a5
+  xdlmopen \
e354a5
   xdup2 \
e354a5
   xfclose \
e354a5
   xfopen \
e354a5
diff --git a/support/xdlfcn.h b/support/xdlfcn.h
e354a5
index ab1cbb3cb9bb1cc7..a53fb61b133af5c3 100644
e354a5
--- a/support/xdlfcn.h
e354a5
+++ b/support/xdlfcn.h
e354a5
@@ -25,11 +25,11 @@ __BEGIN_DECLS
e354a5
 
e354a5
 /* Each of these terminates process on failure with relevant error message.  */
e354a5
 void *xdlopen (const char *filename, int flags);
e354a5
+void *xdlmopen (Lmid_t lmid, const char *filename, int flags);
e354a5
 void *xdlsym (void *handle, const char *symbol);
e354a5
 void *xdlvsym (void *handle, const char *symbol, const char *version);
e354a5
 void xdlclose (void *handle);
e354a5
 
e354a5
-
e354a5
 __END_DECLS
e354a5
 
e354a5
 #endif /* SUPPORT_DLOPEN_H */
e354a5
diff --git a/support/xdlmopen.c b/support/xdlmopen.c
e354a5
new file mode 100644
e354a5
index 0000000000000000..9a39ba8801eb1617
e354a5
--- /dev/null
e354a5
+++ b/support/xdlmopen.c
e354a5
@@ -0,0 +1,31 @@
e354a5
+/* dlmopen with error checking.
e354a5
+   Copyright (C) 2017-2019 Free Software Foundation, Inc.
e354a5
+   This file is part of the GNU C Library.
e354a5
+
e354a5
+   The GNU C Library is free software; you can redistribute it and/or
e354a5
+   modify it under the terms of the GNU Lesser General Public
e354a5
+   License as published by the Free Software Foundation; either
e354a5
+   version 2.1 of the License, or (at your option) any later version.
e354a5
+
e354a5
+   The GNU C Library is distributed in the hope that it will be useful,
e354a5
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
e354a5
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e354a5
+   Lesser General Public License for more details.
e354a5
+
e354a5
+   You should have received a copy of the GNU Lesser General Public
e354a5
+   License along with the GNU C Library; if not, see
e354a5
+   <http://www.gnu.org/licenses/>.  */
e354a5
+
e354a5
+#include <support/check.h>
e354a5
+#include <support/xdlfcn.h>
e354a5
+
e354a5
+void *
e354a5
+xdlmopen (Lmid_t lmid, const char *filename, int flags)
e354a5
+{
e354a5
+  void *dso = dlmopen (lmid, filename, flags);
e354a5
+
e354a5
+  if (dso == NULL)
e354a5
+    FAIL_EXIT1 ("error: dlmopen: %s\n", dlerror ());
e354a5
+
e354a5
+  return dso;
e354a5
+}