This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Commit: Fix display of DW_FORM_ref8 attribute values
- From: Tristan Gingold <gingold at adacore dot com>
- To: Nick Clifton <nickc at redhat dot com>
- Cc: binutils at sourceware dot org
- Date: Wed, 9 Oct 2013 17:57:43 +0200
- Subject: Re: Commit: Fix display of DW_FORM_ref8 attribute values
- Authentication-results: sourceware.org; auth=none
- References: <87ob6ysfpx dot fsf at redhat dot com>
On Oct 9, 2013, at 4:04 PM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Guys,
>
> I am checking in the patch below to fix the display of DWARF
> DW_FORM_ref8 attributes. The code was not biasing the display value
> with the start of the CU containing the reference.
>
> Tested on 32-bit and 64-bit hosts with a wide variety of different
> targets - no regressions.
>
> Tristan - is this patch OK for the 2.24 branch ?
Sure.
Tristan.
>
> Cheers
> Nick
>
> binutils/ChangeLog
> 2013-10-09 Nick Clifton <nickc@redhat.com>
>
> * dwarf.c (add64): New function.
> (read_and_display_attr_value): Add CU offset in to the value
> displayed for a DW_AT_ref8 attribute.
>
> Index: binutils/dwarf.c
> ===================================================================
> RCS file: /cvs/src/src/binutils/dwarf.c,v
> retrieving revision 1.140
> diff -u -3 -p -r1.140 dwarf.c
> --- binutils/dwarf.c 1 Oct 2013 10:32:54 -0000 1.140
> +++ binutils/dwarf.c 9 Oct 2013 14:05:30 -0000
> @@ -1425,6 +1425,34 @@ find_cu_tu_set_v2 (dwarf_vma cu_offset,
> return NULL;
> }
>
> +/* Add INC to HIGH_BITS:LOW_BITS. */
> +static void
> +add64 (dwarf_vma * high_bits, dwarf_vma * low_bits, dwarf_vma inc)
> +{
> + dwarf_vma tmp = * low_bits;
> +
> + tmp += inc;
> +
> + /* FIXME: There is probably a better way of handling this:
> +
> + We need to cope with dwarf_vma being a 32-bit or 64-bit
> + type. Plus regardless of its size LOW_BITS is meant to
> + only hold 32-bits, so if there is overflow or wrap around
> + we must propagate into HIGH_BITS. */
> + if (tmp < * low_bits)
> + {
> + ++ * high_bits;
> + }
> + else if (sizeof (tmp) > 8
> + && (tmp >> 31) > 1)
> + {
> + ++ * high_bits;
> + tmp &= 0xFFFFFFFF;
> + }
> +
> + * low_bits = tmp;
> +}
> +
> static unsigned char *
> read_and_display_attr_value (unsigned long attribute,
> unsigned long form,
> @@ -1567,15 +1595,17 @@ read_and_display_attr_value (unsigned lo
>
> case DW_FORM_ref8:
> case DW_FORM_data8:
> - if (!do_loc)
> {
> dwarf_vma high_bits;
> + dwarf_vma utmp;
> char buf[64];
>
> SAFE_BYTE_GET64 (data, &high_bits, &uvalue, end);
> -
> + utmp = uvalue;
> + if (form == DW_FORM_ref8)
> + add64 (& high_bits, & utmp, cu_offset);
> printf (" 0x%s",
> - dwarf_vmatoa64 (high_bits, uvalue, buf, sizeof (buf)));
> + dwarf_vmatoa64 (high_bits, utmp, buf, sizeof (buf)));
> }
>
> if ((do_loc || do_debug_loc || do_debug_ranges)