linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] objtool: Skip unannotated intra-function call warning for bl+mflr pattern
@ 2025-02-19 16:20 Sathvika Vasireddy
  2025-02-20 19:59 ` Josh Poimboeuf
  2025-02-24  7:15 ` Christophe Leroy
  0 siblings, 2 replies; 12+ messages in thread
From: Sathvika Vasireddy @ 2025-02-19 16:20 UTC (permalink / raw)
  To: jpoimboe, peterz, christophe.leroy, npiggin, maddy
  Cc: linux-kernel, linuxppc-dev, llvm, sv

Architectures like PowerPC use a pattern where the compiler generates a
branch-and-link (bl) instruction that targets the very next instruction,
followed by loading the link register (mflr) later. This pattern appears
in the code like:

 bl .+4
 li r5,0
 mflr r30

Objtool currently warns about this as an "unannotated intra-function
call" because find_call_destination() fails to find any symbol at the
target offset. Add a check to skip the warning when a branch targets
the immediate next instruction in the same function.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202502180818.XnFdv8I8-lkp@intel.com/
Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/check.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 753dbc4f8198..3f7cf2c917b5 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1613,6 +1613,7 @@ static struct symbol *find_call_destination(struct section *sec, unsigned long o
  */
 static int add_call_destinations(struct objtool_file *file)
 {
+	struct instruction *next_insn;
 	struct instruction *insn;
 	unsigned long dest_off;
 	struct symbol *dest;
@@ -1625,6 +1626,11 @@ static int add_call_destinations(struct objtool_file *file)
 		reloc = insn_reloc(file, insn);
 		if (!reloc) {
 			dest_off = arch_jump_destination(insn);
+
+			next_insn = next_insn_same_func(file, insn);
+			if (next_insn && dest_off == next_insn->offset)
+				continue;
+
 			dest = find_call_destination(insn->sec, dest_off);
 
 			add_call_dest(file, insn, dest, false);
-- 
2.39.3



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

end of thread, other threads:[~2025-02-25  7:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-19 16:20 [RFC PATCH] objtool: Skip unannotated intra-function call warning for bl+mflr pattern Sathvika Vasireddy
2025-02-20 19:59 ` Josh Poimboeuf
2025-02-21  8:50   ` Sathvika Vasireddy
2025-02-24 10:36     ` Christophe Leroy
2025-02-24 12:35     ` Peter Zijlstra
2025-02-24 16:25     ` Peter Zijlstra
2025-02-24 17:54       ` Christophe Leroy
2025-02-24  7:15 ` Christophe Leroy
2025-02-24 10:33   ` Christophe Leroy
2025-02-24 13:19     ` Christophe Leroy
2025-02-24 17:09       ` Nathan Chancellor
2025-02-25  7:35         ` Christophe Leroy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).