Make references to __{start,stop}___{markers,tracepoints} weak
authorJan Blunck <jblunck@suse.de>
Tue, 27 Oct 2009 10:07:39 +0000 (11:07 +0100)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 11 Nov 2009 21:48:00 +0000 (16:48 -0500)
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 <jblunck@suse.de>
include/ust/marker.h
include/ust/tracepoint.h

index 0c32586a58b6721708208fda7f4d469866168c5e..bbd9187a66ce4c043b5ab7fe83a38e73d49a067c 100644 (file)
@@ -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);
index 56c62b0c6d3c884b1a6115cb4984eb9b17cb3de5..b0ccbada544440473ef1216b9912c37e0a1e351f 100644 (file)
@@ -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,          \
This page took 0.025366 seconds and 4 git commands to generate.