All of
 help / color / mirror / Atom feed
From: Steven Rostedt <>
To: LKML <>
Cc: Ingo Molnar <>,
	Andrew Morton <>,
	Yoshinori Sato <>,
	Rich Felker <>,
Subject: [PATCH] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link
Date: Thu, 21 Oct 2021 22:16:27 -0400	[thread overview]
Message-ID: <20211021221627.5d7270de@rorschach.local.home> (raw)

Using the linker script to fix an issue where some archs call the
function tracer with just the ip (instruction pointer) and pip (parent
instruction pointer) where as more up to date archs also pass in the
associated ftrace_ops and the ftrace_regs pointer, the generic code
will be called either with two parameters or four. To avoid any C
undefined behavior of calling two parameters to four or four to two
parameter function, two functions are created, where a preprocessor
macro uses the one that matches the architecture. As the function
pointers for them may be different, a typecast is used. But this
triggers issues with newer compilers that will fail due to -Werror.

A linker trick is now used to map the generic function to the function
that is used (note the generic function is only used to set the default
function callback). The linker trick defines ftrace_ops_list_func (the
generic function) to arch_ftrace_ops_list_func (the arch defined one).


But this fails sh arch because their linker script is included in their
compressed image that does not define arch_ftrace_ops_list_func at all

  sh4-linux-ld:arch/sh/boot/compressed/../../kernel/ undefined symbol `arch_ftrace_ops_list_func' referenced in expression

Included a stub by that name in the misc.c to allow the code to
compile and link, even though it's not used.

This is similar to what was done for ftrace_stub:

  b83b43ffc6e4b ("fgraph: Fix function type mismatches of
  ftrace_graph_return using ftrace_stub")

Signed-off-by: Steven Rostedt (VMware) <>
This is based on my tree at:
  branch: ftrace/core
  I can push this change through my tree with the SuperH maintainer's acks.

diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c
index a03b6680a9d9..ca05c99a3d5b 100644
--- a/arch/sh/boot/compressed/misc.c
+++ b/arch/sh/boot/compressed/misc.c
@@ -115,6 +115,9 @@ void __stack_chk_fail(void)
 void ftrace_stub(void)
+void arch_ftrace_ops_list_func(void)
 #define stackalign	4

             reply	other threads:[~2021-10-22  2:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22  2:16 Steven Rostedt [this message]
2021-10-27  5:21 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211021221627.5d7270de@rorschach.local.home \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] ftrace/sh: Add arch_ftrace_ops_list_func stub to have compressed image still link' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.