Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vsprintf: add %ps that is the same as %pS but is like %pf

On PowerPC64 function pointers do not point directly at the functions,
but instead point to pointers to the functions. The output of %pF expects
to point to a pointer to the function, whereas %pS will show the function
itself.

mcount returns the direct pointer to the function and not the pointer to
the pointer. Thus %pS must be used to show this. The function tracer
requires printing of the functions without offsets and uses the %pf
instead.

%pF produces run_local_timers+0x4/0x1f
%pf produces just run_local_timers

For PowerPC64, we need to use the direct pointer, and we only have
%pS which will produce .run_local_timers+0x4/0x1f

This patch creates a %ps that matches the %pf as %pS matches %pF.

Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Zhao Lei <zhaolei@cn.fujitsu.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

authored by

Steven Rostedt and committed by
Steven Rostedt
91adcd2c 45bd00d3

+4 -2
+4 -2
lib/vsprintf.c
··· 581 581 unsigned long value = (unsigned long) ptr; 582 582 #ifdef CONFIG_KALLSYMS 583 583 char sym[KSYM_SYMBOL_LEN]; 584 - if (ext != 'f') 584 + if (ext != 'f' && ext != 's') 585 585 sprint_symbol(sym, value); 586 586 else 587 587 kallsyms_lookup(value, NULL, NULL, NULL, sym); ··· 822 822 case 'F': 823 823 case 'f': 824 824 ptr = dereference_function_descriptor(ptr); 825 + case 's': 825 826 /* Fallthrough */ 826 827 case 'S': 827 828 return symbol_string(buf, end, ptr, spec, *fmt); ··· 1064 1063 * @args: Arguments for the format string 1065 1064 * 1066 1065 * This function follows C99 vsnprintf, but has some extensions: 1067 - * %pS output the name of a text symbol 1066 + * %pS output the name of a text symbol with offset 1067 + * %ps output the name of a text symbol without offset 1068 1068 * %pF output the name of a function pointer with its offset 1069 1069 * %pf output the name of a function pointer without its offset 1070 1070 * %pR output the address range in a struct resource