Since -fsection-anchors is very useful for PPC-Darwin, I decided to
see what I needed to do to support them.
I started by just doing a bootstrap with them enabled by default
and ran into the first issue of SET_ASM_OP not being set.  Next
I ran into the issue of quoting ". + 0" which caused the assembler
to think it is a symbol instead of an addition of . and 0.

The next issue I could not figure out how to fix, it is wrong code
caused by merging constant strings together.
Here is the reduced testcase (reduced from genmodes.c):
int modes;
emit_mode_class (void)
{
  int t;
  for(t = 0;t<modes;t++)
      __builtin_puts ("");
}
int main(void)
{
  char a[3] = "-h";
  if (!strcmp (a, "-h")) ; else  __builtin_abort ();
  emit_mode_class ();
}

If someone could look into this, it would be nice, I think the use
of .cstring and anchors are not supported together as .cstring section
can be merged.

There was another issue but I could not get to that issue with a normal
bootstrap but I could get to it with -j3.  The problem was I could not
figure out which file was causing the issue.

Thanks,
Andrew Pinski

PS Attached is the patch so far to support -fsection-anchors on ppc-darwin. I am unhappy about the quoting hack I had to do but it works.

Index: config/darwin.h
===================================================================
--- config/darwin.h     (revision 111255)
+++ config/darwin.h     (working copy)
@@ -455,6 +459,9 @@ Boston, MA 02110-1301, USA.  */
 
 #define USER_LABEL_PREFIX "_"
 
+#undef  SET_ASM_OP
+#define SET_ASM_OP      "\t.set\t"
+
 /* Don't output a .file directive.  That is only used by the assembler for
    error reporting.  */
 #undef TARGET_ASM_FILE_START_FILE_DIRECTIVE
@@ -563,6 +570,8 @@ Boston, MA 02110-1301, USA.  */
          fprintf (FILE, "L%s", xname);                                      \
        else if (!strncmp (xname, ".objc_class_name_", 17))                  \
         fprintf (FILE, "%s", xname);                                        \
+       else if (xname[0] == '.')                                            \
+        fprintf (FILE, "%s", xname);                                        \
        else if (xname[0] != '"' && name_needs_quotes (xname))               \
         fprintf (FILE, "\"%s\"", xname);                                    \
        else                                                                 \
Index: config/darwin.c
===================================================================
--- config/darwin.c     (revision 111255)
+++ config/darwin.c     (working copy)
@@ -146,6 +146,8 @@ int
 name_needs_quotes (const char *name)
 {
   int c;
+  if (name[0] == '.' && name[1] == ' ')
+    return 0;
   while ((c = *name++) != '\0')
     if (! ISIDNUM (c) && c != '.' && c != '$')
       return 1;

Reply via email to