[ARC] Add support for Quarkse opcodes.
[deliverable/binutils-gdb.git] / binutils / dwarf.c
index 9f1baea831227940575eb286f8a3c7f3466e0ca5..086df4b4ba64099b94ff914035308387c49344bc 100644 (file)
@@ -1,5 +1,5 @@
 /* dwarf.c -- display DWARF contents of a BFD binary file
-   Copyright (C) 2005-2015 Free Software Foundation, Inc.
+   Copyright (C) 2005-2016 Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
@@ -317,8 +317,13 @@ read_uleb128 (unsigned char * data,
 #define SAFE_BYTE_GET(VAL, PTR, AMOUNT, END)   \
   do                                           \
     {                                          \
-      int dummy [sizeof (VAL) < (AMOUNT) ? -1 : 1] ATTRIBUTE_UNUSED ; \
       unsigned int amount = (AMOUNT);          \
+      if (sizeof (VAL) < amount)               \
+       {                                       \
+         error (_("internal error: attempt to read %d bytes of data in to %d sized variable"),\
+                amount, (int) sizeof (VAL));   \
+         amount = sizeof (VAL);                \
+       }                                       \
       if (((PTR) + amount) >= (END))           \
        {                                       \
          if ((PTR) < (END))                    \
@@ -4326,6 +4331,16 @@ display_debug_abbrev (struct dwarf_section *section,
   return 1;
 }
 
+/* Return true when ADDR is the maximum address, when addresses are
+   POINTER_SIZE bytes long.  */
+
+static bfd_boolean
+is_max_address (dwarf_vma addr, unsigned int pointer_size)
+{
+  dwarf_vma mask = ~(~(dwarf_vma) 1 << (pointer_size * 8 - 1));
+  return ((addr & mask) == mask);
+}
+
 /* Display a location list from a normal (ie, non-dwo) .debug_loc section.  */
 
 static void
@@ -4380,10 +4395,6 @@ display_loc_list (struct dwarf_section *section,
 
       printf ("    %8.8lx ", off);
 
-      /* Note: we use sign extension here in order to be sure that we can detect
-        the -1 escape value.  Sign extension into the top 32 bits of a 32-bit
-        address will not affect the values that we display since we always show
-        hex values, and always the bottom 32-bits.  */
       SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, section_end);
       SAFE_BYTE_GET_AND_INC (end, start, pointer_size, section_end);
 
@@ -4404,7 +4415,8 @@ display_loc_list (struct dwarf_section *section,
        }
 
       /* Check base address specifiers.  */
-      if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
+      if (is_max_address (begin, pointer_size)
+          && !is_max_address (end, pointer_size))
        {
          base_address = end;
          print_dwarf_vma (begin, pointer_size);
@@ -5202,11 +5214,6 @@ display_debug_ranges (struct dwarf_section *section,
          dwarf_vma begin;
          dwarf_vma end;
 
-         /* Note: we use sign extension here in order to be sure that
-            we can detect the -1 escape value.  Sign extension into the
-            top 32 bits of a 32-bit address will not affect the values
-            that we display since we always show hex values, and always
-            the bottom 32-bits.  */
          SAFE_BYTE_GET_AND_INC (begin, start, pointer_size, finish);
          if (start >= finish)
            break;
@@ -5221,7 +5228,8 @@ display_debug_ranges (struct dwarf_section *section,
            }
 
          /* Check base address specifiers.  */
-         if (begin == (dwarf_vma) -1 && end != (dwarf_vma) -1)
+          if (is_max_address (begin, pointer_size)
+              && !is_max_address (end, pointer_size))
            {
              base_address = end;
              print_dwarf_vma (begin, pointer_size);
@@ -6456,7 +6464,7 @@ display_debug_frames (struct dwarf_section *section,
 
            case DW_CFA_def_cfa_expression:
              ul = LEB ();
-             if (start >= block_end || start + ul > block_end || start + ul < start)
+             if (start >= block_end || ul > (unsigned long) (block_end - start))
                {
                  printf (_("  DW_CFA_def_cfa_expression: <corrupt len %lu>\n"), ul);
                  break;
This page took 0.029579 seconds and 4 git commands to generate.