[PATCH 32/48] objtool: Add is_cold_func() helper
From: Josh Poimboeuf
Date: Thu Apr 23 2026 - 00:18:27 EST
Add an is_cold_func() helper. The sym->cold bit is redundant and can be
removed.
No functional changes intended.
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
tools/objtool/check.c | 6 +++---
tools/objtool/elf.c | 9 +++++----
tools/objtool/include/objtool/elf.h | 6 +++++-
tools/objtool/klp-diff.c | 3 ++-
4 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 4c18d6e7f6c3..4ed27c53c718 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2614,7 +2614,7 @@ static void mark_holes(struct objtool_file *file)
if (insn->jump_dest) {
struct symbol *dest_func = insn_func(insn->jump_dest);
- if (dest_func && dest_func->cold)
+ if (dest_func && is_cold_func(dest_func))
dest_func->ignore = true;
}
}
@@ -4426,8 +4426,8 @@ static int create_prefix_symbol(struct objtool_file *file, struct symbol *func)
char name[SYM_NAME_LEN];
struct cfi_state *cfi;
- if (!is_func_sym(func) || is_prefix_func(func) ||
- func->cold || func->static_call_tramp)
+ if (!is_func_sym(func) || is_prefix_func(func) || is_cold_func(func) ||
+ func->static_call_tramp)
return 0;
if ((strlen(func->name) + sizeof("__pfx_") > SYM_NAME_LEN)) {
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 00c2389f345f..8a6e1338af97 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -586,8 +586,11 @@ static int elf_add_symbol(struct elf *elf, struct symbol *sym)
if (strstarts(sym->name, ".klp.sym"))
sym->klp = 1;
+ sym->pfunc = sym->cfunc = sym;
+
if (!sym->klp && !is_sec_sym(sym) && strstr(sym->name, ".cold")) {
- sym->cold = 1;
+ /* Tell read_symbols() this is a cold subfunction */
+ sym->pfunc = NULL;
/*
* Clang doesn't mark cold subfunctions as STT_FUNC, which
@@ -596,8 +599,6 @@ static int elf_add_symbol(struct elf *elf, struct symbol *sym)
sym->type = STT_FUNC;
}
- sym->pfunc = sym->cfunc = sym;
-
return 0;
}
@@ -695,7 +696,7 @@ static int read_symbols(struct elf *elf)
char *pname;
size_t pnamelen;
- if (!sym->cold)
+ if (sym->pfunc)
continue;
coldstr = strstr(sym->name, ".cold");
diff --git a/tools/objtool/include/objtool/elf.h b/tools/objtool/include/objtool/elf.h
index 3abe4cbc584c..82b9fb05af26 100644
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -83,7 +83,6 @@ struct symbol {
u8 frame_pointer : 1;
u8 ignore : 1;
u8 nocfi : 1;
- u8 cold : 1;
u8 prefix : 1;
u8 debug_checksum : 1;
u8 changed : 1;
@@ -289,6 +288,11 @@ static inline bool is_prefix_func(struct symbol *sym)
return sym->prefix;
}
+static inline bool is_cold_func(struct symbol *sym)
+{
+ return sym->pfunc != sym;
+}
+
static inline bool is_reloc_sec(struct section *sec)
{
return sec->sh.sh_type == SHT_RELA || sec->sh.sh_type == SHT_REL;
diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
index 1951a8b2df44..266f0d2ba4fe 100644
--- a/tools/objtool/klp-diff.c
+++ b/tools/objtool/klp-diff.c
@@ -1718,7 +1718,8 @@ static int create_klp_sections(struct elfs *e)
unsigned long sympos;
void *func_data;
- if (!is_func_sym(sym) || sym->cold || !sym->clone || !sym->clone->changed)
+ if (!is_func_sym(sym) || is_cold_func(sym) ||
+ !sym->clone || !sym->clone->changed)
continue;
/* allocate klp_func_ext */
--
2.53.0