diff mbox

DWARF support for AIX v4

Message ID CAGWvnymx60pqzK9HmAet9wD0qEXEXS8stCcho_E-244t5zzhNg@mail.gmail.com
State New
Headers show

Commit Message

David Edelsohn Sept. 24, 2015, 2:39 a.m. UTC
Richard and Richard,

Appended is the updated version of the DWARF support patch for AIX.  I
still can split out the length computation into a separate helper
function, but, as I mentioned, it won't apply to the instance that
uses a delta of two labels.

This version sets have_macinfo to False and disables add_AT_loc_list.
It also define XCOFF_DEBUGGING_INFO to 0 by default in dwarf2out.c and
dwarf2asm.c.

Thanks, David

        * dwarf2out.c (XCOFF_DEBUGGING_INFO): Default 0 definition.
        (have_macinfo): Force to False for XCOFF_DEBUGGING_INFO.
        (add_AT_loc_list): Return early if XCOFF_DEBUGGING_INFO.
        (output_compilation_unit_header): Don't output length on AIX.
        (output_pubnames): Don't output length on AIX.
        (output_aranges): Delete argument. Compute length locally. Don't
        output length on AIX.
        (output_line_info): Don't output length on AIX.
        (dwarf2out_finish): Don't compute aranges_length.
        * dwarf2asm.c (XCOFF_DEBUGGING_INFO): Default 0 definition.
        (dw2_asm_output_nstring): Emit .byte not .ascii on AIX.
        * config/rs6000/rs6000.c (rs6000_output_dwrf_dtprel): Emit correct
        symbol decoration for AIX.
        (rs6000_xcoff_debug_unwind_info): New.
        (rs6000_xcoff_asm_named_section): Emit .dwsect pseudo-op
        for SECTION_DEBUG.
        (rs6000_xcoff_declare_function_name): Emit different
        .function pseudo-op when DWARF2_DEBUG. Don't call
        xcoffout_declare_function for DWARF2_DEBUG.
        * config/rs6000/xcoff.h (TARGET_DEBUG_UNWIND_INFO):
        Redefine.
        * config/rs6000/aix71.h (DWARF2_DEBUGGING_INFO): Define.
        (PREFERRED_DEBUGGING_TYPE): Define.
        (DEBUG_INFO_SECTION): Define.
        (DEBUG_ABBREV_SECTION): Define.
        (DEBUG_ARANGES_SECTION): Define.
        (DEBUG_LINE_SECTION): Define.
        (DEBUG_PUBNAMES_SECTION): Define.
        (DEBUG_PUBTYPES_SECTION): Define.
        (DEBUG_STR_SECTION): Define.
        (DEBUG_RANGES_SECTION): Define.

Index: config/rs6000/aix71.h
===================================================================
+/* AIX 7.1 supports DWARF debugging, but XCOFF remains the default.  */
+#define DWARF2_DEBUGGING_INFO 1
+#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG
+#define DEBUG_INFO_SECTION      "0x10000"
+#define DEBUG_ABBREV_SECTION    "0x60000"
+#define DEBUG_ARANGES_SECTION   "0x50000"
+#define DEBUG_LINE_SECTION      "0x20000"
+#define DEBUG_PUBNAMES_SECTION  "0x30000"
+#define DEBUG_PUBTYPES_SECTION  "0x40000"
+#define DEBUG_STR_SECTION       "0x70000"
+#define DEBUG_RANGES_SECTION    "0x80000"

Comments

Richard Henderson Sept. 24, 2015, 4:46 p.m. UTC | #1
On 09/23/2015 07:39 PM, David Edelsohn wrote:
> Richard and Richard,
> 
> Appended is the updated version of the DWARF support patch for AIX.  I
> still can split out the length computation into a separate helper
> function, but, as I mentioned, it won't apply to the instance that
> uses a delta of two labels.
> 
> This version sets have_macinfo to False and disables add_AT_loc_list.
> It also define XCOFF_DEBUGGING_INFO to 0 by default in dwarf2out.c and
> dwarf2asm.c.
> 
> Thanks, David
> 
>         * dwarf2out.c (XCOFF_DEBUGGING_INFO): Default 0 definition.
>         (have_macinfo): Force to False for XCOFF_DEBUGGING_INFO.
>         (add_AT_loc_list): Return early if XCOFF_DEBUGGING_INFO.
>         (output_compilation_unit_header): Don't output length on AIX.
>         (output_pubnames): Don't output length on AIX.
>         (output_aranges): Delete argument. Compute length locally. Don't
>         output length on AIX.
>         (output_line_info): Don't output length on AIX.
>         (dwarf2out_finish): Don't compute aranges_length.
>         * dwarf2asm.c (XCOFF_DEBUGGING_INFO): Default 0 definition.
>         (dw2_asm_output_nstring): Emit .byte not .ascii on AIX.
>         * config/rs6000/rs6000.c (rs6000_output_dwrf_dtprel): Emit correct
>         symbol decoration for AIX.
>         (rs6000_xcoff_debug_unwind_info): New.
>         (rs6000_xcoff_asm_named_section): Emit .dwsect pseudo-op
>         for SECTION_DEBUG.
>         (rs6000_xcoff_declare_function_name): Emit different
>         .function pseudo-op when DWARF2_DEBUG. Don't call
>         xcoffout_declare_function for DWARF2_DEBUG.
>         * config/rs6000/xcoff.h (TARGET_DEBUG_UNWIND_INFO):
>         Redefine.
>         * config/rs6000/aix71.h (DWARF2_DEBUGGING_INFO): Define.
>         (PREFERRED_DEBUGGING_TYPE): Define.
>         (DEBUG_INFO_SECTION): Define.
>         (DEBUG_ABBREV_SECTION): Define.
>         (DEBUG_ARANGES_SECTION): Define.
>         (DEBUG_LINE_SECTION): Define.
>         (DEBUG_PUBNAMES_SECTION): Define.
>         (DEBUG_PUBTYPES_SECTION): Define.
>         (DEBUG_STR_SECTION): Define.
>         (DEBUG_RANGES_SECTION): Define.

Ok.

> +  else if (TARGET_XCOFF && GET_CODE (x) == SYMBOL_REF
> +          && SYMBOL_REF_TLS_MODEL (x) != 0)
> +    {
> +      if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_EXEC)
> +       fputs ("@le", file);
> +      else if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_INITIAL_EXEC)
> +       fputs ("@ie", file);
> +      else if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_GLOBAL_DYNAMIC
> +              || SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_DYNAMIC)
> +       fputs ("@m", file);
> +    }

FWIW, I would have written this:


    else if (TARGET_XCOFF && GET_CODE (x) == SYMBOL_REF)
      {
        switch (SYMBOL_REF_TLS_MODEL (x))
          {
          case 0:
            break;
          case TLS_MODEL_LOCAL_EXEC:
            fputs ("@le", file);
            break;
          case TLS_MODEL_INITIAL_EXEC:
            fputs ("@ie", file);
            break;
          case TLS_MODEL_GLOBAL_DYNAMIC:
          case TLS_MODEL_LOCAL_DYNAMIC:
            fputs ("@m", file);
            break;
          default:
            gcc_unreachable ();
          }
      }


r~
David Edelsohn Sept. 24, 2015, 6:40 p.m. UTC | #2
>> +  else if (TARGET_XCOFF && GET_CODE (x) == SYMBOL_REF
>> +          && SYMBOL_REF_TLS_MODEL (x) != 0)
>> +    {
>> +      if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_EXEC)
>> +       fputs ("@le", file);
>> +      else if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_INITIAL_EXEC)
>> +       fputs ("@ie", file);
>> +      else if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_GLOBAL_DYNAMIC
>> +              || SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_DYNAMIC)
>> +       fputs ("@m", file);
>> +    }
>
> FWIW, I would have written this:
>
>
>     else if (TARGET_XCOFF && GET_CODE (x) == SYMBOL_REF)
>       {
>         switch (SYMBOL_REF_TLS_MODEL (x))
>           {
>           case 0:
>             break;
>           case TLS_MODEL_LOCAL_EXEC:
>             fputs ("@le", file);
>             break;
>           case TLS_MODEL_INITIAL_EXEC:
>             fputs ("@ie", file);
>             break;
>           case TLS_MODEL_GLOBAL_DYNAMIC:
>           case TLS_MODEL_LOCAL_DYNAMIC:
>             fputs ("@m", file);
>             break;
>           default:
>             gcc_unreachable ();
>           }
>       }

Okay, I will retest with that.

I separately have some good news and some bad news.
Good news: AIX added support for the initially missing DWARF sections.
Bad news: The support is in an AIX service pack whose presence on a
system requires effort to determine.

Thanks, David
Richard Henderson Sept. 24, 2015, 6:49 p.m. UTC | #3
On 09/24/2015 11:40 AM, David Edelsohn wrote:
> Good news: AIX added support for the initially missing DWARF sections.

Yay!

> Bad news: The support is in an AIX service pack whose presence on a
> system requires effort to determine.

Boo!

Well, we've had worse problems with Solaris in the past.  We should certainly
put a note about the service pack in the installation instructions.

Is it reasonable to require the service pack be installed before making use of
any of this?  My thinking is that, without location lists, anything except -O0
-g2 is going to be unusable, since most local variables will no longer have any
location data.  At which point you might as well just stick with xcoff
debugging, yes?


r~
David Edelsohn Sept. 24, 2015, 7:02 p.m. UTC | #4
On Thu, Sep 24, 2015 at 2:49 PM, Richard Henderson <rth@redhat.com> wrote:
> On 09/24/2015 11:40 AM, David Edelsohn wrote:
>> Good news: AIX added support for the initially missing DWARF sections.
>
> Yay!
>
>> Bad news: The support is in an AIX service pack whose presence on a
>> system requires effort to determine.
>
> Boo!
>
> Well, we've had worse problems with Solaris in the past.  We should certainly
> put a note about the service pack in the installation instructions.
>
> Is it reasonable to require the service pack be installed before making use of
> any of this?  My thinking is that, without location lists, anything except -O0
> -g2 is going to be unusable, since most local variables will no longer have any
> location data.  At which point you might as well just stick with xcoff
> debugging, yes?

I agree that debugging without location lists is fairly useless.  I
need to find out what happens without the AIX service packs.  If the
assembler and linker pass the sections with the additional numbers
through and older DBX doesn't know about the sections, it doesn't
matter.  If the assembler and linker generate errors, it further
delays deployment in GCC.

Thanks, David
Richard Henderson Sept. 24, 2015, 8:05 p.m. UTC | #5
On 09/24/2015 12:02 PM, David Edelsohn wrote:
> If the assembler and linker pass the sections with the additional numbers 
> through and older DBX doesn't know about the sections, it doesn't matter.

Agreed.  In that case we simply emit the data all the time and let capable
debuggers pick it up.

> If the assembler and linker generate errors, it further
> delays deployment in GCC.

If the assembler generates errors, then surely it's easy to error out at
configure time, printing a note about the service pack.

So, assuming this is true, when configuring for aix7.1,

 * configure --without-dwarf2 disables support for dwarf2 entirely,
   avoiding problems with any missing SP.  Presumably by *not* including
   config/rs6000/aix71.h.

 * configure checks as/ld as required, erroring out if the SP isn't present;
   dwarf2out always emits all of the usual dwarf data.

Sound good?


r~
David Edelsohn Sept. 24, 2015, 11:28 p.m. UTC | #6
On Thu, Sep 24, 2015 at 4:05 PM, Richard Henderson <rth@redhat.com> wrote:

>> If the assembler and linker generate errors, it further
>> delays deployment in GCC.
>
> If the assembler generates errors, then surely it's easy to error out at
> configure time, printing a note about the service pack.
>
> So, assuming this is true, when configuring for aix7.1,
>
>  * configure --without-dwarf2 disables support for dwarf2 entirely,
>    avoiding problems with any missing SP.  Presumably by *not* including
>    config/rs6000/aix71.h.
>
>  * configure checks as/ld as required, erroring out if the SP isn't present;
>    dwarf2out always emits all of the usual dwarf data.
>
> Sound good?

Older assemblers produce an error when presented with the new sections.

I was planning to commit the current patch, which is supported by AIX
7.1.  And follow up with another patch that adds a configure test for
the additional sections support (HAVE_XCOFF_DWARF_EXTRA?) to tweak the
output.  As you mentioned, the minimal sections should allow debugging
with -O0 -g2, which is equivalent to the stabs functionality.

Thanks, David
Mike Stump Sept. 25, 2015, 12:01 a.m. UTC | #7
On Sep 24, 2015, at 11:40 AM, David Edelsohn <dje.gcc@gmail.com> wrote:
> AIX added support for the initially missing DWARF sections.
> Bad news: The support is in an AIX service pack whose presence on a
> system requires effort to determine.

So, we faced this problem at Apple, and we just required that people apply the minor updates.  Sometimes life is too short.  I’d just add a line in the doc that says, X isn’t supported without Y.
David Edelsohn Sept. 25, 2015, 12:15 a.m. UTC | #8
On Thu, Sep 24, 2015 at 8:01 PM, Mike Stump <mikestump@comcast.net> wrote:
> On Sep 24, 2015, at 11:40 AM, David Edelsohn <dje.gcc@gmail.com> wrote:
>> AIX added support for the initially missing DWARF sections.
>> Bad news: The support is in an AIX service pack whose presence on a
>> system requires effort to determine.
>
> So, we faced this problem at Apple, and we just required that people apply the minor updates.  Sometimes life is too short.  I’d just add a line in the doc that says, X isn’t supported without Y.

The DWARF support is useful with the minimal sections.  In fact, most
of the AIX systems to which I personally have access do not have the
support installed.  I don't have control over the patches installed on
most of the systems.  This is the difference between a server
operating system and a personal operating system: most people can
install an update on their Mac OS X system, but not everyone can
install an update on their AIX system.  Many more people can use and
test the DWARF support on AIX without requiring the latest update.

Thanks, David
diff mbox

Patch

Index: dwarf2out.c
===================================================================
--- dwarf2out.c (revision 228071)
+++ dwarf2out.c (working copy)
@@ -108,6 +108,10 @@  static rtx_insn *last_var_location_insn;
 static rtx_insn *cached_next_real_insn;
 static void dwarf2out_decl (tree);

+#ifndef XCOFF_DEBUGGING_INFO
+#define XCOFF_DEBUGGING_INFO 0
+#endif
+
 #ifdef VMS_DEBUGGING_INFO
 int vms_file_stats_name (const char *, long long *, long *, char *, int *);

@@ -2995,7 +2999,8 @@  static GTY (()) vec<macinfo_entry, va_gc> *macinfo
 /* True if .debug_macinfo or .debug_macros section is going to be
    emitted.  */
 #define have_macinfo \
-  (debug_info_level >= DINFO_LEVEL_VERBOSE \
+  (!XCOFF_DEBUGGING_INFO \
+   && debug_info_level >= DINFO_LEVEL_VERBOSE \
    && !macinfo_table->is_empty ())
 /* Array of dies for which we should generate .debug_ranges info.  */
@@ -3202,7 +3207,7 @@  static void add_enumerator_pubname (const char *,
 static void add_pubname_string (const char *, dw_die_ref);
 static void add_pubtype (tree, dw_die_ref);
 static void output_pubnames (vec<pubname_entry, va_gc> *);
-static void output_aranges (unsigned long);
+static void output_aranges (void);
 static unsigned int add_ranges_num (int);
 static unsigned int add_ranges (const_tree);
 static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
@@ -4236,6 +4241,9 @@  add_AT_loc_list (dw_die_ref die, enum dwarf_attrib
 {
   dw_attr_node attr;

+  if (XCOFF_DEBUGGING_INFO)
+    return;
+
   attr.dw_attr = attr_kind;
   attr.dw_attr_val.val_class = dw_val_class_loc_list;
   attr.dw_attr_val.val_entry = NULL;
@@ -9197,12 +9205,16 @@  output_compilation_unit_header (void)
      DWARFv5 draft DIE tags in DWARFv4 format.  */
   int ver = dwarf_version < 5 ? dwarf_version : 4;

-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
-    dw2_asm_output_data (4, 0xffffffff,
-      "Initial length escape value indicating 64-bit DWARF extension");
-  dw2_asm_output_data (DWARF_OFFSET_SIZE,
-                      next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
-                      "Length of Compilation Unit Info");
+  if (!XCOFF_DEBUGGING_INFO)
+    {
+      if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+       dw2_asm_output_data (4, 0xffffffff,
+         "Initial length escape value indicating 64-bit DWARF extension");
+      dw2_asm_output_data (DWARF_OFFSET_SIZE,
+                          next_die_offset - DWARF_INITIAL_LENGTH_SIZE,
+                          "Length of Compilation Unit Info");
+    }
+
   dw2_asm_output_data (2, ver, "DWARF version number");
   dw2_asm_output_offset (DWARF_OFFSET_SIZE, abbrev_section_label,
                         debug_abbrev_section,
@@ -9632,10 +9644,14 @@  output_pubnames (vec<pubname_entry, va_gc> *names)
   unsigned long pubnames_length = size_of_pubnames (names);
   pubname_entry *pub;

-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
-    dw2_asm_output_data (4, 0xffffffff,
-      "Initial length escape value indicating 64-bit DWARF extension");
-  dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length, "Pub Info Length");
+  if (!XCOFF_DEBUGGING_INFO)
+    {
+      if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+       dw2_asm_output_data (4, 0xffffffff,
+         "Initial length escape value indicating 64-bit DWARF extension");
+      dw2_asm_output_data (DWARF_OFFSET_SIZE, pubnames_length,
+                          "Pub Info Length");
+    }

   /* Version number for pubnames/pubtypes is independent of dwarf version.  */
   dw2_asm_output_data (2, 2, "DWARF Version");
@@ -9705,15 +9721,20 @@  output_pubtables (void)
    text section generated for this compilation unit.  */

 static void
-output_aranges (unsigned long aranges_length)
+output_aranges (void)
 {
   unsigned i;
+  unsigned long aranges_length = size_of_aranges ();
+
+  if (!XCOFF_DEBUGGING_INFO)
+    {
+      if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+       dw2_asm_output_data (4, 0xffffffff,
+         "Initial length escape value indicating 64-bit DWARF extension");
+      dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
+                          "Length of Address Ranges Info");
+    }

-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
-    dw2_asm_output_data (4, 0xffffffff,
-      "Initial length escape value indicating 64-bit DWARF extension");
-  dw2_asm_output_data (DWARF_OFFSET_SIZE, aranges_length,
-                      "Length of Address Ranges Info");
   /* Version number for aranges is still 2, even up to DWARF5.  */
   dw2_asm_output_data (2, 2, "DWARF Version");
   if (dwarf_split_debug_info)
@@ -10397,11 +10418,15 @@  output_line_info (bool prologue_only)
   ASM_GENERATE_INTERNAL_LABEL (p1, LN_PROLOG_AS_LABEL, 0);
   ASM_GENERATE_INTERNAL_LABEL (p2, LN_PROLOG_END_LABEL, 0);

-  if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
-    dw2_asm_output_data (4, 0xffffffff,
-      "Initial length escape value indicating 64-bit DWARF extension");
-  dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
-                       "Length of Source Line Info");
+  if (!XCOFF_DEBUGGING_INFO)
+    {
+      if (DWARF_INITIAL_LENGTH_SIZE - DWARF_OFFSET_SIZE == 4)
+       dw2_asm_output_data (4, 0xffffffff,
+         "Initial length escape value indicating 64-bit DWARF extension");
+      dw2_asm_output_delta (DWARF_OFFSET_SIZE, l2, l1,
+                           "Length of Source Line Info");
+    }
+
   ASM_OUTPUT_LABEL (asm_out_file, l1);

   dw2_asm_output_data (2, ver, "DWARF Version");
@@ -22031,7 +22056,7 @@  dwarf_file_hasher::hash (dwarf_file_data *p)
    just a unique number which is associated with only that one filename.  We
    need such numbers for the sake of generating labels (in the .debug_sfnames
    section) and references to those files numbers (in the .debug_srcinfo
-   and.debug_macinfo sections).  If the filename given as an argument is not
+   and .debug_macinfo sections).  If the filename given as an argument is not
    found in our current list, add it to the list and assign it the next
    available unique index number.  */

@@ -25502,10 +25527,8 @@  dwarf2out_finish (const char *filename)
      generate a table that would have contained data.  */
   if (info_section_emitted)
     {
-      unsigned long aranges_length = size_of_aranges ();
-
       switch_to_section (debug_aranges_section);
-      output_aranges (aranges_length);
+      output_aranges ();
     }

   /* Output ranges section if necessary.  */
Index: dwarf2asm.c
===================================================================
--- dwarf2asm.c (revision 228071)
+++ dwarf2asm.c (working copy)
@@ -34,6 +34,10 @@  along with GCC; see the file COPYING3.  If not see
 #include "dwarf2.h"
 #include "tm_p.h"

+#ifndef XCOFF_DEBUGGING_INFO
+#define XCOFF_DEBUGGING_INFO 0
+#endif
+
 ^L
 /* Output an unaligned integer with the given value and size.  Prefer not
    to print a newline, since the caller may want to add a comment.  */
@@ -306,7 +310,11 @@  dw2_asm_output_nstring (const char *str, size_t or

   if (flag_debug_asm && comment)
     {
-      fputs ("\t.ascii \"", asm_out_file);
+      if (XCOFF_DEBUGGING_INFO)
+       fputs ("\t.byte \"", asm_out_file);
+      else
+       fputs ("\t.ascii \"", asm_out_file);
+
       for (i = 0; i < len; i++)
        {
          int c = str[i];
Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c      (revision 228071)
+++ config/rs6000/rs6000.c      (working copy)
@@ -7204,7 +7204,19 @@  rs6000_output_dwarf_dtprel (FILE *file, int size,
       gcc_unreachable ();
     }
   output_addr_const (file, x);
-  fputs ("@dtprel+0x8000", file);
+  if (TARGET_ELF)
+    fputs ("@dtprel+0x8000", file);
+  else if (TARGET_XCOFF && GET_CODE (x) == SYMBOL_REF
+          && SYMBOL_REF_TLS_MODEL (x) != 0)
+    {
+      if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_EXEC)
+       fputs ("@le", file);
+      else if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_INITIAL_EXEC)
+       fputs ("@ie", file);
+      else if (SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_GLOBAL_DYNAMIC
+              || SYMBOL_REF_TLS_MODEL (x) == TLS_MODEL_LOCAL_DYNAMIC)
+       fputs ("@m", file);
+    }
 }

 /* Return true if X is a symbol that refers to real (rather than emulated)
@@ -30684,6 +30696,12 @@  rs6000_elf_file_end (void)
 #endif
 #if TARGET_XCOFF
+static enum unwind_info_type
+rs6000_xcoff_debug_unwind_info (void)
+{
+  return UI_NONE;
+}
+
 static void
 rs6000_xcoff_asm_output_anchor (rtx symbol)
 {
@@ -30805,6 +30823,11 @@  rs6000_xcoff_asm_named_section (const char *name,
   int smclass;
   static const char * const suffix[4] = { "PR", "RO", "RW", "TL" };

+  if (flags & SECTION_DEBUG)
+    {
+      fprintf (asm_out_file, "\t.dwsect %s\n", name);
+      return;
+    }
   if (flags & SECTION_CODE)
     smclass = 0;
   else if (flags & SECTION_TLS)
@@ -31140,8 +31163,16 @@  rs6000_xcoff_declare_function_name (FILE *file, co
   fputs (":\n", file);
   data.function_descriptor = true;
   symtab_node::get (decl)->call_for_symbol_and_aliases (rs6000_declare_alias, \
&data, true);
-  if (write_symbols != NO_DEBUG && !DECL_IGNORED_P (decl))
-    xcoffout_declare_function (file, decl, buffer);
+  if (!DECL_IGNORED_P (decl))
+    {
+      if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
+       xcoffout_declare_function (file, decl, buffer);
+      else if (write_symbols == DWARF2_DEBUG)
+       {
+         name = (*targetm.strip_name_encoding) (name);
+         fprintf (file, "\t.function .%s,.%s,2,0\n", name, name);
+       }
+    }
   return;
 }

Index: config/rs6000/xcoff.h
===================================================================
--- config/rs6000/xcoff.h       (revision 228071)
+++ config/rs6000/xcoff.h       (working copy)
@@ -86,6 +86,8 @@ 
               || (SCALAR_FLOAT_MODE_P (GET_MODE (X))                   \
                   && ! TARGET_NO_FP_IN_TOC)))))

+#undef TARGET_DEBUG_UNWIND_INFO
+#define TARGET_DEBUG_UNWIND_INFO  rs6000_xcoff_debug_unwind_info
 #define TARGET_ASM_OUTPUT_ANCHOR  rs6000_xcoff_asm_output_anchor
 #define TARGET_ASM_GLOBALIZE_LABEL  rs6000_xcoff_asm_globalize_label
 #define TARGET_ASM_INIT_SECTIONS  rs6000_xcoff_asm_init_sections