location list

Sasha Da Rocha Pinheiro darochapinhe@wisc.edu
Tue Jun 9 16:38:51 GMT 2020


Hi Mark,

first of all, thanks for giving me a direction here.

I am now trying to design the changes needed to be done in Dyninst.
So far we have only used the functions dwarf_* under libdw.
What I understood is that libdw is kinda divided in subsets of functions, dwarf_*, dwfl_* and dwelf_*.
I didn't find any documentation about it, or the purpose of these subset of functions. (Whats fl in dwfl for?)
But my understanding is that I can't use data structures from one on the other one.
That alone will need some design to modify the way we parse dwarf info into Dyninst.
Currently the lifetime of a dwarf handle lasts through one execution, because we parse dwarf data when the user needs it.

Can you point me to more documentation here or schedule a call so I can get a more clear view of this?

Regards,
Sasha



From: Mark Wielaard <mark@klomp.org>
Sent: Saturday, June 6, 2020 9:05 AM
To: Sasha Da Rocha Pinheiro <darochapinhe@wisc.edu>; elfutils-devel@sourceware.org <elfutils-devel@sourceware.org>
Subject: Re: location list 
 
Hi Sasha,

On Sat, 2020-06-06 at 00:30 +0000, Sasha Da Rocha Pinheiro wrote:
> As you can see the following variables have distinct locations:
>  [    81]      variable             abbrev: 5
>                name                 (string) "a"
>                decl_file            (data1) sasha.c (1)
>                decl_line            (data1) 12
>                type                 (ref4) [    cd]
>                location             (sec_offset) location list
> [     0]
>  [    9f]        variable             abbrev: 5
>                  name                 (string) "g"
>                  decl_file            (data1) sasha.c (1)
>                  decl_line            (data1) 15
>                  type                 (ref4) [    cd]
>                  location             (sec_offset) location list
> [    4a]
> [    bd]          variable             abbrev: 5
>                    name                 (string) "z"
>                    decl_file            (data1) sasha.c (1)
>                    decl_line            (data1) 16
>                    type                 (ref4) [    cd]
>                    location             (sec_offset) location list
> [    6e]
> 
> But when I use the code I sent before to list the three variables, I
> always get:
> 
> [main01.cpp:73] - Variable and location found (a), size(1).
> [main01.cpp:78] - interval: (0x0,0x5) 
> [main01.cpp:78] - interval: (0x5,0xa) 
> [main01.cpp:78] - interval: (0x16,0x24) 
> [main01.cpp:73] - Variable and location found (g), size(1).
> [main01.cpp:78] - interval: (0x0,0x5) 
> [main01.cpp:78] - interval: (0x5,0xa) 
> [main01.cpp:78] - interval: (0x16,0x24) 
> [main01.cpp:73] - Variable and location found (z), size(1).
> [main01.cpp:78] - interval: (0x0,0x5) 
> [main01.cpp:78] - interval: (0x5,0xa) 
> [main01.cpp:78] - interval: (0x16,0x24) 
> 
> 
> No matter the locationAttribute the code always get the first
> location descriptors in .debug_loc: 
>  
> DWARF section [ 7] '.debug_loc' at offset 0x1c6:
> 
>  CU [     b] base: .text+000000000000000000 <main>
>  [     0] range 0, 5
>           .text+000000000000000000 <main>..
>           .text+0x0000000000000004 <main+0x4>
>            [ 0] lit0
>            [ 1] stack_value
>           range 5, a
>           .text+0x0000000000000005 <main+0x5>..
>           .text+0x0000000000000009 <main+0x9>
>            [ 0] reg1
>           range 16, 24
>           .text+0x0000000000000016 <main+0x16>..
>           .text+0x0000000000000023 <main+0x23>
>            [ 0] reg1
>  [    4a] range 0, 5
>           .text+000000000000000000 <main>..
>           .text+0x0000000000000004 <main+0x4>
>            [ 0] lit0
>            [ 1] stack_value
>  [    6e] range 5, a
>           .text+0x0000000000000005 <main+0x5>..
>           .text+0x0000000000000009 <main+0x9>
>            [ 0] lit0
>            [ 1] stack_value
>           range a, e
>           .text+0x000000000000000a <main+0xa>..
>           .text+0x000000000000000d <main+0xd>
>            [ 0] const4u 65537
>            [ 5] breg0 0
>            [ 7] minus
>            [ 8] stack_value

I think I see what is happening. The fact that <main> is at
.text+000000000000000000 suggests that this is actually an ET_REL file
(not linked object file). The libdw dwarf_xxx calls don't do
relocations. But eu-readelf does. So while eu-readelf shows some
offsets as their relocated values, your program just using dwarf_xxx
calls does not. Specifically the DW_AT_location list attributes will
all point to zero. Which explains why every location list seems to be
the same.

We don't have a public function to just apply all relocations to an
object file, but opening the file through dwfl_begin () will do it.

Something like the attached.

Hope that helps,

Mark


More information about the Elfutils-devel mailing list