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