summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/symbol-elf.c
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2023-01-20 13:34:49 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2023-01-22 22:10:07 +0100
commitb08b20c3098832a4ffc22222ab742179b1f8514b (patch)
tree703c9cd30a126252abb5d1a48f82854343297602 /tools/perf/util/symbol-elf.c
parentperf symbols: Factor out get_plt_sizes() (diff)
downloadlinux-b08b20c3098832a4ffc22222ab742179b1f8514b.tar.xz
linux-b08b20c3098832a4ffc22222ab742179b1f8514b.zip
perf symbols: Check plt_entry_size is not zero
The code expects non-zero plt_entry_size. Check it and add a debug message to print if it is zero. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Acked-by: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20230120123456.12449-4-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol-elf.c')
-rw-r--r--tools/perf/util/symbol-elf.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index 4605680a22a3..c6a4e6c73990 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -323,30 +323,33 @@ static char *demangle_sym(struct dso *dso, int kmodule, const char *elf_name)
return demangled;
}
-static void get_plt_sizes(GElf_Ehdr *ehdr, GElf_Shdr *shdr_plt,
+static bool get_plt_sizes(struct dso *dso, GElf_Ehdr *ehdr, GElf_Shdr *shdr_plt,
u64 *plt_header_size, u64 *plt_entry_size)
{
switch (ehdr->e_machine) {
case EM_ARM:
*plt_header_size = 20;
*plt_entry_size = 12;
- return;
+ return true;
case EM_AARCH64:
*plt_header_size = 32;
*plt_entry_size = 16;
- return;
+ return true;
case EM_SPARC:
*plt_header_size = 48;
*plt_entry_size = 12;
- return;
+ return true;
case EM_SPARCV9:
*plt_header_size = 128;
*plt_entry_size = 32;
- return;
+ return true;
default: /* FIXME: s390/alpha/mips/parisc/poperpc/sh/xtensa need to be checked */
*plt_header_size = shdr_plt->sh_entsize;
*plt_entry_size = shdr_plt->sh_entsize;
- return;
+ if (*plt_entry_size)
+ return true;
+ pr_debug("Missing PLT entry size for %s\n", dso->long_name);
+ return false;
}
}
@@ -438,7 +441,8 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
nr_rel_entries = shdr_rel_plt.sh_size / shdr_rel_plt.sh_entsize;
plt_offset = shdr_plt.sh_offset;
- get_plt_sizes(&ehdr, &shdr_plt, &plt_header_size, &plt_entry_size);
+ if (!get_plt_sizes(dso, &ehdr, &shdr_plt, &plt_header_size, &plt_entry_size))
+ return 0;
plt_offset += plt_header_size;
if (shdr_rel_plt.sh_type == SHT_RELA) {