rs6000.h (ASM_OUTPUT_SYMBOL_REF): Define.
authorMark Mitchell <mark@codesourcery.com>
Tue, 6 Feb 2001 19:04:01 +0000 (19:04 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 6 Feb 2001 19:04:01 +0000 (19:04 +0000)
* config/rs6000/rs6000.h (ASM_OUTPUT_SYMBOL_REF): Define.
* config/rs6000/rs6000-protos.h (rs6000_output_symbol_ref): Declare.
* config/rs6000/rs6000.c (VTABLE_NAME_P): New macro.
(rs6000_output_symbol_ref): New function.
(output_toc): Use VTABLE_NAME_P.

From-SVN: r39497

gcc/ChangeLog
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/rs6000.h

index 1103350d1ae41ff584cd7f6abb30be9b13a64754..9a6c0b745ed23e07f9ad85f248cb2abd33239d13 100644 (file)
@@ -1,3 +1,11 @@
+2001-02-06  Mark Mitchell  <mark@codesourcery.com>
+
+       * config/rs6000/rs6000.h (ASM_OUTPUT_SYMBOL_REF): Define.
+       * config/rs6000/rs6000-protos.h (rs6000_output_symbol_ref): Declare.
+       * config/rs6000/rs6000.c (VTABLE_NAME_P): New macro.
+       (rs6000_output_symbol_ref): New function.
+       (output_toc): Use VTABLE_NAME_P.
+       
 Tue Feb  6 07:54:51 2001  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
        * print-tree.c (print_node, case PARM_DECL):
index 846321a36adc288e43fb58dae1c68b1d3c8bd8e8..31e5716bcf8448e11fed922eb3571d3f0789be24 100644 (file)
@@ -109,6 +109,7 @@ extern void rs6000_emit_move PARAMS ((rtx, rtx, enum machine_mode));
 extern rtx rs6000_legitimize_address PARAMS ((rtx, rtx, enum machine_mode));
 extern void rs6000_select_rtx_section PARAMS ((enum machine_mode, rtx));
 extern rtx rs6000_return_addr PARAMS ((int, rtx));
+extern void rs6000_output_symbol_ref PARAMS ((FILE*, rtx));
 #endif /* RTX_CODE */
 
 #ifdef TREE_CODE
index 9d8060bea2d4ea71e7b4d4a10471d030aba0a644..40c8bbd4cc54cb07425eb07760089287fe628811 100644 (file)
@@ -6735,6 +6735,38 @@ toc_hash_mark_table (vht)
   htab_traverse (*ht, toc_hash_mark_entry, (void *)0);
 }
 
+/* These are the names given by the C++ front-end to vtables, and
+   vtable-like objects.  Ideally, this logic should not be here;
+   instead, there should be some programmatic way of inquiring as
+   to whether or not an object is a vtable.  */
+
+#define VTABLE_NAME_P(NAME)                            \
+  (strncmp ("_vt.", name, strlen("_vt.")) == 0         \
+  || strncmp ("_ZTV", name, strlen ("_ZTV")) == 0      \
+  || strncmp ("_ZTT", name, strlen ("_ZTT")) == 0      \
+  || strncmp ("_ZTC", name, strlen ("_ZTC")) == 0) 
+
+void
+rs6000_output_symbol_ref (file, x)
+     FILE *file;
+     rtx x;
+{
+  /* Currently C++ toc references to vtables can be emitted before it
+     is decided whether the vtable is public or private.  If this is
+     the case, then the linker will eventually complain that there is
+     a reference to an unknown section.  Thus, for vtables only, 
+     we emit the TOC reference to reference the symbol and not the
+     section.  */
+  const char *name = XSTR (x, 0);
+
+  if (VTABLE_NAME_P (name)) 
+    {
+      RS6000_OUTPUT_BASENAME (file, name);
+    }
+  else
+    assemble_name (file, name);
+}
+
 /* Output a TOC entry.  We derive the entry name from what is
    being written.  */
 
@@ -6942,7 +6974,7 @@ output_toc (file, x, labelno, mode)
      a TOC reference to an unknown section.  Thus, for vtables only,
      we emit the TOC reference to reference the symbol and not the
      section.  */
-  if (strncmp ("_vt.", name, 4) == 0)
+  if (VTABLE_NAME_P (name))
     {
       RS6000_OUTPUT_BASENAME (file, name);
       if (offset < 0)
index fc70c506c3a644eb8bb4ac13724a482979d78238..bb59c473358f4480b0e74e157880e69abfaa5982 100644 (file)
@@ -2628,6 +2628,11 @@ do {                                                                     \
 ( (OUTPUT) = (char *) alloca (strlen ((NAME)) + 10),   \
   sprintf ((OUTPUT), "%s.%d", (NAME), (LABELNO)))
 
+/* Output a reference to SYM on FILE.  */
+
+#define ASM_OUTPUT_SYMBOL_REF(FILE, SYM) \
+  rs6000_output_symbol_ref (FILE, SYM)
+
 /* Define the parentheses used to group arithmetic operations
    in assembler code.  */