[Dwarf-Discuss] DW_AT_entry_pc vs DW_AT_ranges

Mark Wielaard mjw@redhat.com
Thu Jul 19 13:28:15 GMT 2012


On Tue, 2012-05-15 at 20:29 +0200, Mark Wielaard wrote:
> I got one off-list reply to the second suggestion, adding that having
> a constant form could also be added so it is an offset relative to the
> first pc of the range.
> 
> Does it make sense to write up an proposal for the second part?
> I could also hack up a GCC patch for it, to better show the impact
> if that would help.

I got some more feedback offlist saying that it would be nice to have a
proposal. I got somewhat distracted by other things and didn't think the
savings were too great. But I learned that even the DW_AT_low_pc
encoding change was found to be a win. That reduced the number of
relocation addresses with just 2%. A quick test showed changing
DW_AT_entry_pc in the same way saves another 1% of relocatable addresses
in the DWARF data. That isn't much, but I guess every percentage counts.

So here is a more formal proposal. Also submitted through
http://dwarfstd.org/SubmitComment.php, but it isn't yet showing up on
http://dwarfstd.org/Issues.php.

Background:

Currently, an DIE with a DW_AT_entry_pc and a DW_AT_ranges will create
multiple relocatable addresses for both the DW_AT_entry_pc and the
DW_AT_ranges. For example:

In .debug_info

DW_TAG_subroutine
  DW_AT_entry_pc (addr) 0x403a9e <func+0x1e>
  DW_AT_ranges (sec_offset) range list [    50]

In .debug_ranges

[50] 0x403a9e <some_func+0x1e>..0x403aa4 <some_func+0x24>
     0x403abb <some_func+0x3b>..0x403abf <some_func+0x3f>

Often, as in this example, the entry_pc is equal to the first range
address.

Proposal:

Since DW_AT_entry_pc is often the same, or an offset from, the first
range list address, it can be encoded as either a flag value signaling
that the DW_AT_entry_pc value is equal to the first DW_AT_ranges
address, or be encoded as a constant offset from the first
DW_AT_ranges address.

Wording changes:

2.18 Entry Address

Remove the '.' the end of the sentence "The value of the
DW_AT_entry_pc attribute is a relocated address" and add "if the
value of DW_AT_entry_pc is of class address; or if it is of class
flag, then the value true indicates it is the same as the first
address in the range of code addresses; or if it is of class constant,
the value is an unsigned integer offset which when added to the first
address in the range of code addresses gives the entry address."

Figure 20. Attribute encodings, begins here.

Change the entry for DW_AT_entry_pc to read:

DW_AT_entry_pc   0x52   address, flag, constant




More information about the Dwarf-discuss mailing list