From 42330adcefcd1830dad89e2a960c93d8dd1da125 Mon Sep 17 00:00:00 2001
From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Date: Tue, 21 Feb 2017 16:00:27 -0500
Subject: [PATCH] Validate the presence of dlmopen at configure time
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
[Backport from upstream commit 42330adcefcd1830dad89e2a960c93d8dd1da125.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
configure.ac | 8 ++++++++
liblttng-ust-dl/lttng-ust-dl.c | 8 ++++++++
liblttng-ust-dl/ust_dl.h | 2 ++
3 files changed, 18 insertions(+)
diff --git a/configure.ac b/configure.ac
index 450b43b..023cfd4 100644
@@ -125,15 +125,23 @@ AS_IF([test "x${ax_cv_sys_weak_alias}" = "xno"], [
AC_CHECK_LIB([dl], [dlopen], [
#libdl not found, check for dlopen in libc.
AC_CHECK_LIB([c], [dlopen], [
AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
+# Check if libdl has dlmopen support.
+AH_TEMPLATE([HAVE_DLMOPEN], ["Define to 1 if dlmopen is available."])
+AC_CHECK_LIB([$libdl_name], [dlmopen],
+ [AC_DEFINE([HAVE_DLMOPEN], [1])]
AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBDL], [test "x$have_libdl" = "xyes"])
AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBC_DL], [test "x$have_libc_dl" = "xyes"])
diff --git a/liblttng-ust-dl/lttng-ust-dl.c b/liblttng-ust-dl/lttng-ust-dl.c
index b0737b6..ce2ae0e 100644
--- a/liblttng-ust-dl/lttng-ust-dl.c
+++ b/liblttng-ust-dl/lttng-ust-dl.c
static void *(*__lttng_ust_plibc_dlopen)(const char *filename, int flags);
static void *(*__lttng_ust_plibc_dlmopen)(Lmid_t nsid, const char *filename,
static int (*__lttng_ust_plibc_dlclose)(void *handle);
@@ -55,6 +57,7 @@ void *_lttng_ust_dl_libc_dlopen(const char *filename, int flags)
return __lttng_ust_plibc_dlopen(filename, flags);