perf symbol: Fix symbol loading from libbfd
Namhyung Kim
maintainerPATCH 1/2 perf symbol: Fix symbol loading from libbfd
The dso__load() should return a positive number (number of symbols loaded) when it succeded to load symbols. But dso__load_bfd_symbols() only returns 0 and it's hard to check if it actually loaded symbols or not. Let's return the value of dso__has_symbol() and check it in dso__load() so that it can return 1 for success.
Reported-by Sashiko <[email protected]>
Fixes eac9a4342e5447cad ("perf symbols: Try reading the symbol table with libbfd")
Signed-off-by Namhyung Kim <[email protected]>
--- tools/perf/util/libbfd.c | 2 +- tools/perf/util/symbol.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/libbfd.c +1 -1
@@ -463,7 +463,7 @@ int dso__load_bfd_symbols(struct dso *dso, const char *debugfile)symbols__fixup_duplicate (dso__symbols (dso));dso__set_adjust_symbols (dso, true); - err =0 ; + err =dso__has_symbols (dso); out_free:free (symbols); out_close:
tools/perf/util/symbol.c +2 -2
@@ -1933,9 +1933,9 @@ int dso__load(struct dso *dso, struct map *map)if (nsexit)nsinfo__mountns_enter (dso__nsinfo (dso), &nsc); -if (bfdrc ==0 ) { +if (bfdrc >0 ) {dso__set_symtab_type (dso, symtab_type); - ret =0 ; + ret =1 ;break ; }
Signature · 1 line
2.55.0
Namhyung Kim
maintainerPATCH 2/2 perf symbol: Add missing symsrc__destroy() for libbfd
When libbfd loaded symbols and there's a pending syms_ss, it'd be lost or overwrite existing symbols. Let's destroy it before breaking the loop so that it can safely return from the function.
Reported-by Sashiko <[email protected]>
Fixes eac9a4342e5447cad ("perf symbols: Try reading the symbol table with libbfd")
Signed-off-by Namhyung Kim <[email protected]>
--- tools/perf/util/symbol.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/perf/util/symbol.c +4 -0
@@ -1935,6 +1935,10 @@ int dso__load(struct dso *dso, struct map *map)if (bfdrc >0 ) {dso__set_symtab_type (dso, symtab_type); +if (syms_ss) { +symsrc__destroy (syms_ss); + syms_ss =NULL ; + } ret =1 ;break ; }
Signature · 1 line
2.55.0