]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* dwarf.c (add64): New function.
authorNick Clifton <nickc@redhat.com>
Wed, 9 Oct 2013 16:37:28 +0000 (16:37 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 9 Oct 2013 16:37:28 +0000 (16:37 +0000)
(read_and_display_attr_value): Add CU offset in to the value
displayed for a DW_AT_ref8 attribute.

binutils/ChangeLog
binutils/dwarf.c

index 5f64635da23daf30d28981ea3e69fffe57a6b733..104a5229988b3869678d7b3053d98b6ed43a9a64 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2013-09-20  Alan Modra  <amodra@gmail.com>
 
        * configure: Regenerate.
index 8a233aa10ff4389630b7e76ae2a5f20330fcc124..afedf3e92a60b9798ce05baa79a7309685081aa8 100644 (file)
@@ -288,7 +288,7 @@ read_uleb128 (unsigned char * data,
 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END)   \
   do                                           \
     {                                          \
-      int dummy [sizeof (VAL) < (AMOUNT) ? -1 : 0] ATTRIBUTE_UNUSED ; \
+      int dummy [sizeof (VAL) < (AMOUNT) ? -1 : 1] ATTRIBUTE_UNUSED ; \
       unsigned int amount = (AMOUNT);          \
       if (((PTR) + amount) >= (END))           \
        {                                       \
@@ -1425,6 +1425,34 @@ find_cu_tu_set_v2 (dwarf_vma cu_offset, int do_types)
   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,
@@ -1570,12 +1598,15 @@ read_and_display_attr_value (unsigned long attribute,
       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)