Tracepoint: make tracepoint ptrs section rw
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 26 Apr 2011 16:18:45 +0000 (12:18 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 26 Apr 2011 16:18:45 +0000 (12:18 -0400)
The pointer section needs to be rw so that the linker can update the
pointers at link-time, thus allowing the code to be compiled with -fPIC.

The previous behavior would cause section flag mismatch, because
TRACEPOINT_LIB declared the ptr with "= NULL", which is not a void *
const, but rather a void *, which forces the element it is assigned to
to become non-const.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/tracepoint.h

index b9557d5703e91ff4082e241e567edc0d8e521d05..b11d69d7c039ee7454c0151e39b31f4ac5faa61c 100644 (file)
@@ -116,13 +116,17 @@ struct tracepoint {
                                                   data);               \
        }
 
+/*
+ * __tracepoints_ptrs section is not const (read-only) to let the linker update
+ * the pointer, allowing PIC code.
+ */
 #define DEFINE_TRACEPOINT_FN(name, reg, unreg)                         \
        static const char __tpstrtab_##name[]                           \
        __attribute__((section("__tracepoints_strings"))) = #name;      \
        struct tracepoint __tracepoint_##name                           \
        __attribute__((section("__tracepoints"))) =                     \
                { __tpstrtab_##name, 0, NULL };                         \
-       static struct tracepoint * const __tracepoint_ptr_##name        \
+       static struct tracepoint * __tracepoint_ptr_##name              \
        __attribute__((used, section("__tracepoints_ptrs"))) =          \
                &__tracepoint_##name;
 
@@ -231,8 +235,8 @@ extern int tracepoint_unregister_lib(struct tracepoint * const *tracepoints_star
 #define TRACEPOINT_LIB                                                 \
        extern struct tracepoint * const __start___tracepoints_ptrs[] __attribute__((weak, visibility("hidden"))); \
        extern struct tracepoint * const __stop___tracepoints_ptrs[] __attribute__((weak, visibility("hidden"))); \
-       static struct tracepoint * const __tracepoint_ptr_dummy         \
-       __attribute__((used, section("__tracepoints_ptrs"))) = NULL;    \
+       static struct tracepoint * __tracepoint_ptr_dummy               \
+       __attribute__((used, section("__tracepoints_ptrs")));           \
        static void __attribute__((constructor)) __tracepoints__init(void)      \
        {                                                                       \
                tracepoint_register_lib(__start___tracepoints_ptrs,                     \
@@ -388,8 +392,8 @@ extern int trace_event_unregister_lib(struct trace_event * const *start_trace_ev
        __attribute__((weak, visibility("hidden")));                    \
        extern struct trace_event * const __stop___trace_events_ptrs[]  \
        __attribute__((weak, visibility("hidden")));                    \
-       static struct trace_event * const __event_ptrs_dummy            \
-       __attribute__((used, section("__trace_events_ptrs"))) = NULL;   \
+       static struct trace_event * __event_ptrs_dummy                  \
+       __attribute__((used, section("__trace_events_ptrs")));          \
        static void __attribute__((constructor))                        \
        __trace_events__init(void)                                      \
        {                                                               \
This page took 0.024412 seconds and 4 git commands to generate.