> >> AFAICT, for gcc+gas it should already work with binutils that include
> >> the AdaCore patch for DWARF support. But this has apparently not been
> >> tested with AIX ld, and there are AdaCore local patches pending.
> >> http://sourceware.org/ml/binutils/2011-04/msg00250.html
> >> http://www.sourceware.org/ml/gdb/2013-01/msg00030.html
> 
> What is the status of merging Adacore's patches for DWARF support on AIX?

Sorry, David. I have been meaning to work on that ever since
we talked about it...

I spent some time today isolating the patches. I am currently
testing the patches we wrote for support on AIX 5.3. I then see
a few more patches to extend support to AIX 7.1 - section alignment
constraints, and stuff related to TLS.

Just for anyone who is curious, this is what I am testing.
It is missing the pieces for the other tools such as objdump,
for instance. But I think those can be submitted separately.

It might not apply to HEAD just yet, because I'm going at it
step by step. For those who use git, I applied it on top of:

    commit 889f73fdb5bec852e083f47703f31592ef3ee77b
    Author: Alan Modra <amo...@bigpond.net.au>
    Date:   Thu Oct 18 23:00:04 2012 +0000

        daily update

-- 
Joel
>From dc928a0dbd0e762577c51204b043d6b6f066940d Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobec...@adacore.com>
Date: Thu, 14 Feb 2013 23:53:25 +0100
Subject: [PATCH] AIX: add DWARF support

        * bfd/coff-rs6000.c (xcoff_dwsect_names): Add .dwframe,
        .dwloc, .dwmacif and .dwmacro.
        * bfd/libxcoff.h (XCOFF_DWSECT_NBR_NAMES): Set to 12.
        * xcofflink.c (xcoff_mark): Mark all debugging symbols.
        (bfd_xcoff_size_dynamic_sections): Mark all debugging sections.
        (xcoff_link_input_bfd): Gah???
        * gas/config/tc-ppc.c (ppc_named_section): Add handling
        of DWARF sections.
---
 bfd/coff-rs6000.c   |    6 ++++-
 bfd/libxcoff.h      |    2 +-
 bfd/xcofflink.c     |   65 +++++++++++++++++++++++++++++---------------------
 gas/config/tc-ppc.c |   29 ++++++++++++++++++++++-
 4 files changed, 72 insertions(+), 30 deletions(-)

diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index 0945aca..9388ce3 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -3916,7 +3916,11 @@ const struct xcoff_dwsect_name xcoff_dwsect_names[] = {
   { SSUBTYP_DWARNGE, ".dwarnge",  TRUE },
   { SSUBTYP_DWABREV, ".dwabrev",  FALSE },
   { SSUBTYP_DWSTR,   ".dwstr",    TRUE },
-  { SSUBTYP_DWRNGES, ".dwrnges",  TRUE }
+  { SSUBTYP_DWRNGES, ".dwrnges",  TRUE },
+  { 0x47000000,      ".dwframe",  TRUE },
+  { 0x47010000,      ".dwloc",    TRUE },
+  { 0x47020000,      ".dwmacif",  FALSE },
+  { 0x47030000,      ".dwmacro",  FALSE }
 };
 
 static const struct xcoff_backend_data_rec bfd_xcoff_backend_data =
diff --git a/bfd/libxcoff.h b/bfd/libxcoff.h
index 53a5e72..7583d5c 100644
--- a/bfd/libxcoff.h
+++ b/bfd/libxcoff.h
@@ -251,7 +251,7 @@ struct xcoff_dwsect_name {
 
 /* Number of entries in the array.  The number is known and public so that user
    can 'extend' this array by index.  */
-#define XCOFF_DWSECT_NBR_NAMES	8
+#define XCOFF_DWSECT_NBR_NAMES	12
 
 /* The dwarf sections array.  */
 extern const struct xcoff_dwsect_name
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index 4adfb17..ad31643 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -2902,8 +2902,7 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
   sec->flags |= SEC_MARK;
 
   if (sec->owner->xvec == info->output_bfd->xvec
-      && coff_section_data (sec->owner, sec) != NULL
-      && xcoff_section_data (sec->owner, sec) != NULL)
+      && coff_section_data (sec->owner, sec) != NULL)
     {
       struct xcoff_link_hash_entry **syms;
       struct internal_reloc *rel, *relend;
@@ -2911,18 +2910,21 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
       unsigned long i, first, last;
 
       /* Mark all the symbols in this section.  */
-      syms = obj_xcoff_sym_hashes (sec->owner);
-      csects = xcoff_data (sec->owner)->csects;
-      first = xcoff_section_data (sec->owner, sec)->first_symndx;
-      last = xcoff_section_data (sec->owner, sec)->last_symndx;
-      for (i = first; i <= last; i++)
-	if (csects[i] == sec
-	    && syms[i] != NULL
-	    && (syms[i]->flags & XCOFF_MARK) == 0)
-	  {
-	    if (!xcoff_mark_symbol (info, syms[i]))
-	      return FALSE;
-	  }
+      if (xcoff_section_data (sec->owner, sec) != NULL)
+        {
+          syms = obj_xcoff_sym_hashes (sec->owner);
+          csects = xcoff_data (sec->owner)->csects;
+          first = xcoff_section_data (sec->owner, sec)->first_symndx;
+          last = xcoff_section_data (sec->owner, sec)->last_symndx;
+          for (i = first; i <= last; i++)
+            if (csects[i] == sec
+                && syms[i] != NULL
+                && (syms[i]->flags & XCOFF_MARK) == 0)
+              {
+                if (!xcoff_mark_symbol (info, syms[i]))
+                  return FALSE;
+              }
+        }
 
       /* Look through the section relocs.  */
       if ((sec->flags & SEC_RELOC) != 0
@@ -2965,7 +2967,8 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
 
 	      /* See if this reloc needs to be copied into the .loader
 		 section.  */
-	      if (xcoff_need_ldrel_p (info, rel, h))
+	      if ((sec->flags & SEC_DEBUGGING) == 0
+                  && xcoff_need_ldrel_p (info, rel, h))
 		{
 		  ++xcoff_hash_table (info)->ldrel_count;
 		  if (h != NULL)
@@ -3760,6 +3763,17 @@ bfd_xcoff_size_dynamic_sections (bfd *output_bfd,
 	  if (ldinfo.failed)
 	    goto error_return;
 	}
+      /* Mark all debugging sections.  */
+      for (sub = info->input_bfds; sub != NULL; sub = sub->link_next)
+	{
+	  asection *o;
+
+	  for (o = sub->sections; o != NULL; o = o->next)
+            if ((o->flags & SEC_DEBUGGING) != 0
+                && (o->flags & SEC_MARK) == 0
+                && ! xcoff_mark (info, o))
+              goto error_return;
+        }
       xcoff_sweep (info);
       xcoff_hash_table (info)->gc = TRUE;
     }
@@ -4920,7 +4934,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 
 		      if (indx != -1)
 			irel->r_symndx = indx;
-		      else
+                      else if ((o->flags & SEC_DEBUGGING) == 0)
 			{
 
 			  struct internal_syment *is;
@@ -4933,19 +4947,16 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
 			     this case, but I don't think it's worth it.  */
 			  is = flinfo->internal_syms + r_symndx;
 
-                          if (is->n_sclass != C_DWARF)
-                            {
-                              name = (_bfd_coff_internal_syment_name
-                                      (input_bfd, is, buf));
+                          name = (_bfd_coff_internal_syment_name
+                                  (input_bfd, is, buf));
 
-                              if (name == NULL)
-                                return FALSE;
+                          if (name == NULL)
+                            return FALSE;
 
-                              if (!(*flinfo->info->callbacks->unattached_reloc)
-                                  (flinfo->info, name, input_bfd, o,
-                                   irel->r_vaddr))
-                                return FALSE;
-                            }
+                          if (!(*flinfo->info->callbacks->unattached_reloc)
+                              (flinfo->info, name, input_bfd, o,
+                               irel->r_vaddr))
+                            return FALSE;
 			}
 		    }
 		}
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 2820c31..8579c2d 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -3951,7 +3951,34 @@ ppc_named_section (int ignore ATTRIBUTE_UNUSED)
     real_name = ".data[RW]";
   else
     {
-      as_bad (_("the XCOFF file format does not support arbitrary sections"));
+      /* Entries in this array correspond to the ones in
+         xcoff_dwsect_names.  */
+      static const char * const dwarf_sections[XCOFF_DWSECT_NBR_NAMES] = {
+        ".debug_info",
+        ".debug_line",
+        ".debug_pubnames",
+        ".debug_pubtypes",
+        ".debug_aranges",
+        ".debug_abbrev",
+        ".debug_str",
+        ".debug_ranges",
+        ".debug_frame",
+        ".debug_loc",
+        ".debug_macinfo",
+        ".debug_macro", };
+      int i;
+
+      /* Try dwarf sections.  */
+      for (i = 0; i < XCOFF_DWSECT_NBR_NAMES; i++)
+        if (strcmp (user_name, dwarf_sections[i]) == 0)
+          {
+            *input_line_pointer = c;
+            demand_empty_rest_of_line ();
+            ppc_change_debug_section (i, 0);
+            return;
+          }
+
+      as_bad (_("The XCOFF file format does not support arbitrary sections"));
       *input_line_pointer = c;
       ignore_rest_of_line ();
       return;
-- 
1.6.5.rc2

Reply via email to