Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

objtool: Ignore end-of-section jumps for KCOV/GCOV

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:

6b023c784204 ("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: 6b023c784204 ("objtool: Silence more KCOV warnings")
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: https://lore.kernel.org/r/08fbe7d7e1e20612206f1df253077b94f178d93e.1743481539.git.jpoimboe@kernel.org
Closes: https://lore.kernel.org/314f8809-cd59-479b-97d7-49356bf1c8d1@infradead.org/

authored by

Josh Poimboeuf and committed by
Ingo Molnar
0d759774 55c78035

+16 -6
+16 -6
tools/objtool/check.c
··· 1488 1488 int ret; 1489 1489 1490 1490 for_each_insn(file, insn) { 1491 + struct symbol *func = insn_func(insn); 1492 + 1491 1493 if (insn->jump_dest) { 1492 1494 /* 1493 1495 * handle_group_alt() may have previously set ··· 1515 1513 } else if (reloc->sym->return_thunk) { 1516 1514 add_return_call(file, insn, true); 1517 1515 continue; 1518 - } else if (insn_func(insn)) { 1516 + } else if (func) { 1519 1517 /* 1520 1518 * External sibling call or internal sibling call with 1521 1519 * STT_FUNC reloc. ··· 1550 1548 continue; 1551 1549 } 1552 1550 1551 + /* 1552 + * GCOV/KCOV dead code can jump to the end of the 1553 + * function/section. 1554 + */ 1555 + if (file->ignore_unreachables && func && 1556 + dest_sec == insn->sec && 1557 + dest_off == func->offset + func->len) 1558 + continue; 1559 + 1553 1560 WARN_INSN(insn, "can't find jump dest instruction at %s+0x%lx", 1554 1561 dest_sec->name, dest_off); 1555 1562 return -1; ··· 1585 1574 /* 1586 1575 * Cross-function jump. 1587 1576 */ 1588 - if (insn_func(insn) && insn_func(jump_dest) && 1589 - insn_func(insn) != insn_func(jump_dest)) { 1577 + if (func && insn_func(jump_dest) && func != insn_func(jump_dest)) { 1590 1578 1591 1579 /* 1592 1580 * For GCC 8+, create parent/child links for any cold ··· 1602 1592 * case where the parent function's only reference to a 1603 1593 * subfunction is through a jump table. 1604 1594 */ 1605 - if (!strstr(insn_func(insn)->name, ".cold") && 1595 + if (!strstr(func->name, ".cold") && 1606 1596 strstr(insn_func(jump_dest)->name, ".cold")) { 1607 - insn_func(insn)->cfunc = insn_func(jump_dest); 1608 - insn_func(jump_dest)->pfunc = insn_func(insn); 1597 + func->cfunc = insn_func(jump_dest); 1598 + insn_func(jump_dest)->pfunc = func; 1609 1599 } 1610 1600 } 1611 1601