[PATCH v4 12/22] objtool: Ignore jumps to the end of the function for checksum runs
Josh Poimboeuf
jpoimboe at kernel.org
Sat Aug 8 16:17:16 PDT 2026
Sometimes Clang arm64 code jumps to the end of the function for UB. No
need to make that an error for checksum runs, which are only run
manually by klp-build, and for which caring about UB is out of scope.
Such UBs are still reported for normal validate branch runs (for arches
which do that).
Signed-off-by: Josh Poimboeuf <jpoimboe at kernel.org>
---
tools/objtool/check.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index b353c7d6cd893..c034676e1b8c7 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -38,6 +38,22 @@ struct disas_context *objtool_disas_ctx;
size_t sym_name_max_len;
+static bool validate_branch_enabled(void)
+{
+ return opts.stackval ||
+ opts.orc ||
+ opts.uaccess;
+}
+
+static bool alts_needed(void)
+{
+ return validate_branch_enabled() ||
+ opts.noinstr ||
+ opts.hack_jump_label ||
+ opts.disas ||
+ opts.checksum;
+}
+
struct instruction *find_insn(struct objtool_file *file,
struct section *sec, unsigned long offset)
{
@@ -1595,8 +1611,12 @@ static int add_jump_destinations(struct objtool_file *file)
/*
* GCOV/KCOV dead code can jump to the end of
* the function/section.
+ *
+ * Clang on arm64 also does this sometimes for
+ * undefined behavior.
*/
- if (file->ignore_unreachables && func &&
+ if ((!validate_branch_enabled() || file->ignore_unreachables) &&
+ func &&
dest_sec == insn->sec &&
dest_off == func->offset + func->len)
continue;
@@ -2586,22 +2606,6 @@ static void mark_holes(struct objtool_file *file)
}
}
-static bool validate_branch_enabled(void)
-{
- return opts.stackval ||
- opts.orc ||
- opts.uaccess;
-}
-
-static bool alts_needed(void)
-{
- return validate_branch_enabled() ||
- opts.noinstr ||
- opts.hack_jump_label ||
- opts.disas ||
- opts.checksum;
-}
-
int decode_file(struct objtool_file *file)
{
arch_initial_func_cfi_state(&initial_func_cfi);
--
2.54.0
More information about the linux-arm-kernel
mailing list