]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/14607 (Duplicate symbol "vtable for node" in files div.o and env.o)
authorJohn David Anglin <dave.anglin@nrc-cnrc.gc.ca>
Tue, 20 Jul 2004 19:52:11 +0000 (19:52 +0000)
committerJohn David Anglin <danglin@gcc.gnu.org>
Tue, 20 Jul 2004 19:52:11 +0000 (19:52 +0000)
PR c++/14607
* config/pa/pa-hpux10.h (SUPPORTS_ONE_ONLY): Define.
(MAKE_DECL_ONE_ONLY): Undefine.
* pa-protos.h (som_text_section_asm_op, one_only_readonly_data_section,
readonly_data, one_only_data_section, forget_section): New prototypes.
* pa.c (pa_init_machine_status, som_text_section_asm_op): New
functions.
(pa_select_section): Add one-only (COMDAT) support.
* pa.h (struct machine_function): Define.
* som.h (ASM_OUTPUT_FUNCTION_PREFIX): Delete.
(TEXT_SECTION_ASM_OP): Call som_text_section_asm_op.
(DEFAULT_TEXT_SECTION_ASM_OP, NEW_TEXT_SECTION_ASM_OP,
ONE_ONLY_TEXT_SECTION_ASM_OP, ONE_ONLY_READONLY_DATA_SECTION_ASM_OP,
ONE_ONLY_DATA_SECTION_ASM_OP): New defines.
(EXTRA_SECTIONS): Add in_one_only_readonly_data and in_one_only_data.
(EXTRA_SECTION_FUNCTIONS): Rework to use individual function macros.
(READONLY_DATA_FUNCTION, ONE_ONLY_READONLY_DATA_SECTION_FUNCTION,
ONE_ONLY_DATA_SECTION_FUNCTION, FORGET_SECTION_FUNCTION): New defines
for EXTRA_SECTION_FUNCTIONS.
* doc/install.texi: Update binutils requirements.

From-SVN: r84970

gcc/ChangeLog
gcc/config/pa/pa-hpux10.h
gcc/config/pa/pa-protos.h
gcc/config/pa/pa.c
gcc/config/pa/pa.h
gcc/config/pa/som.h
gcc/doc/install.texi

index c1c7e01c0b6063030c46a67b2ca68c39baf6ea40..20048bdcb43280d5c8fb8901c3dd7be4336dd232 100644 (file)
@@ -1,3 +1,26 @@
+2004-07-20  John David Anglin  <dava.anglin@nrc-cnrc.gc.ca>
+
+       PR c++/14607
+       * config/pa/pa-hpux10.h (SUPPORTS_ONE_ONLY): Define.
+       (MAKE_DECL_ONE_ONLY): Undefine.
+       * pa-protos.h (som_text_section_asm_op, one_only_readonly_data_section,
+       readonly_data, one_only_data_section, forget_section): New prototypes.
+       * pa.c (pa_init_machine_status, som_text_section_asm_op): New
+       functions.
+       (pa_select_section): Add one-only (COMDAT) support.
+       * pa.h (struct machine_function): Define.
+       * som.h (ASM_OUTPUT_FUNCTION_PREFIX): Delete.
+       (TEXT_SECTION_ASM_OP): Call som_text_section_asm_op.
+       (DEFAULT_TEXT_SECTION_ASM_OP, NEW_TEXT_SECTION_ASM_OP,
+       ONE_ONLY_TEXT_SECTION_ASM_OP, ONE_ONLY_READONLY_DATA_SECTION_ASM_OP,
+       ONE_ONLY_DATA_SECTION_ASM_OP): New defines.
+       (EXTRA_SECTIONS): Add in_one_only_readonly_data and in_one_only_data.
+       (EXTRA_SECTION_FUNCTIONS): Rework to use individual function macros.
+       (READONLY_DATA_FUNCTION, ONE_ONLY_READONLY_DATA_SECTION_FUNCTION,
+       ONE_ONLY_DATA_SECTION_FUNCTION, FORGET_SECTION_FUNCTION): New defines
+       for EXTRA_SECTION_FUNCTIONS.
+       * doc/install.texi: Update binutils requirements.
+
 2004-07-20  Nathan Sidwell  <nathan@codesourcery.com>
 
        * dbxout.c (dbxout_type): Fix printf format.
index d3b5d858474fb3e7ffe7aa5a43b9766d09cab74e..6c4dbf596d51db46a1825f8d289d5c1711d64086 100644 (file)
@@ -136,3 +136,10 @@ Boston, MA 02111-1307, USA.  */
    better than the assembler shipped with older versions of hpux.  */
 #undef NEW_HP_ASSEMBLER
 #define NEW_HP_ASSEMBLER 1
+
+/* CVS GAS as of 4/28/04 supports a comdat parameter for the .nsubspa
+   directive.  This provides one only linkage semantics even though we
+   don't have weak support.  */
+#undef SUPPORTS_ONE_ONLY
+#define SUPPORTS_ONE_ONLY (TARGET_GAS)
+#undef MAKE_DECL_ONE_ONLY
index 0e0dc74d5b4ab69933926b85456c97ce6da172b6..7c9350ce0007e0a320c5e45b6bd524721db8ab3f 100644 (file)
@@ -135,6 +135,7 @@ extern int zdepi_cint_p (unsigned HOST_WIDE_INT);
 
 extern void override_options (void);
 extern void output_ascii (FILE *, const char *, int);
+extern const char * som_text_section_asm_op (void);
 extern HOST_WIDE_INT compute_frame_size (HOST_WIDE_INT, int *);
 extern int and_mask_p (unsigned HOST_WIDE_INT);
 extern int cint_ok_for_move (HOST_WIDE_INT);
@@ -151,7 +152,6 @@ extern int cmpib_comparison_operator (rtx, enum machine_mode);
 #endif
 
 
-
 #ifdef TREE_CODE
 extern int reloc_needed (tree);
 #ifdef RTX_CODE
@@ -164,3 +164,9 @@ extern int function_arg_partial_nregs (CUMULATIVE_ARGS *,
                                       tree, int);
 extern bool pa_return_in_memory (tree, tree);
 #endif /* TREE_CODE */
+
+/* Functions in varasm.c used by pa.c.  */
+extern void readonly_data (void);
+extern void one_only_readonly_data_section (void);
+extern void one_only_data_section (void);
+extern void forget_section (void);
index bd8b0a40c8c9b4e9ac895c4648d9885ba899c75a..20c0b8305de5895d3fd46b5a60a2d631c105e03a 100644 (file)
@@ -143,6 +143,7 @@ static void pa_hpux_init_libfuncs (void);
 static rtx pa_struct_value_rtx (tree, int);
 static bool pa_pass_by_reference (CUMULATIVE_ARGS *ca, enum machine_mode,
                                  tree, bool);
+static struct machine_function * pa_init_machine_status (void);
 
 
 /* Save the operands last given to a compare for use when we
@@ -464,6 +465,8 @@ override_options (void)
       targetm.asm_out.unaligned_op.si = NULL;
       targetm.asm_out.unaligned_op.di = NULL;
     }
+
+  init_machine_status = pa_init_machine_status;
 }
 
 static void
@@ -475,6 +478,16 @@ pa_init_builtins (void)
 #endif
 }
 
+/* Function to init struct machine_function.
+   This will be called, via a pointer variable,
+   from push_function_context.  */
+
+static struct machine_function *
+pa_init_machine_status (void)
+{
+  return ggc_alloc_cleared (sizeof (machine_function));
+}
+
 /* If FROM is a probable pointer register, mark TO as a probable
    pointer register with the same pointer alignment as FROM.  */
 
@@ -4210,6 +4223,14 @@ pa_output_function_epilogue (FILE *file, HOST_WIDE_INT size ATTRIBUTE_UNUSED)
 
   fputs ("\t.EXIT\n\t.PROCEND\n", file);
 
+  if (TARGET_SOM && TARGET_GAS)
+    {
+      /* We done with this subspace except possibly for some additional
+        debug information.  Forget that we are in this subspace to ensure
+        that the next function is output in its own subspace.  */
+      forget_section ();
+    }
+
   if (INSN_ADDRESSES_SET_P ())
     {
       insn = get_last_nonnote_insn ();
@@ -7995,8 +8016,9 @@ pa_asm_output_mi_thunk (FILE *file, tree thunk_fndecl, HOST_WIDE_INT delta,
       fprintf (file, "\t.align 4\n");
       ASM_OUTPUT_LABEL (file, label);
       fprintf (file, "\t.word P'%s\n", fname);
-      function_section (thunk_fndecl);
     }
+  else if (TARGET_SOM && TARGET_GAS)
+    forget_section ();
 
   current_thunk_number++;
   nbytes = ((nbytes + FUNCTION_BOUNDARY / BITS_PER_UNIT - 1)
@@ -9144,6 +9166,58 @@ cmpib_comparison_operator (rtx op, enum machine_mode mode)
              || GET_CODE (op) == LEU));
 }
 
+#ifndef ONE_ONLY_TEXT_SECTION_ASM_OP
+#define ONE_ONLY_TEXT_SECTION_ASM_OP ""
+#endif
+
+#ifndef NEW_TEXT_SECTION_ASM_OP
+#define NEW_TEXT_SECTION_ASM_OP ""
+#endif
+
+#ifndef DEFAULT_TEXT_SECTION_ASM_OP
+#define DEFAULT_TEXT_SECTION_ASM_OP ""
+#endif
+
+/* Select and return a TEXT_SECTION_ASM_OP for the current function.
+
+   This function is only used with SOM.  Because we don't support
+   named subspaces, we can only create a new subspace or switch back
+   into the default text subspace.  */
+const char *
+som_text_section_asm_op (void)
+{
+  if (TARGET_SOM && TARGET_GAS)
+    {
+      if (cfun && !cfun->machine->in_nsubspa)
+       {
+         /* We only want to emit a .nsubspa directive once at the
+            start of the function.  */
+         cfun->machine->in_nsubspa = 1;
+
+         /* Create a new subspace for the text.  This provides
+            better stub placement and one-only functions.  */
+         if (cfun->decl
+             && DECL_ONE_ONLY (cfun->decl)
+             && !DECL_WEAK (cfun->decl))
+           return ONE_ONLY_TEXT_SECTION_ASM_OP;
+
+         return NEW_TEXT_SECTION_ASM_OP;
+       }
+      else
+       {
+         /* There isn't a current function or the body of the current
+            function has been completed.  So, we are changing to the
+            text section to output debugging information.  Do this in
+            the default text section.  We need to forget that we are
+            in the text section so that text_section will call us the
+            next time around.  */
+         forget_section ();
+       }
+    }
+
+  return DEFAULT_TEXT_SECTION_ASM_OP;
+}
+
 /* On hpux10, the linker will give an error if we have a reference
    in the read-only data section to a symbol defined in a shared
    library.  Therefore, expressions that might require a reloc can
@@ -9160,10 +9234,23 @@ pa_select_section (tree exp, int reloc,
       && (DECL_INITIAL (exp) == error_mark_node
           || TREE_CONSTANT (DECL_INITIAL (exp)))
       && !reloc)
-    readonly_data_section ();
+    {
+      if (TARGET_SOM
+         && DECL_ONE_ONLY (exp)
+         && !DECL_WEAK (exp))
+       one_only_readonly_data_section ();
+      else
+       readonly_data_section ();
+    }
   else if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'c'
           && !reloc)
     readonly_data_section ();
+  else if (TARGET_SOM
+          && TREE_CODE (exp) == VAR_DECL
+          && DECL_ONE_ONLY (exp)
+          && !DECL_WEAK (exp)
+          && DECL_INITIAL (exp))
+    one_only_data_section ();
   else
     data_section ();
 }
index 9e259f308b9fe4c1346e9d224e821f8e221ce60d..80f70ded50096013cf7d809e83a36173bbbf8e2d 100644 (file)
@@ -430,6 +430,12 @@ do {                                                               \
 #define CAN_DEBUG_WITHOUT_FP
 \f
 /* target machine storage layout */
+typedef struct machine_function GTY(())
+{
+  /* Flag indicating that a .NSUBSPA directive has been output for
+     this function.  */
+  int in_nsubspa;
+} machine_function;
 
 /* Define this macro if it is advisable to hold scalars in registers
    in a wider mode than that declared by the program.  In such cases, 
index ae52cd0a30e26d5c95c41e3e1794720fc25dd487..d8082d82b9eb83e7b46d73853f65043fb5532220 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions for SOM assembler support.
-   Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -129,19 +129,6 @@ do {                                                               \
 #endif
 
 \f
-/* NAME refers to the function's name.  If we are placing each function into
-   its own section, we need to switch to the section for this function.  Note
-   that the section name will have a "." prefix.  */
-#define ASM_OUTPUT_FUNCTION_PREFIX(FILE, NAME) \
-  {                                                                    \
-    const char *name = (*targetm.strip_name_encoding) (NAME);          \
-    if (TARGET_GAS && in_section == in_text)                           \
-      fputs ("\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,CODE_ONLY\n", FILE); \
-    else if (TARGET_GAS)                                               \
-      fprintf (FILE,                                                   \
-              "\t.SUBSPA .%s\n", name);                                \
-  }
-    
 #define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \
     do { tree fntype = TREE_TYPE (TREE_TYPE (DECL));                   \
         tree tree_type = TREE_TYPE (DECL);                             \
@@ -219,30 +206,84 @@ do {                                                              \
 
 #define TARGET_ASM_FILE_START pa_som_file_start
 
-/* Output before code.  */
+/* Select and return a TEXT_SECTION_ASM_OP string.  */
+#define TEXT_SECTION_ASM_OP som_text_section_asm_op ()
 
-/* Supposedly the assembler rejects the command if there is no tab!  */
-#define TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$\n"
+/* Output before code in the default text section.  */
+#define DEFAULT_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $CODE$"
 
-/* Output before read-only data.  */
+/* Output before text in a new subspace.  This allows the linker to
+   place stubs between functions.  */
+#define NEW_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\t.NSUBSPA $CODE$"
+    
+/* Output before text in a new one-only subspace.  */
+#define ONE_ONLY_TEXT_SECTION_ASM_OP "\t.SPACE $TEXT$\n\
+\t.NSUBSPA $CODE$,QUAD=0,ALIGN=8,ACCESS=44,SORT=24,COMDAT"
 
-/* Supposedly the assembler rejects the command if there is no tab!  */
+/* Output before read-only data.  */
 #define READONLY_DATA_ASM_OP "\t.SPACE $TEXT$\n\t.SUBSPA $LIT$\n"
 
-#define EXTRA_SECTIONS in_readonly_data
+/* Output before one-only readonly data.  We make readonly data one only
+   by creating a new $LIT$ subspace in $TEXT$ with the comdat flag.  */
+#define ONE_ONLY_READONLY_DATA_SECTION_ASM_OP "\t.SPACE $TEXT$\n\
+\t.NSUBSPA $LIT$,QUAD=0,ALIGN=8,ACCESS=0x2c,SORT=16,COMDAT\n"
+
+/* Output before writable data.  */
+#define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
+
+/* Output before one-only data.  We make data one only by creating
+   a new $DATA$ subspace in $PRIVATE$ with the comdat flag.  */
+#define ONE_ONLY_DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\
+\t.NSUBSPA $DATA$,QUAD=1,ALIGN=8,ACCESS=31,SORT=24,COMDAT\n"
+
+/* Output before uninitialized data.  */
+#define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
+
+#define EXTRA_SECTIONS                                                 \
+  in_readonly_data,                                                    \
+  in_one_only_readonly_data,                                           \
+  in_one_only_data
 
 #define EXTRA_SECTION_FUNCTIONS                                                \
-extern void readonly_data (void);                                      \
+  READONLY_DATA_FUNCTION                                               \
+  ONE_ONLY_READONLY_DATA_SECTION_FUNCTION                              \
+  ONE_ONLY_DATA_SECTION_FUNCTION                                       \
+  FORGET_SECTION_FUNCTION
+
+#define READONLY_DATA_FUNCTION                                         \
 void                                                                   \
 readonly_data (void)                                                   \
 {                                                                      \
   if (in_section != in_readonly_data)                                  \
     {                                                                  \
       in_section = in_readonly_data;                                   \
-      fprintf (asm_out_file, "%s\n", READONLY_DATA_ASM_OP);            \
+      fputs (READONLY_DATA_ASM_OP, asm_out_file);                      \
     }                                                                  \
+}                                                                      \
+
+#define ONE_ONLY_READONLY_DATA_SECTION_FUNCTION                                \
+void                                                                   \
+one_only_readonly_data_section (void)                                  \
+{                                                                      \
+  in_section = in_one_only_readonly_data;                              \
+  fputs (ONE_ONLY_READONLY_DATA_SECTION_ASM_OP, asm_out_file);         \
+}                                                                      \
+
+#define ONE_ONLY_DATA_SECTION_FUNCTION                                 \
+void                                                                   \
+one_only_data_section (void)                                           \
+{                                                                      \
+  in_section = in_one_only_data;                                       \
+  fputs (ONE_ONLY_DATA_SECTION_ASM_OP, asm_out_file);                  \
 }
 
+#define FORGET_SECTION_FUNCTION                                                \
+void                                                                   \
+forget_section (void)                                                  \
+{                                                                      \
+  in_section = no_section;                                             \
+}                                                                      \
+
 /* FIXME: HPUX ld generates incorrect GOT entries for "T" fixups
    which reference data within the $TEXT$ space (for example constant
    strings in the $LIT$ subspace).
@@ -255,18 +296,8 @@ readonly_data (void)                                                       \
    $TEXT$ space during PIC generation.  Instead place all constant
    data into the $PRIVATE$ subspace (this reduces sharing, but it
    works correctly).  */
-
 #define READONLY_DATA_SECTION (flag_pic ? data_section : readonly_data)
 
-/* Output before writable data.  */
-
-/* Supposedly the assembler rejects the command if there is no tab!  */
-#define DATA_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $DATA$\n"
-
-/* Output before uninitialized data.  */
-
-#define BSS_SECTION_ASM_OP "\t.SPACE $PRIVATE$\n\t.SUBSPA $BSS$\n"
-
 /* We must not have a reference to an external symbol defined in a
    shared library in a readonly section, else the SOM linker will
    complain.
index a3a73bbcd1035e6dec480258bcdf6774afbd8a75..0af4aa73e0fda6f82d28c8c378e9523093f238eb 100644 (file)
@@ -2607,9 +2607,8 @@ longer a multiple of 2 bytes.
 @heading @anchor{hppa*-hp-hpux*}hppa*-hp-hpux*
 Support for HP-UX version 9 and older was discontinued in GCC 3.4.
 
-We @emph{highly} recommend using gas/binutils 2.8 or newer on all hppa
-platforms; you may encounter a variety of problems when using the HP
-assembler.
+We @emph{highly} recommend using gas/binutils on all hppa platforms;
+you may encounter a variety of problems when using the HP assembler.
 
 Specifically, @option{-g} does not work on HP-UX (since that system
 uses a peculiar debugging format which GCC does not know about), unless you
@@ -2664,6 +2663,13 @@ the 3-stage comparison test to fail during a @samp{make bootstrap}.
 You should be able to continue by saying @samp{make all} after getting
 the failure from @samp{make bootstrap}.
 
+GCC 3.5 requires CVS binutils as of April 28, 2004 or later.  Earlier
+versions require binutils 2.8 or later.
+
+The C++ ABI has changed incompatibly in GCC 3.5.  COMDAT subspaces are
+used for one-only code and data.  This resolves many of the previous
+problems in using C++ on this target.  However, the ABI is not compatible
+with the one implemented under HP-UX 11 using secondary definitions.
 
 @html
 <hr />
@@ -2732,8 +2738,8 @@ result, it's not possible to switch linkers in the middle of a GCC build.
 This has been been reported to sometimes occur in unified builds of
 binutils and GCC.
 
-With GCC 3.0 through 3.2, you must use binutils 2.11 or above.  As of
-GCC 3.3, binutils 2.14 or later is required.
+GCC 3.0 through 3.2 require binutils 2.11 or above.  GCC 3.3 through
+GCC 3.5 require binutils 2.14 or later.
 
 Although the HP assembler can be used for an initial build, it shouldn't
 be used with any languages other than C and perhaps Fortran due to its
This page took 0.084851 seconds and 5 git commands to generate.