From 3d3dc207c16d90ecd80eb1e757fe8b94ff317c63 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 18 Mar 2021 16:50:27 -0400 Subject: [PATCH] Introduce SONAME defines Folowing the refactor of the autotools code, the major soname number of each library is now available as a define in 'lttng/ust-version.h'. Use them instead of literal value that have to be synchronized manually. Change-Id: I7d777d32c2a710708c1ac2546111458c281fce13 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- include/lttng/tracepoint.h | 6 ++++-- include/lttng/ust-tracer.h | 8 ++++++++ liblttng-ust/lttng-ust-comm.c | 10 ++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h index 71f3e36c..a8ee06be 100644 --- a/include/lttng/tracepoint.h +++ b/include/lttng/tracepoint.h @@ -15,8 +15,10 @@ #include #include /* for dlopen */ #include /* for memset */ + #include /* for sdt */ #include +#include #ifdef LTTNG_UST_HAVE_SDT_INTEGRATION /* @@ -359,7 +361,7 @@ __tracepoints__init(void) tracepoint_dlopen_ptr = &tracepoint_dlopen; if (!tracepoint_dlopen_ptr->liblttngust_handle) tracepoint_dlopen_ptr->liblttngust_handle = - dlopen("liblttng-ust-tracepoint.so.1", RTLD_NOW | RTLD_GLOBAL); + dlopen(LTTNG_UST_TRACEPOINT_LIB_SONAME, RTLD_NOW | RTLD_GLOBAL); if (!tracepoint_dlopen_ptr->liblttngust_handle) return; __tracepoint__init_urcu_sym(); @@ -467,7 +469,7 @@ __tracepoints__ptrs_init(void) tracepoint_dlopen_ptr = &tracepoint_dlopen; if (!tracepoint_dlopen_ptr->liblttngust_handle) tracepoint_dlopen_ptr->liblttngust_handle = - dlopen("liblttng-ust-tracepoint.so.1", RTLD_NOW | RTLD_GLOBAL); + dlopen(LTTNG_UST_TRACEPOINT_LIB_SONAME, RTLD_NOW | RTLD_GLOBAL); if (!tracepoint_dlopen_ptr->liblttngust_handle) return; if (!tracepoint_destructors_syms_ptr) diff --git a/include/lttng/ust-tracer.h b/include/lttng/ust-tracer.h index 3a771e9b..4b12be18 100644 --- a/include/lttng/ust-tracer.h +++ b/include/lttng/ust-tracer.h @@ -29,4 +29,12 @@ #define lttng_alignof(type) 1 #endif +/* + * Concatenate lttng ust shared libraries name with their major version number. + */ +#define LTTNG_UST_LIB_SONAME "liblttng-ust.so." lttng_ust_stringify(LTTNG_UST_LIB_SONAME_MAJOR) +#define LTTNG_UST_TRACEPOINT_LIB_SONAME "liblttng-ust-tracepoint.so." lttng_ust_stringify(LTTNG_UST_LIB_SONAME_MAJOR) +#define LTTNG_UST_CTL_LIB_SONAME "liblttng-ust-ctl.so." lttng_ust_stringify(LTTNG_UST_CTL_LIB_SONAME_MAJOR) + + #endif /* _LTTNG_UST_TRACER_H */ diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c index 3ace61fc..be7dc9f1 100644 --- a/liblttng-ust/lttng-ust-comm.c +++ b/liblttng-ust/lttng-ust-comm.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -53,9 +54,6 @@ #include "context-internal.h" #include "ust-compat.h" -/* Concatenate lttng ust shared library name with its major version number. */ -#define LTTNG_UST_LIB_SO_NAME "liblttng-ust.so." lttng_ust_stringify(CONFIG_LTTNG_UST_LIBRARY_VERSION_MAJOR) - /* * Has lttng ust comm constructor been called ? */ @@ -2093,7 +2091,7 @@ void __attribute__((constructor)) lttng_ust_init(void) * liblttng-ust.so to increment the dynamic loader's internal refcount for * this library so it never becomes zero, thus never gets unloaded from the * address space of the process. Since we are already running in the - * constructor of the LTTNG_UST_LIB_SO_NAME library, calling dlopen will + * constructor of the LTTNG_UST_LIB_SONAME library, calling dlopen will * simply increment the refcount and no additionnal work is needed by the * dynamic loader as the shared library is already loaded in the address * space. As a safe guard, we use the RTLD_NODELETE flag to prevent @@ -2101,9 +2099,9 @@ void __attribute__((constructor)) lttng_ust_init(void) * never happen). Do the return value check but discard the handle at the * end of the function as it's not needed. */ - handle = dlopen(LTTNG_UST_LIB_SO_NAME, RTLD_LAZY | RTLD_NODELETE); + handle = dlopen(LTTNG_UST_LIB_SONAME, RTLD_LAZY | RTLD_NODELETE); if (!handle) { - ERR("dlopen of liblttng-ust shared library (%s).", LTTNG_UST_LIB_SO_NAME); + ERR("dlopen of liblttng-ust shared library (%s).", LTTNG_UST_LIB_SONAME); } /* -- 2.34.1