Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1174420 > unrolled thread

Re: [PATCH v2] perf tools: don't adjust symbols in vDSO

Started byAdrian Hunter <adrian.hunter@intel.com>
First post2015-06-30 12:00 +0200
Last post2015-06-30 12:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2] perf tools: don't adjust symbols in vDSO Adrian Hunter <adrian.hunter@intel.com> - 2015-06-30 12:00 +0200
    Re: [PATCH v2] perf tools: don't adjust symbols in vDSO Will Deacon <will.deacon@arm.com> - 2015-06-30 12:50 +0200

#1174420 — Re: [PATCH v2] perf tools: don't adjust symbols in vDSO

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-06-30 12:00 +0200
SubjectRe: [PATCH v2] perf tools: don't adjust symbols in vDSO
Message-ID<pH0uB-6Fg-3@gated-at.bofh.it>
On 29/06/15 16:52, Will Deacon wrote:
> On Mon, Jun 29, 2015 at 02:23:51PM +0100, Adrian Hunter wrote:
>> On 29/06/15 15:30, Adrian Hunter wrote:
>>> On 29/06/15 12:02, Adrian Hunter wrote:
>>>> On 27/06/15 12:10, Will Deacon wrote:
>>>>> @@ -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;
>>>
>>
>> No that's no good either :-(
> 
> Yeah... we're fighting against symbol lookup wanting ->map_ip to give the
> address of the ELF symbol but unwinding wanting ->map_ip to give a relative
> offset for file reads.
> 
> Also, the reloc is a bit weird and I think needs to be the other way around
> (i.e. we convert from a map-relative address to an objdump address by
> *subtracting* the reloc). Even with that change, I run into problems with
> annotate comparing ELF symbol addresses with map addresses. Urgh.

Adding or subtracting shouldn't matter.

This seems to work (without any other changes):

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

Haven't tested 32-bit yet though.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1174433

FromWill Deacon <will.deacon@arm.com>
Date2015-06-30 12:50 +0200
Message-ID<pH1gZ-7OZ-7@gated-at.bofh.it>
In reply to#1174420
On Tue, Jun 30, 2015 at 10:57:04AM +0100, Adrian Hunter wrote:
> On 29/06/15 16:52, Will Deacon wrote:
> > On Mon, Jun 29, 2015 at 02:23:51PM +0100, Adrian Hunter wrote:
> >> On 29/06/15 15:30, Adrian Hunter wrote:
> >>> On 29/06/15 12:02, Adrian Hunter wrote:
> >>>> On 27/06/15 12:10, Will Deacon wrote:
> >>>>> @@ -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;
> >>>
> >>
> >> No that's no good either :-(
> > 
> > Yeah... we're fighting against symbol lookup wanting ->map_ip to give the
> > address of the ELF symbol but unwinding wanting ->map_ip to give a relative
> > offset for file reads.
> > 
> > Also, the reloc is a bit weird and I think needs to be the other way around
> > (i.e. we convert from a map-relative address to an objdump address by
> > *subtracting* the reloc). Even with that change, I run into problems with
> > annotate comparing ELF symbol addresses with map addresses. Urgh.
> 
> Adding or subtracting shouldn't matter.

I was referring to the subtraction in map__rip_2objdump, but you've
addressed that below.

> This seems to work (without any other changes):
> 
> 	if (dso__is_vdso(dso))
> 		map->reloc = map->start - shdr.sh_addr + shdr.sh_offset;
> 
> Haven't tested 32-bit yet though.

FWIW, this works on arm64 and x86_64 with my testing:

  Tested-by: Will Deacon <will.deacon@arm.com>

Cheers,

Will
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web