Only one callsite of dso__load_sym() uses the want_symtab functionality, so place the logic at the callsite instead of within dso__load_sym().
This sets us up for removal of want_symtab completely once we keep multiple elf handles (within symsrc's) around. Setup for the later patch "perf symbol: use both runtime and debug images" Signed-off-by: Cody P Schafer <c...@linux.vnet.ibm.com> --- tools/perf/util/symbol.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index f8fbde2..83d2276 100644 --- a/tools/perf/util/symbol.c +++ b/tools/perf/util/symbol.c @@ -1320,8 +1320,7 @@ static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr) } static int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss, - symbol_filter_t filter, int kmodule, - int want_symtab) + symbol_filter_t filter, int kmodule) { struct kmap *kmap = dso->kernel ? map__kmap(map) : NULL; struct map *curr_map = map; @@ -1346,16 +1345,6 @@ static int dso__load_sym(struct dso *dso, struct map *map, struct symsrc *ss, sec = ss->symtab; shdr = ss->symshdr; - if (sec == NULL) { - if (want_symtab) - goto out_elf_end; - - sec = ss->dynsym; - shdr = ss->dynshdr; - if (sec == NULL) - goto out_elf_end; - } - opdsec = ss->opdsec; opdshdr = ss->opdshdr; opdidx = ss->opdidx; @@ -1947,8 +1936,15 @@ restart: if (symsrc__init(&ss, dso, name, symtab_type) < 0) continue; - ret = dso__load_sym(dso, map, &ss, filter, 0, - want_symtab); + if (want_symtab && !ss.symtab) { + symsrc__destroy(&ss); + continue; + } else if (!want_symtab) { + ss.symtab = ss.dynsym; + ss.symshdr = ss.dynshdr; + } + + ret = dso__load_sym(dso, map, &ss, filter, 0); /* * Some people seem to have debuginfo files _WITHOUT_ debug @@ -2253,7 +2249,7 @@ int dso__load_vmlinux(struct dso *dso, struct map *map, if (symsrc__init(&ss, dso, symfs_vmlinux, symtab_type)) return -1; - err = dso__load_sym(dso, map, &ss, filter, 0, 0); + err = dso__load_sym(dso, map, &ss, filter, 0); symsrc__destroy(&ss); if (err > 0) { -- 1.7.11.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/