Skip to contentSkip to conversation

perf, tool: Read plt symbols from proper symtab_type binary

PATCH In review Jiri Olsa 1 participant 2 messages Apr 18, 2012 – Apr 25, 2012 perf events

lore
Share & tools
lore

Jiri Olsa

author
#0 lore raw

PATCH 1/1 perf, tool: Read plt symbols from proper symtab_type binary

When loading symbols from DSO we check multiple paths of DSO binary until we succeed to load symbols ('.symtab' section). Once symbols are read we try to load also plt symbols ('.dynsym' section).

During the reading of plt symbols, the dso file is reopened from location given by dso->long_name. This could be wrong in case we want process buildid binaries.

The change is to make the plt symbols being read from the DSO path, that normal symbols were read from.

---
 tools/perf/util/symbol.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +7 -7
index c0a028c..5988861 100644
@@ -977,8 +977,9 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
  * And always look at the original dso, not at debuginfo packages, that
  * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS).
  */
-static int dso__synthesize_plt_symbols(struct  dso *dso, struct map *map,
-				       symbol_filter_t filter)
+static int
+dso__synthesize_plt_symbols(char *name, struct dso *dso, struct map *map,
+			    symbol_filter_t filter)
 {
 	uint32_t nr_rel_entries, idx;
 	GElf_Sym sym;
@@ -993,10 +994,7 @@ static int dso__synthesize_plt_symbols(struct  dso *dso, struct map *map,
 	char sympltname[1024];
 	Elf *elf;
 	int nr = 0, symidx, fd, err = 0;
-	char name[PATH_MAX];
 
-	snprintf(name, sizeof(name), "%s%s",
-		 symbol_conf.symfs, dso->long_name);
 	fd = open(name, O_RDONLY);
 	if (fd < 0)
 		goto out;
@@ -1703,8 +1701,10 @@ restart:
 			continue;
 
 		if (ret > 0) {
-			int nr_plt = dso__synthesize_plt_symbols(dso, map,
-								 filter);
+			int nr_plt;
+
+			nr_plt = dso__synthesize_plt_symbols(name,
+					dso, map, filter);
 			if (nr_plt > 0)
 				ret += nr_plt;
 			break;
Signature · 1 line
1.7.7.6
#1 lore raw

[tip:perf/urgent] perf symbols: Read plt symbols from proper symtab_type binary

Commit-ID:  33ff581eddf744ea91a50d46c2f0961b375a9595
Gitweb:     http://git.kernel.org/tip/33ff581eddf744ea91a50d46c2f0961b375a9595
Author:     Jiri Olsa <[email protected]>
AuthorDate: Wed, 18 Apr 2012 15:46:58 +0200
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 20 Apr 2012 13:34:49 -0300

perf symbols: Read plt symbols from proper symtab_type binary

When loading symbols from DSO we check multiple paths of DSO binary until we succeed to load symbols ('.symtab' section). Once symbols are read we try to load also plt symbols.

During the reading of plt symbols, the dso file is reopened from location given by dso->long_name. This could be wrong in case we want process buildid binaries.

The change is to make the plt symbols being read from the DSO path, that normal symbols were read from.

Cc Corey Ashford <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Peter Zijlstra <[email protected]>
[ committer note: moved dso to be the first parameter of that function ]
---
 tools/perf/util/symbol.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +6 -7
index c0a028c..ab9867b 100644
@@ -977,8 +977,9 @@ static Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
  * And always look at the original dso, not at debuginfo packages, that
  * have the PLT data stripped out (shdr_rel_plt.sh_type == SHT_NOBITS).
  */
-static int dso__synthesize_plt_symbols(struct  dso *dso, struct map *map,
-				       symbol_filter_t filter)
+static int
+dso__synthesize_plt_symbols(struct dso *dso, char *name, struct map *map,
+			    symbol_filter_t filter)
 {
 	uint32_t nr_rel_entries, idx;
 	GElf_Sym sym;
@@ -993,10 +994,7 @@ static int dso__synthesize_plt_symbols(struct  dso *dso, struct map *map,
 	char sympltname[1024];
 	Elf *elf;
 	int nr = 0, symidx, fd, err = 0;
-	char name[PATH_MAX];
 
-	snprintf(name, sizeof(name), "%s%s",
-		 symbol_conf.symfs, dso->long_name);
 	fd = open(name, O_RDONLY);
 	if (fd < 0)
 		goto out;
@@ -1703,8 +1701,9 @@ restart:
 			continue;
 
 		if (ret > 0) {
-			int nr_plt = dso__synthesize_plt_symbols(dso, map,
-								 filter);
+			int nr_plt;
+
+			nr_plt = dso__synthesize_plt_symbols(dso, name, map, filter);
 			if (nr_plt > 0)
 				ret += nr_plt;
 			break;