Re: 'perf probe' and symbols from .text.<something>

From
Josh Poimboeuf <hidden>
Date
2021-02-18 19:57:25
Also in
lkml
Reply to
Evgenii Shatokhin, 2021-02-18
On Thu, Feb 18, 2021 at 08:09:17PM +0300, Evgenii Shatokhin wrote:
Is there a way to allow probing of functions in .text.<something> ?

Of course, one could place probes using absolute addresses of the functions
but that would be less convenient.

This also affects many livepatch modules where the kernel code can be
compiled with -ffunction-sections and each function may end up in a separate
section .text.<function_name>. 'perf probe' cannot be used there, except
with the absolute addresses.

Moreover, if FGKASLR patches are merged (https://lwn.net/Articles/832434/)
and the kernel is built with FGKASLR enabled, -ffunction-sections will be
used too. 'perf probe' will be unable to see the kernel functions then.
A hack fix like the below would probably work, but as you pointed out,
FGKASLR is going to be a problem.  I suspect the proper fix is for perf
to learn how to deal with multiple executable ELF sections.
diff --git a/scripts/module.lds.S b/scripts/module.lds.S
index 69b9b71a6a47..0c522a87f6ce 100644
--- a/scripts/module.lds.S
+++ b/scripts/module.lds.S
@@ -4,6 +4,10 @@
  * combine them automatically.
  */
 SECTIONS {
+	.text : {
+		*(.text)
+		*(.text.*)
+	}
 	/DISCARD/ : {
 		*(.discard)
 		*(.discard.*)
Thread (16 messages) 16 messages, 4 authors, last reply 2021-02-24
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help