All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ftrace: Do not reference symbols in sections without size
@ 2021-02-15 21:44 Steven Rostedt
  2021-02-16  0:05 ` Josh Poimboeuf
  0 siblings, 1 reply; 9+ messages in thread
From: Steven Rostedt @ 2021-02-15 21:44 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Andrew Morton, Josh Poimboeuf, Greg Kroah-Hartman

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

Starting with binutils 2.36, sections were being removed if they had weak
functions that were optimized out. Unfortunately, these weak functions would
leave references to mcount/fentry calls, that would make recordmcount fail
to find the symbol that matched the call to fentry.

Before returning the symbol of the section to create the mcount location,
check if that section size is greater than zero. If it has no size, skip
referencing that mcount call location.

Link: https://lore.kernel.org/lkml/YCafKVSTX9MxDBMd@kroah.com/

Cc: stable@vger.kernel.org
[ Backport as far as it can go ]
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Reported-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 scripts/recordmcount.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h
index f9b19524da11..1a29f290092d 100644
--- a/scripts/recordmcount.h
+++ b/scripts/recordmcount.h
@@ -562,7 +562,8 @@ static char const * __has_rel_mcount(Elf_Shdr const *const relhdr, /* reltype */
 	if (w(txthdr->sh_type) != SHT_PROGBITS ||
 	    !(_w(txthdr->sh_flags) & SHF_EXECINSTR))
 		return NULL;
-	return txtname;
+	/* If the section has no size, then it wont be available for reference */
+	return shdr0->sh_size ? txtname : NULL;
 }
 
 static char const *has_rel_mcount(Elf_Shdr const *const relhdr,
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-02-16 17:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 21:44 [PATCH] ftrace: Do not reference symbols in sections without size Steven Rostedt
2021-02-16  0:05 ` Josh Poimboeuf
2021-02-16  1:06   ` Steven Rostedt
2021-02-16  2:00     ` Steven Rostedt
2021-02-16 11:04       ` Greg Kroah-Hartman
2021-02-16 14:51         ` Steven Rostedt
2021-02-16 15:45           ` Josh Poimboeuf
2021-02-16 15:54             ` Greg Kroah-Hartman
2021-02-16 17:53               ` Steven Rostedt

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.