1 From 42330adcefcd1830dad89e2a960c93d8dd1da125 Mon Sep 17 00:00:00 2001
2 From: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
3 Date: Tue, 21 Feb 2017 16:00:27 -0500
4 Subject: [PATCH] Validate the presence of dlmopen at configure time
6 Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
7 Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
8 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 [Backport from upstream commit 42330adcefcd1830dad89e2a960c93d8dd1da125.]
10 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
12 configure.ac | 8 ++++++++
13 liblttng-ust-dl/lttng-ust-dl.c | 8 ++++++++
14 liblttng-ust-dl/ust_dl.h | 2 ++
15 3 files changed, 18 insertions(+)
17 diff --git a/configure.ac b/configure.ac
18 index 450b43b..023cfd4 100644
21 @@ -125,15 +125,23 @@ AS_IF([test "x${ax_cv_sys_weak_alias}" = "xno"], [
22 # Checks for libraries.
23 AC_CHECK_LIB([dl], [dlopen], [
27 #libdl not found, check for dlopen in libc.
28 AC_CHECK_LIB([c], [dlopen], [
32 AC_MSG_ERROR([Cannot find dlopen in libdl nor libc. Use [LDFLAGS]=-Ldir to specify their location.])
36 +# Check if libdl has dlmopen support.
37 +AH_TEMPLATE([HAVE_DLMOPEN], ["Define to 1 if dlmopen is available."])
38 +AC_CHECK_LIB([$libdl_name], [dlmopen],
39 + [AC_DEFINE([HAVE_DLMOPEN], [1])]
42 AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBDL], [test "x$have_libdl" = "xyes"])
43 AM_CONDITIONAL([LTTNG_UST_BUILD_WITH_LIBC_DL], [test "x$have_libc_dl" = "xyes"])
45 diff --git a/liblttng-ust-dl/lttng-ust-dl.c b/liblttng-ust-dl/lttng-ust-dl.c
46 index b0737b6..ce2ae0e 100644
47 --- a/liblttng-ust-dl/lttng-ust-dl.c
48 +++ b/liblttng-ust-dl/lttng-ust-dl.c
52 static void *(*__lttng_ust_plibc_dlopen)(const char *filename, int flags);
54 static void *(*__lttng_ust_plibc_dlmopen)(Lmid_t nsid, const char *filename,
57 static int (*__lttng_ust_plibc_dlclose)(void *handle);
60 @@ -55,6 +57,7 @@ void *_lttng_ust_dl_libc_dlopen(const char *filename, int flags)
61 return __lttng_ust_plibc_dlopen(filename, flags);
66 void *_lttng_ust_dl_libc_dlmopen(Lmid_t nsid, const char *filename,
68 @@ -68,6 +71,7 @@ void *_lttng_ust_dl_libc_dlmopen(Lmid_t nsid, const char *filename,
70 return __lttng_ust_plibc_dlmopen(nsid, filename, flags);
75 int _lttng_ust_dl_libc_dlclose(void *handle)
76 @@ -143,6 +147,7 @@ end:
82 void lttng_ust_dl_dlmopen(void *so_base, Lmid_t nsid, const char *so_name,
84 @@ -203,6 +208,7 @@ end:
85 lttng_ust_elf_destroy(elf);
90 void *dlopen(const char *filename, int flags)
92 @@ -223,6 +229,7 @@ void *dlopen(const char *filename, int flags)
97 void *dlmopen(Lmid_t nsid, const char *filename, int flags)
100 @@ -243,6 +250,7 @@ void *dlmopen(Lmid_t nsid, const char *filename, int flags)
106 int dlclose(void *handle)
108 diff --git a/liblttng-ust-dl/ust_dl.h b/liblttng-ust-dl/ust_dl.h
109 index b8cfe82..afa8e84 100644
110 --- a/liblttng-ust-dl/ust_dl.h
111 +++ b/liblttng-ust-dl/ust_dl.h
112 @@ -51,6 +51,7 @@ TRACEPOINT_EVENT(lttng_ust_dl, dlopen,
117 TRACEPOINT_EVENT(lttng_ust_dl, dlmopen,
118 TP_ARGS(void *, ip, void *, baddr, Lmid_t, nsid,
119 const char *, path, int, flags,
120 @@ -66,6 +67,7 @@ TRACEPOINT_EVENT(lttng_ust_dl, dlmopen,
121 ctf_integer(uint8_t, has_debug_link, has_debug_link)
126 TRACEPOINT_EVENT(lttng_ust_dl, build_id,