Web lists-archives.com

Re: [PATCH 17/17] perf annotate: Handle variables in 'sub', 'or' and many other instructions

Em Fri, Apr 13, 2018 at 09:20:43AM -0700, Andi Kleen escreveu:
> On Fri, Apr 13, 2018 at 11:01:11AM -0300, Arnaldo Carvalho de Melo wrote:
> > From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

> > Just like is done for 'mov' and others that can have as source or
> > targets variables resolved by objdump, to make them more compact:
> > 
> > -               orb    $0x4,0x224d71(%rip)        # 226ca4 <_rtld_global+0xca4>
> > +               orb    $0x4,_rtld_global+0xca4
> That's not equivalent.  It could be non rip relative too. You would need
> to keep at least the (%rip).

So, the function is _dl_start in /lib64/ld-2.26.so, the objdump output

0000000000001b10 <_dl_start>:
    1d1f:       0f 84 ab 00 00 00       je     1dd0 <_dl_start+0x2c0>
    1d25:       48 8d 3d 64 3c 22 00    lea    0x223c64(%rip),%rdi        # 225990 <_rtld_global+0x990>
    1d2c:       80 0d 71 3f 22 00 04    orb    $0x4,0x223f71(%rip)        # 225ca4 <_rtld_global+0xca4>
    1d33:       e8 78 92 00 00          callq  afb0 <_dl_setup_hash>


    21: 0000000000225000  3960 OBJECT  GLOBAL DEFAULT   20 _rtld_global@@GLIBC_PRIVATE

0x225ca4 = 0x225000 + 0x0xca4 

And that is equal to 0x1d33 + 0x223f71

What do I miss? Or where is it that I'm misinterpreting the calculations
that objdump did in its output?

This is just to make things compact, on the TUI if one wants to see the
original its just a matter of pressing 'o', i.e. that line appears by
default as:

perf annotate _dl_start
press HOME
press /orb
       │215:   lea    _rtld_global+0x990,%rdi
       │       orb    $0x4,_rtld_global+0xca4
       │     → callq  _dl_setup_hash 

press 'o', to see details, i.e. was this encoded as rip-relative?

       │1f25:   lea    0x224a64(%rip),%rdi        # 226990 <_rtld_global+0x990>
       │1f2c:   orb    $0x4,0x224d71(%rip)        # 226ca4 <_rtld_global+0xca4>
       │1f33: → callq  b080 <_dl_setup_hash>  

Now, if we have a non-rip relative orb, lemme search one with:

perf annotate --stdio2

There, we have one in the kernel's sys_pselect6:

perf annotate sys_pselect6
       │       mov    %gs:0x15b40,%rax
       │       orb    $0x4,0x490(%rax)
       │       mov    %rdx,0x718(%rax)
       │       mov    (%rax),%rdx

No variables resolved, nothing done, press 'o' to see the original objdump
disassembled line:

       │ffffffff8128af29:   mov    %gs:0x15b40,%rax
       │ffffffff8128af32:   orb    $0x4,0x490(%rax)
       │ffffffff8128af39:   mov    %rdx,0x718(%rax)
       │ffffffff8128af40:   mov    (%rax),%rdx

About something mildly related: what do you think about this:
http://ref.x86asm.net/, there is a xml file there[1] I'm thinking about
using, if available on the developer's HOME or some other standard place,
to provide help about the instructions :-)

- Arnaldo

[1] http://ref.x86asm.net/x86reference.xml

look for <mnem>PUNPCKHQDQ</mnem>

<entry r="yes">
		<brief>Unpack High Data</brief>