linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Adrian Hunter <adrian.hunter@intel.com>,
	Will Deacon <will.deacon@arm.com>,
	acme@redhat.com
Cc: linux-kernel@vger.kernel.org, kristina.martsenko@arm.com,
	Vladimir Nikulichev <nvs@tbricks.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Andy Lutomirski <luto@amacapital.net>
Subject: Re: [PATCH v2] perf tools: don't adjust symbols in vDSO
Date: Mon, 29 Jun 2015 15:30:15 +0300	[thread overview]
Message-ID: <55913A57.2000602@intel.com> (raw)
In-Reply-To: <55910989.8090608@intel.com>

On 29/06/15 12:02, Adrian Hunter wrote:
> On 27/06/15 12:10, Will Deacon wrote:
>> Commit 922d0e4d9f04 ("perf tools: Adjust symbols in VDSO") changed the
>> ELF symbol parsing so that the vDSO is treated the same as ET_EXEC and
>> ET_REL binaries despite being an ET_DYN. This was a partial workaround
>> to deal with older x86 vDSOs being prelinked at a high address that
>> didn't correspond to the map, so using object-relative offsets and
>> adding the base of the map allowed symbol resolution to succeed.
>>
>> Unfortunately, this causes objdump not to produce any output in
>> conjunction with perf annotate, which cheerfully passes the absolute
>> address of the map symbol.
>>
>> This patch fixes the problem by avoiding adjustment of vDSO symbols and
>> instead setting the map->pgoff field to correspond to the virtual load
>> address specified in the vDSO ELF header.
>>
>> Cc: Vladimir Nikulichev <nvs@tbricks.com>
>> Cc: Adrian Hunter <adrian.hunter@intel.com>
>> Cc: Namhyung Kim <namhyung@kernel.org>
>> Cc: Andy Lutomirski <luto@amacapital.net>
>> Reported-by: Kristina Martsenko <kristina.martsenko@arm.com>
>> Signed-off-by: Will Deacon <will.deacon@arm.com>
>> ---
>>
>> v1->v2: Adjust map->pgoff in ELF loader to avoid breaking symbol lookup
>>         on older kernels.
>>
>>  tools/perf/util/map.c        | 5 ++---
>>  tools/perf/util/symbol-elf.c | 9 ++++++++-
>>  2 files changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
>> index a14f08f41686..6ba38293be88 100644
>> --- a/tools/perf/util/map.c
>> +++ b/tools/perf/util/map.c
>> @@ -173,10 +173,9 @@ struct map *map__new(struct machine *machine, u64 start, u64 len,
>>  				filename = newfilename;
>>  		}
>>  
>> -		if (vdso) {
>> -			pgoff = 0;
>> +		if (vdso)
>>  			dso = vdso__dso_findnew(machine, thread);
>> -		} else
>> +		else
>>  			dso = __dsos__findnew(&machine->user_dsos, filename);
>>  
>>  		if (dso == NULL)
>> diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
>> index a7ab6063e038..83f8ba232575 100644
>> --- a/tools/perf/util/symbol-elf.c
>> +++ b/tools/perf/util/symbol-elf.c
>> @@ -706,7 +706,6 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name,
>>  		GElf_Shdr shdr;
>>  		ss->adjust_symbols = (ehdr.e_type == ET_EXEC ||
>>  				ehdr.e_type == ET_REL ||
>> -				dso__is_vdso(dso) ||
>>  				elf_section_by_name(elf, &ehdr, &shdr,
>>  						     ".gnu.prelink_undo",
>>  						     NULL) != NULL);
>> @@ -824,6 +823,14 @@ int dso__load_sym(struct dso *dso, struct map *map,
>>  	sec = syms_ss->symtab;
>>  	shdr = syms_ss->symshdr;
>>  
>> +	/*
>> +	 * Older x86 kernels prelink the vDSO at a high address, so
>> +	 * we need to reflect that in map->pgoff in order to talk to
>> +	 * objdump.
>> +	 */
>> +	if (dso__is_vdso(dso))
>> +		map->pgoff = shdr.sh_addr - shdr.sh_offset;
> 
> In the case of perf tools, maps map memory addresses to file offsets.
> That is used to read from the object file, so you can't change the map.

So what about just this instead:

	if (dso__is_vdso(dso))
		map->reloc = shdr.sh_addr - shdr.sh_offset;

Although shdr is ".dynsym" whereas ".text" is what we typically care about.
Don't know if they could be inconsistent.


  reply	other threads:[~2015-06-29 12:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-27  9:10 [PATCH v2] perf tools: don't adjust symbols in vDSO Will Deacon
2015-06-29  9:02 ` Adrian Hunter
2015-06-29 12:30   ` Adrian Hunter [this message]
2015-06-29 13:23     ` Adrian Hunter
2015-06-29 13:52       ` Will Deacon
2015-06-29 14:55         ` acme
2015-06-30  9:57         ` Adrian Hunter
2015-06-30 10:47           ` Will Deacon
2015-07-09 10:12           ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55913A57.2000602@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@redhat.com \
    --cc=kristina.martsenko@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=namhyung@kernel.org \
    --cc=nvs@tbricks.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).