From: Ian Rogers <irogers@google.com>
To: "Peter Zijlstra" <peterz@infradead.org>,
"Ingo Molnar" <mingo@redhat.com>,
"Arnaldo Carvalho de Melo" <acme@kernel.org>,
"Namhyung Kim" <namhyung@kernel.org>,
"Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
"Jiri Olsa" <jolsa@kernel.org>, "Ian Rogers" <irogers@google.com>,
"Adrian Hunter" <adrian.hunter@intel.com>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"Mike Leach" <mike.leach@linaro.org>,
"James Clark" <james.clark@linaro.org>,
"John Garry" <john.g.garry@oracle.com>,
"Will Deacon" <will@kernel.org>, "Leo Yan" <leo.yan@linux.dev>,
"Athira Rajeev" <atrajeev@linux.ibm.com>,
tanze <tanze@kylinos.cn>,
"Stephen Brennan" <stephen.s.brennan@oracle.com>,
"Andi Kleen" <ak@linux.intel.com>,
"Chun-Tse Shao" <ctshao@google.com>,
"Thomas Falcon" <thomas.falcon@intel.com>,
"Dapeng Mi" <dapeng1.mi@linux.intel.com>,
"Dr. David Alan Gilbert" <linux@treblig.org>,
"Christophe Leroy" <christophe.leroy@csgroup.eu>,
"Krzysztof Łopatowski" <krzysztof.m.lopatowski@gmail.com>,
"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
"Alexandre Ghiti" <alexghiti@rivosinc.com>,
"Haibo Xu" <haibo1.xu@intel.com>,
"Sergei Trofimovich" <slyich@gmail.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: [PATCH v2 02/10] perf symbol: Reduce scope of arch__sym_update
Date: Mon, 1 Dec 2025 12:55:01 -0800 [thread overview]
Message-ID: <20251201205509.195451-3-irogers@google.com> (raw)
In-Reply-To: <20251201205509.195451-1-irogers@google.com>
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.
Note, the previous PPC code would compile both for 32 and 64-bit and
when _CALL_ELF==2. Similar testing could be done using the ELF file's
e_machine for PPC32 and e_flags for not EF_PPC_EMB. It can also be
done on the symbol for a non-zero st_other. Given we're just copying
the value, which would otherwise be 0, there's no need to introduce a
st_other != 0 test. The value is only used in arch__fix_tev_from_maps
on PowerPC in the PPC64_LOCAL_ENTRY_OFFSET macro, where 64-bit is
assumed.
Signed-off-by: Ian Rogers <irogers@google.com>
---
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 f661ea6c8ac2..99b1e060acf5 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -1338,8 +1338,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)
+ s->arch_sym = sym->st_other;
+}
static int dso__process_kernel_symbol(struct dso *dso, struct map *map,
GElf_Sym *sym, GElf_Shdr *shdr,
@@ -1718,7 +1721,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 9aa0016937b7..f12bb3d0e08b 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.158.g65b55ccf14-goog
next prev parent reply other threads:[~2025-12-01 20:55 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 20:54 [PATCH v2 00/10] perf: Refactor/add fallbacks for reading build-id and debuglink Ian Rogers
2025-12-01 20:55 ` [PATCH v2 01/10] perf symbol: Reduce scope of elf__needs_adjust_symbols Ian Rogers
2025-12-01 20:55 ` Ian Rogers [this message]
2025-12-01 20:55 ` [PATCH v2 03/10] perf symbol: Move libelf code to its own file/header Ian Rogers
2025-12-01 20:55 ` [PATCH v2 04/10] perf symbol: Remove unused includes Ian Rogers
2025-12-01 20:55 ` [PATCH v2 05/10] perf symbol: Move dso__load_bfd_symbols out of symbol.h Ian Rogers
2025-12-01 20:55 ` [PATCH v2 06/10] perf symbol: Use fallbacks with filename__read_build_id Ian Rogers
2025-12-01 20:55 ` [PATCH v2 07/10] perf symbol: Use fallbacks for filename__read_debuglink Ian Rogers
2025-12-01 20:55 ` [PATCH v2 08/10] perf symbol: Make a common sysfs__read_build_id Ian Rogers
2025-12-01 20:55 ` [PATCH v2 09/10] perf dso: Move type helpers out of symbol and use fallbacks Ian Rogers
2025-12-01 20:55 ` [PATCH v2 10/10] perf symbol: Fix ENOENT case for filename__read_build_id Ian Rogers
2025-12-05 19:40 ` Ian Rogers
2025-12-05 21:18 ` Namhyung Kim
2025-12-07 2:28 ` Ian Rogers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251201205509.195451-3-irogers@google.com \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexghiti@rivosinc.com \
--cc=atrajeev@linux.ibm.com \
--cc=christophe.leroy@csgroup.eu \
--cc=ctshao@google.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=haibo1.xu@intel.com \
--cc=james.clark@linaro.org \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=krzysztof.m.lopatowski@gmail.com \
--cc=leo.yan@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux@treblig.org \
--cc=mhiramat@kernel.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=slyich@gmail.com \
--cc=stephen.s.brennan@oracle.com \
--cc=suzuki.poulose@arm.com \
--cc=tanze@kylinos.cn \
--cc=thomas.falcon@intel.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).