Skip to content

Commit f3751ad

Browse files
nickdesaulniersrostedt
authored andcommitted
tracepoint: Mark __tracepoint_string's __used
__tracepoint_string's have their string data stored in .rodata, and an address to that data stored in the "__tracepoint_str" section. Functions that refer to those strings refer to the symbol of the address. Compiler optimization can replace those address references with references directly to the string data. If the address doesn't appear to have other uses, then it appears dead to the compiler and is removed. This can break the /tracing/printk_formats sysfs node which iterates the addresses stored in the "__tracepoint_str" section. Like other strings stored in custom sections in this header, mark these __used to inform the compiler that there are other non-obvious users of the address, so they should still be emitted. Link: https://lkml.kernel.org/r/[email protected] Cc: Ingo Molnar <[email protected]> Cc: Miguel Ojeda <[email protected]> Cc: [email protected] Fixes: 102c932 ("tracing: Add __tracepoint_string() to export string pointers") Reported-by: Tim Murray <[email protected]> Reported-by: Simon MacMullen <[email protected]> Suggested-by: Greg Hackmann <[email protected]> Signed-off-by: Nick Desaulniers <[email protected]> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
1 parent 0f69dae commit f3751ad

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/linux/tracepoint.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
361361
static const char *___tp_str __tracepoint_string = str; \
362362
___tp_str; \
363363
})
364-
#define __tracepoint_string __attribute__((section("__tracepoint_str")))
364+
#define __tracepoint_string __attribute__((section("__tracepoint_str"), used))
365365
#else
366366
/*
367367
* tracepoint_string() is used to save the string address for userspace

0 commit comments

Comments
 (0)