Re: [PATCH v2 2/2] objtool: dead_end function change for split functions

From: Josh Poimboeuf
Date: Mon Nov 17 2025 - 16:44:50 EST


On Mon, Nov 03, 2025 at 09:52:44PM +0000, xur@xxxxxxxxxx wrote:
> From: Rong Xu <xur@xxxxxxxxxx>
>
> Function Splitting can potentially move all return instructions
> into the cold (infrequently executed) section of the function.
> If this happens, the original function might be incorrectly
> flagged as a dead-end function.
>
> The consequence is an incomplete ORC table, which leads to an unwind
> error, and subsequently, a livepatch failure.

I assume there were also some ignored objtool warnings? Ignoring those
can have catastrophic consequences (beyond just failing livepatches) so
I highly recommend building with CONFIG_OBJTOOL_WERROR.

> This patch adds the support of the dead_end_function check for
> split function.
>
> Signed-off-by: Rong Xu <xur@xxxxxxxxxx>
> Reviewed-by: Sriraman Tallam <tmsriram@xxxxxxxxxx>
> Reviewed-by: Han Shen <shenhan@xxxxxxxxxx>
> Reviewed-by: Krzysztof Pszeniczny <kpszeniczny@xxxxxxxxxx>

I was scratching my head about this one for a while. .text.split.<func>
is for <func>.cold code, which should automatically get iterated by the
outer func_for_each_insn() construct in __dead_end_function(). So this
patch shouldn't be necessary.

After some testing with Clang -fsplit-machine-functions, I'm realizing
the problem is that unlike GCC, Clang .cold code (in .text.split.*)
isn't STT_FUNC. Which breaks several objtool assumptions. So something
like the below is needed.

I've also discovered a few more .cold-related issues... working on
fixing those.

diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 3f20b257ab25..ab2d4fe37fb3 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -502,8 +502,11 @@ static int elf_add_symbol(struct elf *elf, struct symbol *sym)
if (strstarts(sym->name, ".klp.sym"))
sym->klp = 1;

- if (!sym->klp && is_func_sym(sym) && strstr(sym->name, ".cold"))
+ if (!sym->klp && is_func_sym(sym) && strstr(sym->name, ".cold")) {
sym->cold = 1;
+ sym->type = STT_FUNC;
+ }
+
sym->pfunc = sym->cfunc = sym;

sym->demangled_name = demangle_name(sym);