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

perf symbols: Allow for .plt without header

A static executable can have a .plt due to the presence of IFUNCs.  In
that case the .plt does not have a header. Check for whether there is a
header by comparing the number of entries to the number of relocation
entries.
Reviewed-by: default avatarNamhyung Kim <namhyung@kernel.org>
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20230131131625.6964-7-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b7dbc0be
...@@ -489,6 +489,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -489,6 +489,7 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
Elf *elf; Elf *elf;
int nr = 0, err = -1; int nr = 0, err = -1;
struct rel_info ri = { .is_rela = false }; struct rel_info ri = { .is_rela = false };
bool lazy_plt;
elf = ss->elf; elf = ss->elf;
ehdr = ss->ehdr; ehdr = ss->ehdr;
...@@ -523,8 +524,10 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -523,8 +524,10 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss)
plt_sym->end = plt_sym->start + shdr_plt.sh_size; plt_sym->end = plt_sym->start + shdr_plt.sh_size;
/* Use .plt.sec offset */ /* Use .plt.sec offset */
plt_offset = plt_sec_shdr.sh_offset; plt_offset = plt_sec_shdr.sh_offset;
lazy_plt = false;
} else { } else {
plt_offset = shdr_plt.sh_offset + plt_header_size; plt_offset = shdr_plt.sh_offset;
lazy_plt = true;
} }
scn_dynsym = ss->dynsym; scn_dynsym = ss->dynsym;
...@@ -577,6 +580,17 @@ int dso__synthesize_plt_symbols(struct dso *dso, struct symsrc *ss) ...@@ -577,6 +580,17 @@ 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 (lazy_plt) {
/*
* Assume a .plt with the same number of entries as the number
* of relocation entries is not lazy and does not have a header.
*/
if (ri.nr_entries * plt_entry_size == shdr_plt.sh_size)
dso__delete_symbol(dso, plt_sym);
else
plt_offset += plt_header_size;
}
/* /*
* x86 doesn't insert IFUNC relocations in .plt order, so sort to get * x86 doesn't insert IFUNC relocations in .plt order, so sort to get
* back in order. * back in order.
......
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