* [PATCH v1] perf symbol-elf: Avoid a weak cxx_demangle_sym function
@ 2024-11-19 3:17 Ian Rogers
2025-01-09 17:58 ` Ian Rogers
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2024-11-19 3:17 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, linux-perf-users,
linux-kernel
cxx_demangle_sym is weak in case demangle-cxx.c replaces the
definition in symbol-elf.c. When demangle-cxx.c is built
HAVE_CXA_DEMANGLE_SUPPORT is defined, as such the define can be used
to avoid a weak symbol. As weak symbols are outside of the C standard
their use can lead to strange behaviors, in particular with LTO, as
well as causing issues to be hidden at link time.
Signed-off-by: Ian Rogers <irogers@google.com>
---
tools/perf/util/symbol-elf.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index e398abfd13a0..66fd1249660a 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -287,8 +287,9 @@ static bool want_demangle(bool is_kernel_sym)
* Demangle C++ function signature, typically replaced by demangle-cxx.cpp
* version.
*/
-__weak char *cxx_demangle_sym(const char *str __maybe_unused, bool params __maybe_unused,
- bool modifiers __maybe_unused)
+#ifndef HAVE_CXA_DEMANGLE_SUPPORT
+char *cxx_demangle_sym(const char *str __maybe_unused, bool params __maybe_unused,
+ bool modifiers __maybe_unused)
{
#ifdef HAVE_LIBBFD_SUPPORT
int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
@@ -302,6 +303,7 @@ __weak char *cxx_demangle_sym(const char *str __maybe_unused, bool params __mayb
return NULL;
#endif
}
+#endif /* !HAVE_CXA_DEMANGLE_SUPPORT */
static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
{
--
2.47.0.338.g60cca15819-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] perf symbol-elf: Avoid a weak cxx_demangle_sym function
2024-11-19 3:17 [PATCH v1] perf symbol-elf: Avoid a weak cxx_demangle_sym function Ian Rogers
@ 2025-01-09 17:58 ` Ian Rogers
2025-01-09 21:12 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2025-01-09 17:58 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, linux-perf-users,
linux-kernel
On Mon, Nov 18, 2024 at 7:17 PM Ian Rogers <irogers@google.com> wrote:
>
> cxx_demangle_sym is weak in case demangle-cxx.c replaces the
> definition in symbol-elf.c. When demangle-cxx.c is built
> HAVE_CXA_DEMANGLE_SUPPORT is defined, as such the define can be used
> to avoid a weak symbol. As weak symbols are outside of the C standard
> their use can lead to strange behaviors, in particular with LTO, as
> well as causing issues to be hidden at link time.
>
> Signed-off-by: Ian Rogers <irogers@google.com>
Ping.
Thanks,
Ian
> ---
> tools/perf/util/symbol-elf.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
> index e398abfd13a0..66fd1249660a 100644
> --- a/tools/perf/util/symbol-elf.c
> +++ b/tools/perf/util/symbol-elf.c
> @@ -287,8 +287,9 @@ static bool want_demangle(bool is_kernel_sym)
> * Demangle C++ function signature, typically replaced by demangle-cxx.cpp
> * version.
> */
> -__weak char *cxx_demangle_sym(const char *str __maybe_unused, bool params __maybe_unused,
> - bool modifiers __maybe_unused)
> +#ifndef HAVE_CXA_DEMANGLE_SUPPORT
> +char *cxx_demangle_sym(const char *str __maybe_unused, bool params __maybe_unused,
> + bool modifiers __maybe_unused)
> {
> #ifdef HAVE_LIBBFD_SUPPORT
> int flags = (params ? DMGL_PARAMS : 0) | (modifiers ? DMGL_ANSI : 0);
> @@ -302,6 +303,7 @@ __weak char *cxx_demangle_sym(const char *str __maybe_unused, bool params __mayb
> return NULL;
> #endif
> }
> +#endif /* !HAVE_CXA_DEMANGLE_SUPPORT */
>
> static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
> {
> --
> 2.47.0.338.g60cca15819-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] perf symbol-elf: Avoid a weak cxx_demangle_sym function
2025-01-09 17:58 ` Ian Rogers
@ 2025-01-09 21:12 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2025-01-09 21:12 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Namhyung Kim, Mark Rutland,
Alexander Shishkin, Jiri Olsa, Adrian Hunter, Kan Liang,
linux-perf-users, linux-kernel
On Thu, Jan 09, 2025 at 09:58:34AM -0800, Ian Rogers wrote:
> On Mon, Nov 18, 2024 at 7:17 PM Ian Rogers <irogers@google.com> wrote:
> >
> > cxx_demangle_sym is weak in case demangle-cxx.c replaces the
> > definition in symbol-elf.c. When demangle-cxx.c is built
> > HAVE_CXA_DEMANGLE_SUPPORT is defined, as such the define can be used
> > to avoid a weak symbol. As weak symbols are outside of the C standard
> > their use can lead to strange behaviors, in particular with LTO, as
> > well as causing issues to be hidden at link time.
> >
> > Signed-off-by: Ian Rogers <irogers@google.com>
>
> Ping.
Thanks, applied to perf-tools-next,
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-09 21:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-19 3:17 [PATCH v1] perf symbol-elf: Avoid a weak cxx_demangle_sym function Ian Rogers
2025-01-09 17:58 ` Ian Rogers
2025-01-09 21:12 ` Arnaldo Carvalho de Melo
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).