]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
objtool: Mark prefix functions
authorJosh Poimboeuf <jpoimboe@kernel.org>
Wed, 17 Sep 2025 16:03:39 +0000 (09:03 -0700)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Tue, 14 Oct 2025 21:46:47 +0000 (14:46 -0700)
In preparation for the objtool klp diff subcommand, introduce a flag to
identify __pfx_*() and __cfi_*() functions in advance so they don't need
to be manually identified every time a check is needed.

Acked-by: Petr Mladek <pmladek@suse.com>
Tested-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
tools/objtool/check.c
tools/objtool/elf.c
tools/objtool/include/objtool/elf.h

index 86f6e4da536c2527d55335c5e0834848fa37bbbc..46b425fade4f06dac1bc4a4327e8a433e0899f7b 100644 (file)
@@ -3568,10 +3568,7 @@ static int validate_branch(struct objtool_file *file, struct symbol *func,
 
                if (func && insn_func(insn) && func != insn_func(insn)->pfunc) {
                        /* Ignore KCFI type preambles, which always fall through */
-                       if (!strncmp(func->name, "__cfi_", 6) ||
-                           !strncmp(func->name, "__pfx_", 6) ||
-                           !strncmp(func->name, "__pi___cfi_", 11) ||
-                           !strncmp(func->name, "__pi___pfx_", 11))
+                       if (is_prefix_func(func))
                                return 0;
 
                        if (file->ignore_unreachables)
index 59568381486c90030f6c6a33c5faed39ecdf18a5..775d017b1b79b0c7557d4734b5a0cd74ad0698dc 100644 (file)
@@ -442,6 +442,13 @@ static void elf_add_symbol(struct elf *elf, struct symbol *sym)
        elf_hash_add(symbol, &sym->hash, sym->idx);
        elf_hash_add(symbol_name, &sym->name_hash, str_hash(sym->name));
 
+       if (is_func_sym(sym) &&
+           (strstarts(sym->name, "__pfx_") ||
+            strstarts(sym->name, "__cfi_") ||
+            strstarts(sym->name, "__pi___pfx_") ||
+            strstarts(sym->name, "__pi___cfi_")))
+               sym->prefix = 1;
+
        if (is_func_sym(sym) && strstr(sym->name, ".cold"))
                sym->cold = 1;
        sym->pfunc = sym->cfunc = sym;
index dbadcc88a3b2687cb7a2f2b8a70325067a35a536..79edf82e76ddfb532a3f5879ae0d336bace2ad6a 100644 (file)
@@ -73,6 +73,7 @@ struct symbol {
        u8 ignore            : 1;
        u8 nocfi             : 1;
        u8 cold              : 1;
+       u8 prefix            : 1;
        struct list_head pv_target;
        struct reloc *relocs;
        struct section *group_sec;
@@ -230,6 +231,11 @@ static inline bool is_local_sym(struct symbol *sym)
        return sym->bind == STB_LOCAL;
 }
 
+static inline bool is_prefix_func(struct symbol *sym)
+{
+       return sym->prefix;
+}
+
 static inline bool is_reloc_sec(struct section *sec)
 {
        return sec->sh.sh_type == SHT_RELA || sec->sh.sh_type == SHT_REL;