From: Mathieu Desnoyers Date: Fri, 20 May 2016 19:23:06 +0000 (-0400) Subject: Print DBG() message about compiler weak hidden symbol behavior X-Git-Tag: v2.6.7~1 X-Git-Url: http://git.liburcu.org/?p=lttng-ust.git;a=commitdiff_plain;h=f56a7aba42af986be4de9b4917dbdcb22fed10e0 Print DBG() message about compiler weak hidden symbol behavior Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/Makefile.am b/liblttng-ust/Makefile.am index 10797d05..3bc6b9ef 100644 --- a/liblttng-ust/Makefile.am +++ b/liblttng-ust/Makefile.am @@ -7,6 +7,7 @@ lib_LTLIBRARIES = liblttng-ust-tracepoint.la liblttng-ust.la liblttng_ust_tracepoint_la_SOURCES = \ tracepoint.c \ + tracepoint-weak-test.c \ tracepoint-internal.h \ lttng-tracer-core.h \ jhash.h \ diff --git a/liblttng-ust/tracepoint-internal.h b/liblttng-ust/tracepoint-internal.h index 2f18355d..3cc95e56 100644 --- a/liblttng-ust/tracepoint-internal.h +++ b/liblttng-ust/tracepoint-internal.h @@ -51,4 +51,6 @@ static inline void tracepoint_synchronize_unregister(void) extern void init_tracepoint(void); extern void exit_tracepoint(void); +void *lttng_ust_tp_check_weak_hidden(void); + #endif /* _LTTNG_TRACEPOINT_INTERNAL_H */ diff --git a/liblttng-ust/tracepoint-weak-test.c b/liblttng-ust/tracepoint-weak-test.c new file mode 100644 index 00000000..e691fbb1 --- /dev/null +++ b/liblttng-ust/tracepoint-weak-test.c @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2016 Mathieu Desnoyers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* Test compiler support for weak symbols with hidden visibility. */ +char __tracepoint_test_symbol[9] __attribute__((weak, visibility("hidden"))); + +__attribute__((visibility("hidden"))) +void *lttng_ust_tp_check_weak_hidden(void) +{ + return __tracepoint_test_symbol; +} diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c index 5fd1126a..a594d73d 100644 --- a/liblttng-ust/tracepoint.c +++ b/liblttng-ust/tracepoint.c @@ -43,6 +43,9 @@ #include "jhash.h" #include "error.h" +/* Test compiler support for weak symbols with hidden visibility. */ +char __tracepoint_test_symbol[9] __attribute__((weak, visibility("hidden"))); + /* Set to 1 to enable tracepoint debug output */ static const int tracepoint_debug; static int initialized; @@ -803,11 +806,26 @@ int tracepoint_unregister_lib(struct lttng_ust_tracepoint * const *tracepoints_s return 0; } +/* + * Report in debug message whether the compiler correctly supports weak + * hidden symbols. This test checks that the address associated with two + * weak symbols with hidden visibility is the same when declared within + * two compile units part of the same module. + */ +static void check_weak_hidden(void) +{ + DBG("Your compiler support for weak symbols with hidden visibility is %s", + __tracepoint_test_symbol == lttng_ust_tp_check_weak_hidden() ? + "OK" : + "BROKEN. Please upgrade or fix your compiler to use LTTng-UST tracepoints."); +} + void init_tracepoint(void) { if (uatomic_xchg(&initialized, 1) == 1) return; init_usterr(); + check_weak_hidden(); } void exit_tracepoint(void)