summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2025-01-14 13:57:58 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-03-22 12:54:16 -0700
commitc39bd0df25b4760806e7e63d79b5407d9d098158 (patch)
tree8ab858cf7cb45e02a1e817033faf2a7014027603 /tools
parentd5ca39d3369aaa2067f47ffff3a46e7e42c8c79f (diff)
downloadlinux-c39bd0df25b4760806e7e63d79b5407d9d098158.tar.gz
linux-c39bd0df25b4760806e7e63d79b5407d9d098158.tar.bz2
linux-c39bd0df25b4760806e7e63d79b5407d9d098158.zip
objtool: Ignore dangling jump table entries
[ Upstream commit 3724062ca2b1364f02cf44dbea1a552227844ad1 ] Clang sometimes leaves dangling unused jump table entries which point to the end of the function. Ignore them. Closes: https://lore.kernel.org/20250113235835.vqgvb7cdspksy5dn@jpoimboe Reported-by: Klaus Kusche <klaus.kusche@computerix.info> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://lkml.kernel.org/r/ee25c0b7e80113e950bd1d4c208b671d35774ff4.1736891751.git.jpoimboe@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/objtool/check.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 1691aa6e6ce3..3c3e5760e81b 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2061,6 +2061,14 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
reloc_addend(reloc) == pfunc->offset)
break;
+ /*
+ * Clang sometimes leaves dangling unused jump table entries
+ * which point to the end of the function. Ignore them.
+ */
+ if (reloc->sym->sec == pfunc->sec &&
+ reloc_addend(reloc) == pfunc->offset + pfunc->len)
+ goto next;
+
dest_insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
if (!dest_insn)
break;
@@ -2078,6 +2086,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
alt->insn = dest_insn;
alt->next = insn->alts;
insn->alts = alt;
+next:
prev_offset = reloc_offset(reloc);
}