Commit ddd9efb5 authored by Nick Desaulniers's avatar Nick Desaulniers Committed by Kelsey Skunberg

tracepoint: Mark __tracepoint_string's __used

BugLink: https://bugs.launchpad.net/bugs/1892822

commit f3751ad0 upstream.

__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/20200730224555.2142154-2-ndesaulniers@google.com

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: stable@vger.kernel.org
Fixes: 102c9323 ("tracing: Add __tracepoint_string() to export string pointers")
Reported-by: default avatarTim Murray <timmurray@google.com>
Reported-by: default avatarSimon MacMullen <simonmacm@google.com>
Suggested-by: default avatarGreg Hackmann <ghackmann@google.com>
Signed-off-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarIan May <ian.may@canonical.com>
Signed-off-by: default avatarKelsey Skunberg <kelsey.skunberg@canonical.com>
parent f27f883d
...@@ -328,7 +328,7 @@ extern void syscall_unregfunc(void); ...@@ -328,7 +328,7 @@ extern void syscall_unregfunc(void);
static const char *___tp_str __tracepoint_string = str; \ static const char *___tp_str __tracepoint_string = str; \
___tp_str; \ ___tp_str; \
}) })
#define __tracepoint_string __attribute__((section("__tracepoint_str"))) #define __tracepoint_string __attribute__((section("__tracepoint_str"), used))
#else #else
/* /*
* tracepoint_string() is used to save the string address for userspace * tracepoint_string() is used to save the string address for userspace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment