]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
objtool/klp: Improve local label check
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 29 Apr 2026 23:02:38 +0000 (16:02 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 5 May 2026 04:16:00 +0000 (21:16 -0700)
Clang emits various .L-prefixed local symbols beyond .Ltmp*, such as
.L__const.* for local constant data.  These are assembler-local labels
not present in kallsyms, so they can never be resolved at module load
time.

Broaden the check from .Ltmp* to all .L* symbols so they get cloned into
the patch module instead.

Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/klp-diff.c

index ccb16a45107e3ceadca194db5e794957d5e83faf..c5d4c9ed8580f42e0275e23d6305c135093212f4 100644 (file)
@@ -282,14 +282,14 @@ static bool is_uncorrelated_static_local(struct symbol *sym)
 }
 
 /*
- * Clang emits several useless .Ltmp_* code labels.
+ * .L symbols are assembler-local labels not present in kallsyms.  They must
+ * never become KLP relocations; instead their data is cloned into the patch
+ * module.  This covers .Ltmp* (Clang temp labels), .L__const.* (Clang local
+ * constants), and any other assembler-local pattern.
  */
-static bool is_clang_tmp_label(struct symbol *sym)
+static bool is_local_label(struct symbol *sym)
 {
-       return is_notype_sym(sym) &&
-              is_text_sec(sym->sec) &&
-              strstarts(sym->name, ".Ltmp") &&
-              isdigit(sym->name[5]);
+       return strstarts(sym->name, ".L");
 }
 
 static bool is_special_section(struct section *sec)
@@ -388,7 +388,7 @@ static bool dont_correlate(struct symbol *sym)
               is_abs_sym(sym) ||
               is_prefix_func(sym) ||
               is_uncorrelated_static_local(sym) ||
-              is_clang_tmp_label(sym) ||
+              is_local_label(sym) ||
               is_string_sec(sym->sec) ||
               is_initcall_sym(sym) ||
               is_addressable_sym(sym) ||