[PATCH 10/14] objtool: Ignore jumps to the end of the function for non-CFG arches

Josh Poimboeuf posted 14 patches 1 month ago
There is a newer version of this series
[PATCH 10/14] objtool: Ignore jumps to the end of the function for non-CFG arches
Posted by Josh Poimboeuf 1 month ago
Sometimes Clang arm64 code jumps to the end of the function for UB.
No need to make that an error, arm64 doesn't reverse engineer the CFG
anyway.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/check.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f73cf1382e5c..23cde2de66b9 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1630,10 +1630,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 &&
-			    dest_sec == insn->sec &&
-			    dest_off == func->offset + func->len)
+			if ((file->ignore_unreachables || (!opts.stackval && !opts.orc)) &&
+			    func && dest_sec == insn->sec && dest_off == func->offset + func->len)
 				continue;
 
 			ERROR_INSN(insn, "can't find jump dest instruction at %s",
-- 
2.53.0
Re: [PATCH 10/14] objtool: Ignore jumps to the end of the function for non-CFG arches
Posted by Song Liu 4 weeks, 1 day ago
On Wed, Mar 4, 2026 at 7:31 PM Josh Poimboeuf <jpoimboe@kernel.org> wrote:
>
> Sometimes Clang arm64 code jumps to the end of the function for UB.
> No need to make that an error, arm64 doesn't reverse engineer the CFG
> anyway.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

Acked-by: Song Liu <song@kernel.org>