]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR debug/42454 (debug_ranges table contains empty range for unused .text section...
authorJakub Jelinek <jakub@redhat.com>
Wed, 23 Dec 2009 16:54:35 +0000 (17:54 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 23 Dec 2009 16:54:35 +0000 (17:54 +0100)
PR debug/42454
* dwarf2out.c (add_ranges_by_labels_to_AT_range_list): New function.
(dwarf2out_finish): Call add_ranges_by_labels_to_AT_range_list.

* gcc.dg/debug/dwarf2/aranges-fnsec-1.c: Add check for .debug_ranges.

Co-Authored-By: Cary Coutant <ccoutant@google.com>
From-SVN: r155429

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/debug/dwarf2/aranges-fnsec-1.c

index be2608887616f099561a660973cb597beaf41a4d..42c4e1c085cf48ebc166a0be86f3aa5978fa8d32 100644 (file)
@@ -1,3 +1,10 @@
+2009-12-23  Jakub Jelinek  <jakub@redhat.com>
+           Cary Coutant  <ccoutant@google.com>
+
+       PR debug/42454
+       * dwarf2out.c (add_ranges_by_labels_to_AT_range_list): New function.
+       (dwarf2out_finish): Call add_ranges_by_labels_to_AT_range_list.
+
 2009-12-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
         PR target/42093
index 2296dc3494597727703b6775237208fe1830b83f..02c0afd1171ec88cf7b8fa86a0ec8f67e8d7ed6d 100644 (file)
@@ -6062,7 +6062,8 @@ static void add_arange (tree, dw_die_ref);
 static void output_aranges (void);
 static unsigned int add_ranges_num (int);
 static unsigned int add_ranges (const_tree);
-static unsigned int add_ranges_by_labels (const char *, const char *);
+static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
+                                 bool *);
 static void output_ranges (void);
 static void output_line_info (void);
 static void output_file_names (void);
@@ -11021,10 +11022,12 @@ add_ranges (const_tree block)
 /* Add a new entry to .debug_ranges corresponding to a pair of
    labels.  */
 
-static unsigned int
-add_ranges_by_labels (const char *begin, const char *end)
+static void
+add_ranges_by_labels (dw_die_ref die, const char *begin, const char *end,
+                     bool *added)
 {
   unsigned int in_use = ranges_by_label_in_use;
+  unsigned int offset;
 
   if (in_use == ranges_by_label_allocated)
     {
@@ -11041,7 +11044,12 @@ add_ranges_by_labels (const char *begin, const char *end)
   ranges_by_label[in_use].end = end;
   ranges_by_label_in_use = in_use + 1;
 
-  return add_ranges_num (-(int)in_use - 1);
+  offset = add_ranges_num (-(int)in_use - 1);
+  if (!*added)
+    {
+      add_AT_range_list (die, DW_AT_ranges, offset);
+      *added = true;
+    }
 }
 
 static void
@@ -21209,6 +21217,7 @@ dwarf2out_finish (const char *filename)
   else
     {
       unsigned fde_idx = 0;
+      bool range_list_added = false;
 
       /* We need to give .debug_loc and .debug_ranges an appropriate
         "base address".  Use zero so that these addresses become
@@ -21219,12 +21228,11 @@ dwarf2out_finish (const char *filename)
       add_AT_addr (comp_unit_die, DW_AT_entry_pc, const0_rtx);
 
       if (text_section_used)
-       add_AT_range_list (comp_unit_die, DW_AT_ranges,
-                          add_ranges_by_labels (text_section_label,
-                                                text_end_label));
+       add_ranges_by_labels (comp_unit_die, text_section_label,
+                             text_end_label, &range_list_added);
       if (flag_reorder_blocks_and_partition && cold_text_section_used)
-       add_ranges_by_labels (cold_text_section_label,
-                             cold_end_label);
+       add_ranges_by_labels (comp_unit_die, cold_text_section_label,
+                             cold_end_label, &range_list_added);
 
       for (fde_idx = 0; fde_idx < fde_table_in_use; fde_idx++)
        {
@@ -21233,18 +21241,23 @@ dwarf2out_finish (const char *filename)
          if (fde->dw_fde_switched_sections)
            {
              if (!fde->in_std_section)
-               add_ranges_by_labels (fde->dw_fde_hot_section_label,
-                                     fde->dw_fde_hot_section_end_label);
+               add_ranges_by_labels (comp_unit_die,
+                                     fde->dw_fde_hot_section_label,
+                                     fde->dw_fde_hot_section_end_label,
+                                     &range_list_added);
              if (!fde->cold_in_std_section)
-               add_ranges_by_labels (fde->dw_fde_unlikely_section_label,
-                                     fde->dw_fde_unlikely_section_end_label);
+               add_ranges_by_labels (comp_unit_die,
+                                     fde->dw_fde_unlikely_section_label,
+                                     fde->dw_fde_unlikely_section_end_label,
+                                     &range_list_added);
            }
          else if (!fde->in_std_section)
-           add_ranges_by_labels (fde->dw_fde_begin,
-                                 fde->dw_fde_end);
+           add_ranges_by_labels (comp_unit_die, fde->dw_fde_begin,
+                                 fde->dw_fde_end, &range_list_added);
        }
 
-      add_ranges (NULL);
+      if (range_list_added)
+       add_ranges (NULL);
     }
 
   /* Output location list section if necessary.  */
index da6d3b1e5b3939656e503829772a5723d8d922ad..83144a258f2e9219ae094e9c890064175b208a20 100644 (file)
@@ -1,3 +1,9 @@
+2009-12-23  Jakub Jelinek  <jakub@redhat.com>
+           Cary Coutant  <ccoutant@google.com>
+
+       PR debug/42454
+       * gcc.dg/debug/dwarf2/aranges-fnsec-1.c: Add check for .debug_ranges.
+
 2009-12-23  Ramana Radhakrishnan  <ramana.radhakrishnan@arm.com>
 
         PR target/42093
index 8bd34b2fe299ac04e4f12da4c41348abd8a8b1cb..124e28eb7cea050960e017e3bfae0d92efa0625e 100644 (file)
@@ -1,9 +1,11 @@
-/* Test that .debug_aranges does not have an entry for the text
-   section if nothing went in there.  */
+/* Test that .debug_aranges and .debug_ranges do not have an entry for the
+   text section if nothing went in there.  */
 /* Origin: Joseph Myers <joseph@codesourcery.com> */
 /* { dg-do compile } */
-/* { dg-options "-gdwarf-2 -ffunction-sections -w" } */
+/* { dg-options "-gdwarf-2 -ffunction-sections -w -dA" } */
 /* { dg-final { scan-assembler-not "\\.Letext0-\\.Ltext0" } } */
+/* { dg-final { scan-assembler-not "\\.Ltext0\[^\n\r\]*Offset 0x0" } } */
+/* { dg-final { scan-assembler "DW_AT_ranges" } } */
 
 int
 f (void)