On Wed, Feb 25, 2026 at 04:54:35PM -0800, Song Liu wrote:
> Allow correlating original locals to patched globals, and vice versa.
> This is needed when:
>
> 1. User adds/removes "static" for a function.
> 2. CONFIG_LTO_CLANG_THIN promotes local functions and objects to global
> and add .llvm.<hash> suffix.
>
> Given this is a less common scenario, show warnings when this is needed.
>
> Signed-off-by: Song Liu <[email protected]>
> ---
> tools/objtool/klp-diff.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/tools/objtool/klp-diff.c b/tools/objtool/klp-diff.c
> index 92043da0ed0b..5cda965807a5 100644
> --- a/tools/objtool/klp-diff.c
> +++ b/tools/objtool/klp-diff.c
> @@ -517,6 +517,40 @@ static int correlate_symbols(struct elfs *e)
> }
> }
>
> + /* Correlate original locals with patched globals */
> + for_each_sym(e->orig, sym1) {
> + if (sym1->twin || dont_correlate(sym1) || !is_local_sym(sym1))
> + continue;
> +
> + sym2 = find_global_symbol_by_name(e->patched, sym1->name);
> + if (!sym2 && find_global_symbol_by_demangled_name(e->patched,
> sym1, &sym2))
> + return -1;
> +
> + if (sym2 && !sym2->twin) {
> + sym1->twin = sym2;
> + sym2->twin = sym1;
> + WARN("correlate LOCAL %s (original) to GLOBAL %s
> (patched)",
> + sym1->name, sym2->name);
I think this correlation is deterministic so there's no need for the
warning?
> + }
> + }
> +
> + /* Correlate original globals with patched locals */
> + for_each_sym(e->patched, sym2) {
> + if (sym2->twin || dont_correlate(sym2) || !is_local_sym(sym2))
> + continue;
> +
> + sym1 = find_global_symbol_by_name(e->orig, sym2->name);
> + if (!sym1 && find_global_symbol_by_demangled_name(e->orig,
> sym2, &sym1))
> + return -1;
> +
> + if (sym1 && !sym1->twin) {
> + sym2->twin = sym1;
> + sym1->twin = sym2;
> + WARN("correlate GLOBAL %s (origial) to LOCAL %s
> (patched)",
> + sym1->name, sym2->name);
> + }
Ditto.
--
Josh