Commit df8aeaef authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf symbols: Check SHT_RELA and SHT_REL type earlier

Make the code more readable by checking for SHT_RELA and SHT_REL type
earlier.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Acked-by: default avatarIan Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20230120123456.12449-11-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 375a4481
...@@ -434,6 +434,10 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -434,6 +434,10 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
return 0; return 0;
} }
if (shdr_rel_plt.sh_type != SHT_RELA &&
shdr_rel_plt.sh_type != SHT_REL)
return 0;
if (shdr_rel_plt.sh_link != dynsym_idx) if (shdr_rel_plt.sh_link != dynsym_idx)
goto out_elf_end; goto out_elf_end;
...@@ -466,8 +470,6 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -466,8 +470,6 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
ri.is_rela = shdr_rel_plt.sh_type == SHT_RELA; ri.is_rela = shdr_rel_plt.sh_type == SHT_RELA;
if (shdr_rel_plt.sh_type == SHT_RELA ||
shdr_rel_plt.sh_type == SHT_REL) {
for (idx = 0; idx < nr_rel_entries; idx++) { for (idx = 0; idx < nr_rel_entries; idx++) {
const char *elf_name = NULL; const char *elf_name = NULL;
char *demangled = NULL; char *demangled = NULL;
...@@ -476,7 +478,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -476,7 +478,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
elf_name = elf_sym__name(&sym, symstrs); elf_name = elf_sym__name(&sym, symstrs);
demangled = demangle_sym(dso, 0, elf_name); demangled = demangle_sym(dso, 0, elf_name);
if (demangled != NULL) if (demangled)
elf_name = demangled; elf_name = demangled;
if (*elf_name) if (*elf_name)
snprintf(sympltname, sizeof(sympltname), "%s@plt", elf_name); snprintf(sympltname, sizeof(sympltname), "%s@plt", elf_name);
...@@ -485,8 +487,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -485,8 +487,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
"offset_%#" PRIx64 "@plt", plt_offset); "offset_%#" PRIx64 "@plt", plt_offset);
free(demangled); free(demangled);
f = symbol__new(plt_offset, plt_entry_size, f = symbol__new(plt_offset, plt_entry_size, STB_GLOBAL, STT_FUNC, sympltname);
STB_GLOBAL, STT_FUNC, sympltname);
if (!f) if (!f)
goto out_elf_end; goto out_elf_end;
...@@ -494,7 +495,6 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -494,7 +495,6 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
symbols__insert(&dso->symbols, f); symbols__insert(&dso->symbols, f);
++nr; ++nr;
} }
}
err = 0; err = 0;
out_elf_end: out_elf_end:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment