Skip to content

Commit 3724062

Browse files
jpoimboePeter Zijlstra
authored andcommitted
objtool: Ignore dangling jump table entries
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
1 parent 2014c95 commit 3724062

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/objtool/check.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,14 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
19751975
reloc_addend(reloc) == pfunc->offset)
19761976
break;
19771977

1978+
/*
1979+
* Clang sometimes leaves dangling unused jump table entries
1980+
* which point to the end of the function. Ignore them.
1981+
*/
1982+
if (reloc->sym->sec == pfunc->sec &&
1983+
reloc_addend(reloc) == pfunc->offset + pfunc->len)
1984+
goto next;
1985+
19781986
dest_insn = find_insn(file, reloc->sym->sec, reloc_addend(reloc));
19791987
if (!dest_insn)
19801988
break;
@@ -1992,6 +2000,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
19922000
alt->insn = dest_insn;
19932001
alt->next = insn->alts;
19942002
insn->alts = alt;
2003+
next:
19952004
prev_offset = reloc_offset(reloc);
19962005
}
19972006

0 commit comments

Comments
 (0)