OSDN Git Service

PR target/35483
authordje <dje@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Oct 2008 12:23:55 +0000 (12:23 +0000)
committerdje <dje@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 15 Oct 2008 12:23:55 +0000 (12:23 +0000)
        Based on patches by Laurent Vivier.
        * xcoffout.h (DBX_FINISH_STABS): Translate dollar sign to underscore.
        * config/rs6000/rs6000-protos.h (rs6000_xcoff_strip_dollar): Declare.
        * config/rs6000/xcoff.h (ASM_DECLARE_FUNCTION_NAME): Translate
        dollar sign to underscore.
        (ASM_OUTPUT_EXTERNAL): Same.
        (ASM_OUTPUT_LABELREF): New.
        * config/rs6000/rs6000.c (rs6000_xcoff_strip_dollar): New.

        * config/rs6000/aix51.h (TARGET_USE_JCR_SECTION): Define.
        * config/rs6000/aix52.h (TARGET_USE_JCR_SECTION): Define.
        * config/rs6000/aix53.h (TARGET_USE_JCR_SECTION): Define.
        * config/rs6000/aix61.h (TARGET_USE_JCR_SECTION): Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@141134 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/config/rs6000/aix51.h
gcc/config/rs6000/aix52.h
gcc/config/rs6000/aix53.h
gcc/config/rs6000/aix61.h
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/xcoff.h
gcc/xcoffout.h

index 4a5a9ec..981b94a 100644 (file)
@@ -185,3 +185,8 @@ do {                                                                        \
 
 /* This target uses the aix64.opt file.  */
 #define TARGET_USES_AIX64_OPT 1
+
+/* This target defines SUPPORTS_WEAK and TARGET_ASM_NAMED_SECTION,
+   but does not have crtbegin/end.  */
+
+#define TARGET_USE_JCR_SECTION 0
index f0744e1..b40e467 100644 (file)
@@ -196,3 +196,8 @@ extern long long int    atoll(const char *);
 
 /* This target uses the aix64.opt file.  */
 #define TARGET_USES_AIX64_OPT 1
+
+/* This target defines SUPPORTS_WEAK and TARGET_ASM_NAMED_SECTION,
+   but does not have crtbegin/end.  */
+
+#define TARGET_USE_JCR_SECTION 0
index f599508..09cd2bf 100644 (file)
@@ -192,3 +192,8 @@ extern long long int    atoll(const char *);
 
 /* This target uses the aix64.opt file.  */
 #define TARGET_USES_AIX64_OPT 1
+
+/* This target defines SUPPORTS_WEAK and TARGET_ASM_NAMED_SECTION,
+   but does not have crtbegin/end.  */
+
+#define TARGET_USE_JCR_SECTION 0
index 9e01bca..e62a775 100644 (file)
@@ -194,4 +194,11 @@ extern long long int    atoll(const char *);
 /* This target uses the aix64.opt file.  */
 #define TARGET_USES_AIX64_OPT 1
 
+/* This target defines SUPPORTS_WEAK and TARGET_ASM_NAMED_SECTION,
+   but does not have crtbegin/end.  */
+
+#define TARGET_USE_JCR_SECTION 0
+
+/* Default to 128 bit long double.  */
+
 #define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128
index 0c5b111..2f1b04c 100644 (file)
@@ -181,6 +181,10 @@ extern void rs6000_cpu_cpp_builtins (struct cpp_reader *);
 char *output_call (rtx, rtx *, int, int);
 #endif
 
+#ifdef NO_DOLLAR_IN_LABEL
+const char * rs6000_xcoff_strip_dollar (const char *);
+#endif
+
 void rs6000_final_prescan_insn (rtx, rtx *operand, int num_operands);
 
 extern bool rs6000_hard_regno_mode_ok_p[][FIRST_PSEUDO_REGISTER];
index 05f4e26..612c7d4 100644 (file)
@@ -18041,6 +18041,35 @@ toc_hash_eq (const void *h1, const void *h2)
   || strncmp ("_ZTI", name, strlen ("_ZTI")) == 0      \
   || strncmp ("_ZTC", name, strlen ("_ZTC")) == 0)
 
+#ifdef NO_DOLLAR_IN_LABEL
+/* Return a GGC-allocated character string translating dollar signs in
+   input NAME to underscores.  Used by XCOFF ASM_OUTPUT_LABELREF.  */
+
+const char *
+rs6000_xcoff_strip_dollar (const char *name)
+{
+  char *strip, *p;
+  int len;
+
+  p = strchr (name, '$');
+
+  if (p == 0 || p == name)
+    return name;
+
+  len = strlen (name);
+  strip = (char *) alloca (len + 1);
+  strcpy (strip, name);
+  p = strchr (strip, '$');
+  while (p)
+    {
+      *p = '_';
+      p = strchr (p + 1, '$');
+    }
+
+  return ggc_alloc_string (strip, len);
+}
+#endif
+
 void
 rs6000_output_symbol_ref (FILE *file, rtx x)
 {
index 3cf6e4b..08e06b4 100644 (file)
 /* This macro produces the initial definition of a function name.
    On the RS/6000, we need to place an extra '.' in the function name and
    output the function descriptor.
+   Dollar signs are converted to underscores.
 
    The csect for the function will have already been created when
    text_section was selected.  We do have to go back to that csect, however.
    are placeholders which no longer have any use.  */
 
 #define ASM_DECLARE_FUNCTION_NAME(FILE,NAME,DECL)              \
-{ if (TREE_PUBLIC (DECL))                                      \
+{ char *buffer = (char *) alloca (strlen (NAME) + 1);          \
+  char *p;                                                     \
+  int dollar_inside = 0;                                       \
+  strcpy (buffer, NAME);                                       \
+  p = strchr (buffer, '$');                                    \
+  while (p) {                                                  \
+    *p = '_';                                                  \
+    dollar_inside++;                                           \
+    p = strchr (p + 1, '$');                                   \
+  }                                                            \
+  if (TREE_PUBLIC (DECL))                                      \
     {                                                          \
       if (!RS6000_WEAK || !DECL_WEAK (decl))                   \
        {                                                       \
+          if (dollar_inside) {                                 \
+              fprintf(FILE, "\t.rename .%s,\".%s\"\n", buffer, NAME);  \
+              fprintf(FILE, "\t.rename %s,\"%s\"\n", buffer, NAME);    \
+           }                                                   \
          fputs ("\t.globl .", FILE);                           \
-         RS6000_OUTPUT_BASENAME (FILE, NAME);                  \
+         RS6000_OUTPUT_BASENAME (FILE, buffer);                \
          putc ('\n', FILE);                                    \
        }                                                       \
     }                                                          \
   else                                                         \
     {                                                          \
+      if (dollar_inside) {                                     \
+          fprintf(FILE, "\t.rename .%s,\".%s\"\n", buffer, NAME);      \
+          fprintf(FILE, "\t.rename %s,\"%s\"\n", buffer, NAME);        \
+       }                                                       \
       fputs ("\t.lglobl .", FILE);                             \
-      RS6000_OUTPUT_BASENAME (FILE, NAME);                     \
+      RS6000_OUTPUT_BASENAME (FILE, buffer);                   \
       putc ('\n', FILE);                                       \
     }                                                          \
   fputs ("\t.csect ", FILE);                                   \
-  RS6000_OUTPUT_BASENAME (FILE, NAME);                         \
+  RS6000_OUTPUT_BASENAME (FILE, buffer);                       \
   fputs (TARGET_32BIT ? "[DS]\n" : "[DS],3\n", FILE);          \
-  RS6000_OUTPUT_BASENAME (FILE, NAME);                         \
+  RS6000_OUTPUT_BASENAME (FILE, buffer);                       \
   fputs (":\n", FILE);                                         \
   fputs (TARGET_32BIT ? "\t.long ." : "\t.llong .", FILE);     \
-  RS6000_OUTPUT_BASENAME (FILE, NAME);                         \
+  RS6000_OUTPUT_BASENAME (FILE, buffer);                       \
   fputs (", TOC[tc0], 0\n", FILE);                             \
   in_section = NULL;                                           \
   switch_to_section (function_section (DECL));                 \
   putc ('.', FILE);                                            \
-  RS6000_OUTPUT_BASENAME (FILE, NAME);                         \
+  RS6000_OUTPUT_BASENAME (FILE, buffer);                       \
   fputs (":\n", FILE);                                         \
   if (write_symbols != NO_DEBUG)                               \
-    xcoffout_declare_function (FILE, DECL, NAME);              \
+    xcoffout_declare_function (FILE, DECL, buffer);            \
 }
 
 /* Output a reference to SYM on FILE.  */
 #define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \
   rs6000_output_symbol_ref (FILE, SYM)
 
-/* This says how to output an external.  */
+/* This says how to output an external.
+   Dollar signs are converted to underscores.  */
 
 #undef  ASM_OUTPUT_EXTERNAL
 #define ASM_OUTPUT_EXTERNAL(FILE, DECL, NAME)                          \
-{ rtx _symref = XEXP (DECL_RTL (DECL), 0);                             \
+{ char *buffer = (char *) alloca (strlen (NAME) + 1);                  \
+  char *p;                                                             \
+  rtx _symref = XEXP (DECL_RTL (DECL), 0);                             \
+  int dollar_inside = 0;                                               \
+  strcpy (buffer, NAME);                                               \
+  p = strchr (buffer, '$');                                            \
+  while (p) {                                                          \
+    *p = '_';                                                          \
+    dollar_inside++;                                                   \
+    p = strchr (p + 1, '$');                                           \
+  }                                                                    \
+  if (dollar_inside) {                                                 \
+      fputs ("\t.extern .", FILE);                                     \
+      RS6000_OUTPUT_BASENAME (FILE, buffer);                           \
+      putc ('\n', FILE);                                               \
+      fprintf(FILE, "\t.rename .%s,\".%s\"\n", buffer, NAME);          \
+    }                                                                  \
   if ((TREE_CODE (DECL) == VAR_DECL                                    \
        || TREE_CODE (DECL) == FUNCTION_DECL)                           \
       && (NAME)[strlen (NAME) - 1] != ']')                             \
     }                                                                  \
 }
 
+/* This is how to output a reference to a user-level label named NAME.
+   `assemble_name' uses this.  */
+
+#define ASM_OUTPUT_LABELREF(FILE,NAME) \
+  asm_fprintf ((FILE), "%U%s", rs6000_xcoff_strip_dollar (NAME));
+
 /* This is how to output an internal label prefix.  rs6000.c uses this
    when generating traceback tables.  */
 
index be6d2a2..2143192 100644 (file)
@@ -84,7 +84,7 @@ along with GCC; see the file COPYING3.  If not see
            fputs (_p+1, asm_out_file);                                 \
          else                                                          \
            for (; *_p != '[' && *_p; _p++)                             \
-             putc (*_p, asm_out_file);                                 \
+             putc (*_p != '$' ? *_p : '_', asm_out_file);              \
        }                                                               \
       else                                                             \
        output_addr_const (asm_out_file, ADDR);                         \