[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <i6slsoiymyay2mvudrkzdqj7rgsd2voks62su3gmeeyu54gmz4@3twhehxrimyt>
Date: Mon, 17 Nov 2025 13:43:23 -0800
From: Josh Poimboeuf <jpoimboe@...nel.org>
To: xur@...gle.com
Cc: Peter Zijlstra <peterz@...radead.org>, linux-kernel@...r.kernel.org,
Sriraman Tallam <tmsriram@...gle.com>, Han Shen <shenhan@...gle.com>,
Krzysztof Pszeniczny <kpszeniczny@...gle.com>
Subject: Re: [PATCH v2 2/2] objtool: dead_end function change for split
functions
On Mon, Nov 03, 2025 at 09:52:44PM +0000, xur@...gle.com wrote:
> From: Rong Xu <xur@...gle.com>
>
> 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@...gle.com>
> Reviewed-by: Sriraman Tallam <tmsriram@...gle.com>
> Reviewed-by: Han Shen <shenhan@...gle.com>
> Reviewed-by: Krzysztof Pszeniczny <kpszeniczny@...gle.com>
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);
Powered by blists - more mailing lists