Display null bytes in DWARF debug info
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Aug 2012 13:42:59 +0000 (13:42 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 2 Aug 2012 13:42:59 +0000 (13:42 +0000)
binutils/

PR binutils/14420
* dwarf.c (process_abbrev_section): Add attribute terminator.
Warn missing section terminator.
(get_FORM_name): Special check for 0 value.
(get_AT_name): Likewise.
(process_debug_info): Display zero abbrev number.  Check
attribute terminator.

binutils/testsuite/

PR binutils/14420
* binutils-all/i386/compressed-1a.d: Updated.
* binutils-all/objdump.W: Likewise.
* binutils-all/readelf.wa: Likewise.
* binutils-all/x86-64/compressed-1a.d: Likewise.

gas/testsuite/

PR binutils/14420
* gas/elf/dwarf2-1.d: Updated.
* gas/elf/dwarf2-2.d: Likwise.
* gas/i386/dw2-compress-1.d: Likwise.

binutils/ChangeLog
binutils/dwarf.c
binutils/testsuite/ChangeLog
binutils/testsuite/binutils-all/i386/compressed-1a.d
binutils/testsuite/binutils-all/objdump.W
binutils/testsuite/binutils-all/readelf.wa
binutils/testsuite/binutils-all/x86-64/compressed-1a.d
gas/testsuite/ChangeLog
gas/testsuite/gas/elf/dwarf2-1.d
gas/testsuite/gas/elf/dwarf2-2.d
gas/testsuite/gas/i386/dw2-compress-1.d

index 7634de48b60f1025ce44d80c014c6ee2666f5d97..7594bcb26eef6b7f646f5ceba7316868da2d1464 100644 (file)
@@ -1,3 +1,13 @@
+2012-08-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/14420
+       * dwarf.c (process_abbrev_section): Add attribute terminator.
+       Warn missing section terminator.
+       (get_FORM_name): Special check for 0 value.
+       (get_AT_name): Likewise.
+       (process_debug_info): Display zero abbrev number.  Check
+       attribute terminator.
+
 2012-07-30  Nick Clifton  <nickc@redhat.com>
 
        * po/binutils.pot: Updated template.
index 6e93906af385ff3dd0f8785792a1e8cc3d04a774..d8050faf98d1e359f684a6e2288f680e039fd75d 100644 (file)
@@ -647,12 +647,14 @@ process_abbrev_section (unsigned char *start, unsigned char *end)
          form = read_leb128 (start, & bytes_read, 0);
          start += bytes_read;
 
-         if (attribute != 0)
-           add_abbrev_attr (attribute, form);
+         add_abbrev_attr (attribute, form);
        }
       while (attribute != 0);
     }
 
+  /* Report the missing single zero which ends the section.  */
+  error (_(".debug_abbrev section not zero terminated\n"));
+
   return NULL;
 }
 
@@ -675,8 +677,12 @@ get_TAG_name (unsigned long tag)
 static const char *
 get_FORM_name (unsigned long form)
 {
-  const char *name = get_DW_FORM_name (form);
+  const char *name;
+  
+  if (form == 0)
+    return "DW_FORM value: 0";
 
+  name = get_DW_FORM_name (form);
   if (name == NULL)
     {
       static char buffer[100];
@@ -1860,6 +1866,9 @@ get_AT_name (unsigned long attribute)
 {
   const char *name;
 
+  if (attribute == 0)
+    return "DW_AT value: 0";
+
   /* One value is shared by the MIPS and HP extensions:  */
   if (attribute == DW_AT_MIPS_fde)
     return "DW_AT_MIPS_fde or DW_AT_HP_unmodifiable";
@@ -2161,6 +2170,10 @@ process_debug_info (struct dwarf_section *section,
                    break;
                }
 
+             if (!do_loc && die_offset >= dwarf_start_die)
+               printf (_(" <%d><%lx>: Abbrev Number: 0\n"),
+                       level, die_offset);
+
              --level;
              if (level < 0)
                {
@@ -2238,7 +2251,9 @@ process_debug_info (struct dwarf_section *section,
              break;
            }
 
-         for (attr = entry->first_attr; attr; attr = attr->next)
+         for (attr = entry->first_attr;
+              attr && attr->attribute;
+              attr = attr->next)
            {
              debug_info *arg;
 
index b82624a4019dc4992b1eef4063d4aa5c0aa8afac..7d4de5ab50f480a9a1cbcd9792e98acbdda50c98 100644 (file)
@@ -1,3 +1,11 @@
+2012-08-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/14420
+       * binutils-all/i386/compressed-1a.d: Updated.
+       * binutils-all/objdump.W: Likewise.
+       * binutils-all/readelf.wa: Likewise.
+       * binutils-all/x86-64/compressed-1a.d: Likewise.
+
 2012-07-28  Kai Tietz  <ktietz@redhat.com>
 
        * binutils-all/windres/version_small.rc: New test.
index aa0284ad68b877497817f63f029f0330f9212769..bb609ddcba1f9459e496bb625355e5e9743ff345 100644 (file)
@@ -16,6 +16,7 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_stmt_list    DW_FORM_data4
+    DW_AT value: 0     DW_FORM value: 0
    2      DW_TAG_subprogram    \[no children\]
     DW_AT_external     DW_FORM_flag
     DW_AT_name         DW_FORM_strp
@@ -24,6 +25,7 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_frame_base   DW_FORM_block1
+    DW_AT value: 0     DW_FORM value: 0
 
 Contents of the .[z]?debug_info section:
 
@@ -56,6 +58,7 @@ Contents of the .[z]?debug_info section:
     <3f>   DW_AT_low_pc      : 0x10    
     <43>   DW_AT_high_pc     : 0x1b    
     <47>   DW_AT_frame_base  : 1 byte block: 9c        \(DW_OP_call_frame_cfa\)
+ <1><49>: Abbrev Number: 0
 
 Raw dump of debug contents of section .[z]?debug_line:
 
index 449372eaed05193112112142cc69f7570a9a5f87..43c2451aec2285a099129ac0516de228e0c64240 100644 (file)
@@ -28,6 +28,7 @@ Contents of the .debug_info section:
     <4b>   DW_AT_name        : int     
     <4f>   DW_AT_byte_size   : 4       
     <50>   DW_AT_encoding    : 5       \(signed\)
+ <1><51>: Abbrev Number: 0
 
 Raw dump of debug contents of section .debug_line:
 
@@ -83,6 +84,7 @@ Contents of the .debug_abbrev section:
     DW_AT_name         DW_FORM_string
     DW_AT_producer     DW_FORM_string
     DW_AT_language     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
    2      DW_TAG_subprogram    \[no children\]
     DW_AT_external     DW_FORM_flag
     DW_AT_decl_file    DW_FORM_data1
@@ -92,8 +94,10 @@ Contents of the .debug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_frame_base   DW_FORM_block1
+    DW_AT value: 0     DW_FORM value: 0
    3      DW_TAG_base_type    \[no children\]
     DW_AT_name         DW_FORM_string
     DW_AT_byte_size    DW_FORM_data1
     DW_AT_encoding     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
 
index e1e158ccbe172505ed30a12b0252be739b76ec58..43d60b1754a371b6ee93b4935a1c4f01ec6fee84 100644 (file)
@@ -8,6 +8,7 @@ Contents of the .zdebug_abbrev section:
     DW_AT_name         DW_FORM_string
     DW_AT_producer     DW_FORM_string
     DW_AT_language     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
    2      DW_TAG_subprogram    [no children]
     DW_AT_external     DW_FORM_flag
     DW_AT_decl_file    DW_FORM_data1
@@ -17,8 +18,10 @@ Contents of the .zdebug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_frame_base   DW_FORM_block1
+    DW_AT value: 0     DW_FORM value: 0
    3      DW_TAG_base_type    [no children]
     DW_AT_name         DW_FORM_string
     DW_AT_byte_size    DW_FORM_data1
     DW_AT_encoding     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
 
index 98115aff890fef62a7baa10fa703c99dfd6c3602..06ab011bf6c739ab2ad8cd0e9bed1a3537dc4aeb 100644 (file)
@@ -16,6 +16,7 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_stmt_list    DW_FORM_data4
+    DW_AT value: 0     DW_FORM value: 0
    2      DW_TAG_subprogram    \[no children\]
     DW_AT_external     DW_FORM_flag
     DW_AT_name         DW_FORM_strp
@@ -24,6 +25,7 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_frame_base   DW_FORM_block1
+    DW_AT value: 0     DW_FORM value: 0
 
 Contents of the .[z]?debug_info section:
 
@@ -56,6 +58,7 @@ Contents of the .[z]?debug_info section:
     <4f>   DW_AT_low_pc      : 0x10    
     <57>   DW_AT_high_pc     : 0x15    
     <5f>   DW_AT_frame_base  : 1 byte block: 9c        \(DW_OP_call_frame_cfa\)
+ <1><61>: Abbrev Number: 0
 
 Raw dump of debug contents of section .[z]?debug_line:
 
index 2601cc10d5c2cc0bd4dd92e4683f0a1458778041..b9635ac00f86395ad0010bca22661812d59748f6 100644 (file)
@@ -1,3 +1,10 @@
+2012-08-02  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR binutils/14420
+       * gas/elf/dwarf2-1.d: Updated.
+       * gas/elf/dwarf2-2.d: Likwise.
+       * gas/i386/dw2-compress-1.d: Likwise.
+
 2012-08-01  James Lemke  <jwlemke@codesourcery.com>
 
        * gas/cfi/cfi-ppc-1.d: Allow for code alignment of 2 or 4.
index ff0ff74c31249dc15800456db60f33bb4405498c..1a6b0ca316523c7bbc815c1298dc720a632e8a13 100644 (file)
@@ -30,6 +30,7 @@ Contents of the .[z]?debug_info section:
     <4b>   DW_AT_name        : int     
     <4f>   DW_AT_byte_size   : 4       
     <50>   DW_AT_encoding    : 5       \(signed\)
+ <1><51>: Abbrev Number: 0
 
 Raw dump of debug contents of section .[z]?debug_line:
 
@@ -85,6 +86,7 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_name         DW_FORM_string
     DW_AT_producer     DW_FORM_string
     DW_AT_language     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
    2      DW_TAG_subprogram    \[no children\]
     DW_AT_external     DW_FORM_flag
     DW_AT_decl_file    DW_FORM_data1
@@ -94,8 +96,10 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_frame_base   DW_FORM_block1
+    DW_AT value: 0     DW_FORM value: 0
    3      DW_TAG_base_type    \[no children\]
     DW_AT_name         DW_FORM_string
     DW_AT_byte_size    DW_FORM_data1
     DW_AT_encoding     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
 
index 2feafa691e28dbe1d1195a14bfc554ac9cbc61c4..a463acc22d57b4633188ad23ad9a8929683d6b44 100644 (file)
@@ -30,6 +30,7 @@ Contents of the .[z]?debug_info section:
     <4b>   DW_AT_name        : int     
     <4f>   DW_AT_byte_size   : 4       
     <50>   DW_AT_encoding    : 5       \(signed\)
+ <1><51>: Abbrev Number: 0
 
 Raw dump of debug contents of section .[z]?debug_line:
 
@@ -85,6 +86,7 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_name         DW_FORM_string
     DW_AT_producer     DW_FORM_string
     DW_AT_language     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
    2      DW_TAG_subprogram    \[no children\]
     DW_AT_external     DW_FORM_flag
     DW_AT_decl_file    DW_FORM_data1
@@ -94,8 +96,10 @@ Contents of the .[z]?debug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_frame_base   DW_FORM_block1
+    DW_AT value: 0     DW_FORM value: 0
    3      DW_TAG_base_type    \[no children\]
     DW_AT_name         DW_FORM_string
     DW_AT_byte_size    DW_FORM_data1
     DW_AT_encoding     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
 
index 06057cac7e6b5ce225268c7045e963a658634de1..64e255915a6499817b471bdb44fc74c1af9a7c84 100644 (file)
@@ -29,6 +29,7 @@ Contents of the .zdebug_info section:
     <4b>   DW_AT_name        : int     
     <4f>   DW_AT_byte_size   : 4       
     <50>   DW_AT_encoding    : 5       \(signed\)
+ <1><51>: Abbrev Number: 0
 
 Contents of the .zdebug_abbrev section:
 
@@ -40,6 +41,7 @@ Contents of the .zdebug_abbrev section:
     DW_AT_name         DW_FORM_string
     DW_AT_producer     DW_FORM_string
     DW_AT_language     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
    2      DW_TAG_subprogram    \[no children\]
     DW_AT_external     DW_FORM_flag
     DW_AT_decl_file    DW_FORM_data1
@@ -49,10 +51,12 @@ Contents of the .zdebug_abbrev section:
     DW_AT_low_pc       DW_FORM_addr
     DW_AT_high_pc      DW_FORM_addr
     DW_AT_frame_base   DW_FORM_block1
+    DW_AT value: 0     DW_FORM value: 0
    3      DW_TAG_base_type    \[no children\]
     DW_AT_name         DW_FORM_string
     DW_AT_byte_size    DW_FORM_data1
     DW_AT_encoding     DW_FORM_data1
+    DW_AT value: 0     DW_FORM value: 0
 
 Raw dump of debug contents of section .zdebug_line: