[PATCH 4/4] perf report: Fix return value when loading PE DSO

From: Nicholas Fraser
Date: Wed Feb 10 2021 - 14:40:20 EST


The first time dso__load() was called on a PE file it always returned -1
error. This caused the first call to map__find_symbol() to always fail
on a PE file so the first sample from each PE file always had symbol
<unknown>. Subsequent samples succeed however because the DSO is already
loaded.

This fixes dso__load() to return 0 when successfully loading a DSO with
libbfd.

Signed-off-by: Nicholas Fraser <nfraser@xxxxxxxxxxxxxxx>
---
tools/perf/util/symbol.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index aa9ae875b995..492c873713cc 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1861,8 +1861,10 @@ int dso__load(struct dso *dso, struct map *map)
if (nsexit)
nsinfo__mountns_enter(dso->nsinfo, &nsc);

- if (bfdrc == 0)
+ if (bfdrc == 0) {
+ ret = 0;
break;
+ }

if (!is_reg || sirc < 0)
continue;
--
2.30.0