This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA/DWARF] constant class of DW_AT_high_pc is offset for version >=4 only.
- From: Mark Wielaard <mjw at redhat dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Sun, 16 Feb 2014 20:19:02 +0100
- Subject: Re: [RFA/DWARF] constant class of DW_AT_high_pc is offset for version >=4 only.
- Authentication-results: sourceware.org; auth=none
- References: <1392478818-30320-1-git-send-email-brobecker at adacore dot com>
Hi Joel,
On Sat, 2014-02-15 at 19:40 +0400, Joel Brobecker wrote:
> Starting with DWARF version 4, the description of the DW_AT_high_pc
> attribute was amended to say:
>
> if it is of class constant, the value is an unsigned integer offset
> which when added to the low PC gives the address of the first
> location past the last instruction associated with the entity.
>
> A change was made in Apr 27th, 2012 to reflect that change:
>
> | commit 91da14142c0171e58a91ad58a32fd010b700e761
> | Author: Mark Wielaard <mjw@redhat.com>
> | Date: Fri Apr 27 18:55:19 2012 +0000
> |
> | * dwarf2read.c (dwarf2_get_pc_bounds): Check DW_AT_high_pc form to
> | see whether it is an address or a constant offset from DW_AT_low_pc.
> | (dwarf2_record_block_ranges): Likewise.
> | (read_partial_die): Likewise.
>
> Unfortunately, this new interpretation is now used regardless of
> the CU's DWARF version. It turns out that one of WindRiver's compilers
> (FTR: Diabdata 4.4) is generating DWARF version 2 info with
> DW_AT_high_pc attributes using the data4 form. Because of that,
> we miscompute all high PCs incorrectly.
Sorry about that. I read the spec as disallowing anything except
DW_FORM_addr to encode class address. And since before DWARF4
DW_AT_high_pc only allowed class address it hadn't occurred to me that
it could have been encoded differently. I do think this really is a bug
in the compiler that generated this.
> This patch fixes it by ammending a bit the changes from the commit
> mentioned above to use the new interpretation of a relative address
> only when the CU's DWARF version is 4 or greater.
That should work fine. GCC at least doesn't generate DW_AT_high_pc
attributes as offsets (constant class) unless it generates DWARF4+.
Cheers,
Mark