Skip to content

Commit 4536550

Browse files
jpoimboeopsiff
authored andcommitted
objtool: Ignore dangling jump table entries
[ Upstream commit 3724062 ] 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 <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/ee25c0b7e80113e950bd1d4c208b671d35774ff4.1736891751.git.jpoimboe@kernel.org Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 5b1c485) Conflicts: tools/objtool/check.c [Handle 765ecc2:("objtool: Handle various symbol types of rodata")] Signed-off-by: Wentao Guan <[email protected]>
1 parent ac944fe commit 4536550

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
@@ -2079,6 +2079,14 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
20792079
if (reloc->sym->sec == pfunc->sec && offset == pfunc->offset)
20802080
break;
20812081

2082+
/*
2083+
* Clang sometimes leaves dangling unused jump table entries
2084+
* which point to the end of the function. Ignore them.
2085+
*/
2086+
if (reloc->sym->sec == pfunc->sec &&
2087+
offset == pfunc->offset + pfunc->len)
2088+
goto next;
2089+
20822090
dest_insn = find_insn(file, reloc->sym->sec, offset);
20832091
if (!dest_insn)
20842092
break;
@@ -2103,6 +2111,7 @@ static int add_jump_table(struct objtool_file *file, struct instruction *insn,
21032111
alt->insn = dest_insn;
21042112
alt->next = insn->alts;
21052113
insn->alts = alt;
2114+
next:
21062115
prev_offset = reloc_offset(reloc);
21072116
}
21082117

0 commit comments

Comments
 (0)