From: Jan Blunck Date: Tue, 27 Oct 2009 10:07:39 +0000 (+0100) Subject: Make references to __{start,stop}___{markers,tracepoints} weak X-Git-Tag: v1.9.1~829 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=55994a672106ec794f292d747206542067a27584;p=lttng-ust.git Make references to __{start,stop}___{markers,tracepoints} weak When using the linker script approach for initialization of the libust library we unconditionally call __markers_init()/__tracepoints_init(). If one is using only tracepoints or only markers the init call fails because of undefined references to the linker generated symbols for the __markers or __tracepoints section (__start___markers, ...). Since we use the symbols just for the size and the start of the section it is safe to use weak symbols in this case: if the size if zero nothing get read anyway. Signed-off-by: Jan Blunck --- diff --git a/include/ust/marker.h b/include/ust/marker.h index 0c32586a..bbd9187a 100644 --- a/include/ust/marker.h +++ b/include/ust/marker.h @@ -309,18 +309,20 @@ struct lib { struct list_head list; }; -extern int marker_register_lib(struct marker *markers_start, struct marker_addr *marker_addr_start, int markers_count); - -#define MARKER_LIB \ -extern struct marker __start___markers[] __attribute__((visibility("hidden"))); \ -extern struct marker __stop___markers[] __attribute__((visibility("hidden"))); \ -extern struct marker_addr __start___marker_addr[] __attribute__((visibility("hidden"))); \ -extern struct marker_addr __stop___marker_addr[] __attribute__((visibility("hidden"))); \ - \ -static void __attribute__((constructor)) __markers__init(void) \ -{ \ - marker_register_lib(__start___markers, __start___marker_addr, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); \ -} +extern int marker_register_lib(struct marker *markers_start, + struct marker_addr *marker_addr_start, + int markers_count); + +#define MARKER_LIB \ + extern struct marker __start___markers[] __attribute__((weak, visibility("hidden"))); \ + extern struct marker __stop___markers[] __attribute__((weak, visibility("hidden"))); \ + extern struct marker_addr __start___marker_addr[] __attribute__((weak, visibility("hidden"))); \ + extern struct marker_addr __stop___marker_addr[] __attribute__((weak, visibility("hidden"))); \ + \ + static void __attribute__((constructor)) __markers__init(void) \ + { \ + marker_register_lib(__start___markers, __start___marker_addr, (((long)__stop___markers)-((long)__start___markers))/sizeof(struct marker)); \ + } extern void marker_set_new_marker_cb(void (*cb)(struct marker *)); extern void init_markers(void); diff --git a/include/ust/tracepoint.h b/include/ust/tracepoint.h index 56c62b0c..b0ccbada 100644 --- a/include/ust/tracepoint.h +++ b/include/ust/tracepoint.h @@ -202,8 +202,8 @@ extern int tracepoint_register_lib(struct tracepoint *tracepoints_start, int tracepoints_count); #define TRACEPOINT_LIB \ - extern struct tracepoint __start___tracepoints[] __attribute__((visibility("hidden"))); \ - extern struct tracepoint __stop___tracepoints[] __attribute__((visibility("hidden"))); \ + extern struct tracepoint __start___tracepoints[] __attribute__((weak, visibility("hidden"))); \ + extern struct tracepoint __stop___tracepoints[] __attribute__((weak, visibility("hidden"))); \ static void __attribute__((constructor)) __tracepoints__init(void) \ { \ tracepoint_register_lib(__start___tracepoints, \