Skip to content

Commit 3687810

Browse files
captain5050acmel
authored andcommitted
perf symbol-elf: Avoid a weak cxx_demangle_sym function
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 <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 4f90ed0 commit 3687810

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/perf/util/symbol-elf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,9 @@ static bool want_demangle(bool is_kernel_sym)
287287
* Demangle C++ function signature, typically replaced by demangle-cxx.cpp
288288
* version.
289289
*/
290-
__weak char *cxx_demangle_sym(const char *str __maybe_unused, bool params __maybe_unused,
291-
bool modifiers __maybe_unused)
290+
#ifndef HAVE_CXA_DEMANGLE_SUPPORT
291+
char *cxx_demangle_sym(const char *str __maybe_unused, bool params __maybe_unused,
292+
bool modifiers __maybe_unused)
292293
{
293294
#ifdef HAVE_LIBBFD_SUPPORT
294295
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
302303
return NULL;
303304
#endif
304305
}
306+
#endif /* !HAVE_CXA_DEMANGLE_SUPPORT */
305307

306308
static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
307309
{

0 commit comments

Comments
 (0)