Skip to content

Commit 4dc5c03

Browse files
jpoimboegregkh
authored andcommitted
objtool: Ignore end-of-section jumps for KCOV/GCOV
commit 0d75977 upstream. When KCOV or GCOV is enabled, dead code can be left behind, in which case objtool silences unreachable and undefined behavior (fallthrough) warnings. Fallthrough warnings, and their variant "end of section" warnings, were silenced with the following commit: 6b023c7 ("objtool: Silence more KCOV warnings") Another variant of a fallthrough warning is a jump to the end of a function. If that function happens to be at the end of a section, the jump destination doesn't actually exist. Normally that would be a fatal objtool error, but for KCOV/GCOV it's just another undefined behavior fallthrough. Silence it like the others. Fixes the following warning: drivers/iommu/dma-iommu.o: warning: objtool: iommu_dma_sw_msi+0x92: can't find jump dest instruction at .text+0x54d5 Fixes: 6b023c7 ("objtool: Silence more KCOV warnings") Reported-by: Randy Dunlap <[email protected]> Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Linus Torvalds <[email protected]> Link: https://lore.kernel.org/r/08fbe7d7e1e20612206f1df253077b94f178d93e.1743481539.git.jpoimboe@kernel.org Closes: https://lore.kernel.org/[email protected]/ Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 1b7647e commit 4dc5c03

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tools/objtool/check.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,8 @@ static int add_jump_destinations(struct objtool_file *file)
15701570
unsigned long dest_off;
15711571

15721572
for_each_insn(file, insn) {
1573+
struct symbol *func = insn_func(insn);
1574+
15731575
if (insn->jump_dest) {
15741576
/*
15751577
* handle_group_alt() may have previously set
@@ -1593,7 +1595,7 @@ static int add_jump_destinations(struct objtool_file *file)
15931595
} else if (reloc->sym->return_thunk) {
15941596
add_return_call(file, insn, true);
15951597
continue;
1596-
} else if (insn_func(insn)) {
1598+
} else if (func) {
15971599
/*
15981600
* External sibling call or internal sibling call with
15991601
* STT_FUNC reloc.
@@ -1626,6 +1628,15 @@ static int add_jump_destinations(struct objtool_file *file)
16261628
continue;
16271629
}
16281630

1631+
/*
1632+
* GCOV/KCOV dead code can jump to the end of the
1633+
* function/section.
1634+
*/
1635+
if (file->ignore_unreachables && func &&
1636+
dest_sec == insn->sec &&
1637+
dest_off == func->offset + func->len)
1638+
continue;
1639+
16291640
WARN_INSN(insn, "can't find jump dest instruction at %s+0x%lx",
16301641
dest_sec->name, dest_off);
16311642
return -1;
@@ -1650,8 +1661,7 @@ static int add_jump_destinations(struct objtool_file *file)
16501661
/*
16511662
* Cross-function jump.
16521663
*/
1653-
if (insn_func(insn) && insn_func(jump_dest) &&
1654-
insn_func(insn) != insn_func(jump_dest)) {
1664+
if (func && insn_func(jump_dest) && func != insn_func(jump_dest)) {
16551665

16561666
/*
16571667
* For GCC 8+, create parent/child links for any cold
@@ -1668,10 +1678,10 @@ static int add_jump_destinations(struct objtool_file *file)
16681678
* case where the parent function's only reference to a
16691679
* subfunction is through a jump table.
16701680
*/
1671-
if (!strstr(insn_func(insn)->name, ".cold") &&
1681+
if (!strstr(func->name, ".cold") &&
16721682
strstr(insn_func(jump_dest)->name, ".cold")) {
1673-
insn_func(insn)->cfunc = insn_func(jump_dest);
1674-
insn_func(jump_dest)->pfunc = insn_func(insn);
1683+
func->cfunc = insn_func(jump_dest);
1684+
insn_func(jump_dest)->pfunc = func;
16751685
}
16761686
}
16771687

0 commit comments

Comments
 (0)