[PATCH v1 2/9] perf symbol: Reduce scope of arch__sym_update

From: Ian Rogers

Date: Sat Nov 22 2025 - 21:32:33 EST


Rather than being a weak arch function, use the e_machine from the ELF
header to determine whether to update or not. This should make the
function work cross-platform, it also reduces the function's scope.

Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/arch/powerpc/util/sym-handling.c | 7 -------
tools/perf/util/symbol-elf.c | 9 ++++++---
tools/perf/util/symbol.h | 4 ----
3 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/tools/perf/arch/powerpc/util/sym-handling.c b/tools/perf/arch/powerpc/util/sym-handling.c
index 947bfad7aa59..afefa9bd0c93 100644
--- a/tools/perf/arch/powerpc/util/sym-handling.c
+++ b/tools/perf/arch/powerpc/util/sym-handling.c
@@ -66,13 +66,6 @@ const char *arch__normalize_symbol_name(const char *name)

#if defined(_CALL_ELF) && _CALL_ELF == 2

-#ifdef HAVE_LIBELF_SUPPORT
-void arch__sym_update(struct symbol *s, GElf_Sym *sym)
-{
- s->arch_sym = sym->st_other;
-}
-#endif
-
#define PPC64LE_LEP_OFFSET 8

void arch__fix_tev_from_maps(struct perf_probe_event *pev,
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 5cd4844f9bb4..629b272e0a13 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1337,8 +1337,11 @@ static u64 ref_reloc(struct kmap *kmap)
return 0;
}

-void __weak arch__sym_update(struct symbol *s __maybe_unused,
- GElf_Sym *sym __maybe_unused) { }
+static void arch__sym_update(int e_machine, const GElf_Sym *sym, struct symbol *s)
+{
+ if (e_machine == EM_PPC64 || e_machine == EM_PPC)
+ s->arch_sym = sym->st_other;
+}

static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
GElf_Sym *sym, GElf_Shdr *shdr,
@@ -1717,7 +1720,7 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss,
if (!f)
goto out_elf_end;

- arch__sym_update(f, &sym);
+ arch__sym_update(ehdr.e_machine, &sym, f);

__symbols__insert(dso__symbols(curr_dso), f, dso__kernel(dso));
nr++;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index d91dc89386e2..78fb2ba69f65 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -216,10 +216,6 @@ int setup_list(struct strlist **list, const char *list_str,
int setup_intlist(struct intlist **list, const char *list_str,
const char *list_name);

-#ifdef HAVE_LIBELF_SUPPORT
-void arch__sym_update(struct symbol *s, GElf_Sym *sym);
-#endif
-
const char *arch__normalize_symbol_name(const char *name);
#define SYMBOL_A 0
#define SYMBOL_B 1
--
2.52.0.rc2.455.g230fcf2819-goog