> On Fri, Dec 23, 2005 at 11:33:20AM -0800, Janis Johnson wrote:
 > > > PS: I'm going to try applying the patch to 3.4 and see if it fixes
 > > > tinfo1.C.
 > > 
 > > Meanwhile I'm running a regression hunt for the fix on mainline,
 > > which is currently looking between 2005-07-29 and 2005-07-30.
 > > Perhaps that's not relevant if the real fix was applied later, but
 > > at least we'll know why the section definition went away.
 > 
 > The test started getting the third XPASS (for the .section definition
 > going away) on mainline with this large patch from Mark:
 > 
 >   http://gcc.gnu.org/viewcvs?view=rev&rev=85309
 > 
 >   r85309 | mmitchel | 2004-07-29 17:59:31 +0000 (Thu, 29 Jul 2004) |
 >   124 lines
 > 
 > Janis

Ug, thanks for figuring that out.  Mark's patch looks way to invasive
to consider backporting.  And it must have been the one to fix
rtti/tinfo1.C, since Jakub's patch for PR 16276 didn't have any effect
on tinfo1.C.

Although Jakub's patch passes regtest on i686-unknown-linux-gnu, he
must have been trying to fix a separate but perhaps related problem.

For reference, here's what I tested against current 3.4.x.  It may be
worthwhile installing it if we can figure out what it fixes apart from
tinfo1.C.  (I'm CC'ing gcc-patches now.)

                --Kaveh


2005-12-23  Kaveh R. Ghazi  <[EMAIL PROTECTED]>

        Backport:
        2004-08-12  Jakub Jelinek  <[EMAIL PROTECTED]>

        PR c++/16276
        * output.h (default_function_rodata_section,
        default_no_function_rodata_section): New prototypes.
        * target.h (struct gcc_target): Add asm_out.function_rodata_section.
        * target-def.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define.
        (TARGET_ASM_OUT): Add it.
        * varasm.c (default_function_rodata_section,
        default_no_function_rodata_section): New functions.
        * final.c (final_scan_insn): Call
        targetm.asm_out.function_rodata_section instead of
        readonly_data_section.
        * config/darwin.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Define.
        * config/mcore/mcore.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise.
        * config/ip2k/ip2k.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise.
        * config/rs6000/xcoff.h (TARGET_ASM_FUNCTION_RODATA_SECTION):
        Likewise.
        * config/alpha/alpha.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise.
        * config/i386/cygming.h (TARGET_ASM_FUNCTION_RODATA_SECTION):
        Likewise.
        * config/i386/i386-interix.h (TARGET_ASM_FUNCTION_RODATA_SECTION):
        Likewise.
        * config/arm/pe.h (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise.
        * config/avr/avr.c (TARGET_ASM_FUNCTION_RODATA_SECTION): Likewise.
        * doc/tm.texi (TARGET_ASM_FUNCTION_RODATA_SECTION): Document.

testsuite:
        Backport:
        2004-08-12  Jakub Jelinek  <[EMAIL PROTECTED]>
        * g++.old-deja/g++.other/comdat4.C: New test.
        * g++.old-deja/g++.other/comdat4-aux.cc: New.

diff -rup orig/egcc-3.4-SVN20051222/gcc/config/alpha/alpha.c 
egcc-3.4-SVN20051222/gcc/config/alpha/alpha.c
--- orig/egcc-3.4-SVN20051222/gcc/config/alpha/alpha.c  2005-11-03 
11:02:17.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/alpha/alpha.c       2005-12-23 
14:49:51.000000000 -0500
@@ -10196,6 +10196,8 @@ alpha_init_libfuncs (void)
 # define TARGET_SECTION_TYPE_FLAGS unicosmk_section_type_flags
 # undef TARGET_ASM_UNIQUE_SECTION
 # define TARGET_ASM_UNIQUE_SECTION unicosmk_unique_section
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 # undef TARGET_ASM_GLOBALIZE_LABEL
 # define TARGET_ASM_GLOBALIZE_LABEL hook_void_FILEptr_constcharptr
 #endif
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/arm/pe.h 
egcc-3.4-SVN20051222/gcc/config/arm/pe.h
--- orig/egcc-3.4-SVN20051222/gcc/config/arm/pe.h       2005-11-03 
11:02:27.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/arm/pe.h    2005-12-23 14:49:51.000000000 
-0500
@@ -97,6 +97,7 @@
 #define MULTIPLE_SYMBOL_SPACES
 
 #define TARGET_ASM_UNIQUE_SECTION arm_pe_unique_section
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 
 #define SUPPORTS_ONE_ONLY 1
 
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/avr/avr.c 
egcc-3.4-SVN20051222/gcc/config/avr/avr.c
--- orig/egcc-3.4-SVN20051222/gcc/config/avr/avr.c      2005-11-03 
11:02:28.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/avr/avr.c   2005-12-23 14:51:12.000000000 
-0500
@@ -229,6 +229,8 @@ int avr_case_values_threshold = 30000;
 #define TARGET_ASM_FUNCTION_EPILOGUE avr_output_function_epilogue
 #undef TARGET_ATTRIBUTE_TABLE
 #define TARGET_ATTRIBUTE_TABLE avr_attribute_table
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 #undef TARGET_INSERT_ATTRIBUTES
 #define TARGET_INSERT_ATTRIBUTES avr_insert_attributes
 #undef TARGET_SECTION_TYPE_FLAGS
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/darwin.h 
egcc-3.4-SVN20051222/gcc/config/darwin.h
--- orig/egcc-3.4-SVN20051222/gcc/config/darwin.h       2005-11-03 
11:02:32.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/darwin.h    2005-12-23 14:52:17.000000000 
-0500
@@ -685,6 +685,8 @@ objc_section_init (void)                    \
 #define TARGET_ASM_SELECT_SECTION machopic_select_section
 #undef TARGET_ASM_SELECT_RTX_SECTION
 #define TARGET_ASM_SELECT_RTX_SECTION machopic_select_rtx_section
+#undef  TARGET_ASM_FUNCTION_RODATA_SECTION
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 
 #define ASM_DECLARE_UNRESOLVED_REFERENCE(FILE,NAME)                    \
     do {                                                               \
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/i386/cygming.h 
egcc-3.4-SVN20051222/gcc/config/i386/cygming.h
--- orig/egcc-3.4-SVN20051222/gcc/config/i386/cygming.h 2005-11-03 
11:02:23.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/i386/cygming.h      2005-12-23 
14:49:51.000000000 -0500
@@ -255,6 +255,7 @@ do {                                                        
\
 
 extern void i386_pe_unique_section (TREE, int);
 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 
 #define SUPPORTS_ONE_ONLY 1
 
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/i386/i386-interix.h 
egcc-3.4-SVN20051222/gcc/config/i386/i386-interix.h
--- orig/egcc-3.4-SVN20051222/gcc/config/i386/i386-interix.h    2005-11-03 
11:02:23.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/i386/i386-interix.h 2005-12-23 
14:49:51.000000000 -0500
@@ -344,6 +344,7 @@ while (0)
 
 extern void i386_pe_unique_section (tree, int);
 #define TARGET_ASM_UNIQUE_SECTION i386_pe_unique_section
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 
 #define SUPPORTS_ONE_ONLY 1
 #endif /* 0 */
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/ip2k/ip2k.c 
egcc-3.4-SVN20051222/gcc/config/ip2k/ip2k.c
--- orig/egcc-3.4-SVN20051222/gcc/config/ip2k/ip2k.c    2005-11-03 
11:02:19.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/ip2k/ip2k.c 2005-12-23 14:49:51.000000000 
-0500
@@ -98,6 +98,9 @@ const struct attribute_spec ip2k_attribu
 #undef TARGET_ASM_UNIQUE_SECTION
 #define TARGET_ASM_UNIQUE_SECTION unique_section
 
+#undef TARGET_ASM_FUNCTION_RODATA_SECTION
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
+
 #undef TARGET_ATTRIBUTE_TABLE
 #define TARGET_ATTRIBUTE_TABLE ip2k_attribute_table
 
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/mcore/mcore.c 
egcc-3.4-SVN20051222/gcc/config/mcore/mcore.c
--- orig/egcc-3.4-SVN20051222/gcc/config/mcore/mcore.c  2005-11-03 
11:02:26.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/mcore/mcore.c       2005-12-23 
14:49:51.000000000 -0500
@@ -165,6 +165,8 @@ static bool       mcore_rtx_costs           (rtx,
 #define TARGET_ATTRIBUTE_TABLE                 mcore_attribute_table
 #undef  TARGET_ASM_UNIQUE_SECTION
 #define TARGET_ASM_UNIQUE_SECTION      mcore_unique_section
+#undef  TARGET_ASM_FUNCTION_RODATA_SECTION
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 #undef  TARGET_ENCODE_SECTION_INFO
 #define TARGET_ENCODE_SECTION_INFO     mcore_encode_section_info
 #undef  TARGET_STRIP_NAME_ENCODING
diff -rup orig/egcc-3.4-SVN20051222/gcc/config/rs6000/xcoff.h 
egcc-3.4-SVN20051222/gcc/config/rs6000/xcoff.h
--- orig/egcc-3.4-SVN20051222/gcc/config/rs6000/xcoff.h 2005-11-03 
11:02:26.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/config/rs6000/xcoff.h      2005-12-23 
14:49:51.000000000 -0500
@@ -172,6 +172,7 @@ toc_section (void)                                  \
 #define TARGET_ASM_SELECT_SECTION  rs6000_xcoff_select_section
 #define TARGET_ASM_SELECT_RTX_SECTION  rs6000_xcoff_select_rtx_section
 #define TARGET_ASM_UNIQUE_SECTION  rs6000_xcoff_unique_section
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_no_function_rodata_section
 #define TARGET_STRIP_NAME_ENCODING  rs6000_xcoff_strip_name_encoding
 #define TARGET_SECTION_TYPE_FLAGS  rs6000_xcoff_section_type_flags
 
diff -rup orig/egcc-3.4-SVN20051222/gcc/doc/tm.texi 
egcc-3.4-SVN20051222/gcc/doc/tm.texi
--- orig/egcc-3.4-SVN20051222/gcc/doc/tm.texi   2005-11-03 11:00:12.000000000 
-0500
+++ egcc-3.4-SVN20051222/gcc/doc/tm.texi        2005-12-23 14:49:51.000000000 
-0500
@@ -6003,6 +6003,15 @@ example, the function @code{foo} would b
 Whatever the actual target object format, this is often good enough.
 @end deftypefn
 
[EMAIL PROTECTED] {Target Hook} void TARGET_ASM_FUNCTION_RODATA_SECTION (tree 
@var{decl})
+Switches to a readonly data section associated with
[EMAIL PROTECTED] (@var{decl})}.
+The default version of this function switches to @code{.gnu.linkonce.r.name}
+section if function's section is @code{.gnu.linkonce.t.name}, to
[EMAIL PROTECTED] if function is in @code{.text.name} section
+and otherwise switches to the normal readonly data section.
[EMAIL PROTECTED] deftypefn
+
 @deftypefn {Target Hook} void TARGET_ASM_SELECT_RTX_SECTION (enum machine_mode 
@var{mode}, rtx @var{x}, unsigned HOST_WIDE_INT @var{align})
 Switches to the appropriate section for output of constant pool entry
 @var{x} in @var{mode}.  You can assume that @var{x} is some kind of
diff -rup orig/egcc-3.4-SVN20051222/gcc/final.c egcc-3.4-SVN20051222/gcc/final.c
--- orig/egcc-3.4-SVN20051222/gcc/final.c       2005-11-03 11:02:46.000000000 
-0500
+++ egcc-3.4-SVN20051222/gcc/final.c    2005-12-23 14:49:51.000000000 -0500
@@ -1881,7 +1881,7 @@ final_scan_insn (rtx insn, FILE *file, i
                {
                  int log_align;
 
-                 readonly_data_section ();
+                 targetm.asm_out.function_rodata_section 
(current_function_decl);
 
 #ifdef ADDR_VEC_ALIGN
                  log_align = ADDR_VEC_ALIGN (NEXT_INSN (insn));
diff -rup orig/egcc-3.4-SVN20051222/gcc/output.h 
egcc-3.4-SVN20051222/gcc/output.h
--- orig/egcc-3.4-SVN20051222/gcc/output.h      2005-11-03 11:02:46.000000000 
-0500
+++ egcc-3.4-SVN20051222/gcc/output.h   2005-12-23 14:49:51.000000000 -0500
@@ -500,6 +500,8 @@ extern void default_elf_select_section_1
                                          unsigned HOST_WIDE_INT, int);
 extern void default_unique_section (tree, int);
 extern void default_unique_section_1 (tree, int, int);
+extern void default_function_rodata_section (tree);
+extern void default_no_function_rodata_section (tree);
 extern void default_select_rtx_section (enum machine_mode, rtx,
                                        unsigned HOST_WIDE_INT);
 extern void default_elf_select_rtx_section (enum machine_mode, rtx,
diff -rup orig/egcc-3.4-SVN20051222/gcc/target-def.h 
egcc-3.4-SVN20051222/gcc/target-def.h
--- orig/egcc-3.4-SVN20051222/gcc/target-def.h  2005-11-03 11:02:46.000000000 
-0500
+++ egcc-3.4-SVN20051222/gcc/target-def.h       2005-12-23 14:49:51.000000000 
-0500
@@ -78,6 +78,10 @@ Foundation, 59 Temple Place - Suite 330,
 #define TARGET_ASM_UNIQUE_SECTION default_unique_section
 #endif
 
+#ifndef TARGET_ASM_FUNCTION_RODATA_SECTION
+#define TARGET_ASM_FUNCTION_RODATA_SECTION default_function_rodata_section
+#endif
+
 #ifndef TARGET_ASM_SELECT_RTX_SECTION
 #define TARGET_ASM_SELECT_RTX_SECTION default_select_rtx_section
 #endif
@@ -201,6 +205,7 @@ Foundation, 59 Temple Place - Suite 330,
                        TARGET_ASM_SELECT_SECTION,              \
                        TARGET_ASM_SELECT_RTX_SECTION,          \
                        TARGET_ASM_UNIQUE_SECTION,              \
+                       TARGET_ASM_FUNCTION_RODATA_SECTION,     \
                        TARGET_ASM_CONSTRUCTOR,                 \
                        TARGET_ASM_DESTRUCTOR,                  \
                         TARGET_ASM_OUTPUT_MI_THUNK,             \
diff -rup orig/egcc-3.4-SVN20051222/gcc/target.h 
egcc-3.4-SVN20051222/gcc/target.h
--- orig/egcc-3.4-SVN20051222/gcc/target.h      2005-11-03 11:02:46.000000000 
-0500
+++ egcc-3.4-SVN20051222/gcc/target.h   2005-12-23 14:49:51.000000000 -0500
@@ -118,6 +118,10 @@ struct gcc_target
        for SELECT_SECTION.  */
     void (* unique_section) (tree, int);
 
+    /* Tell assembler to switch to the readonly data section associated
+       with function DECL.  */
+    void (* function_rodata_section) (tree); 
+
     /* Output a constructor for a symbol with a given priority.  */
     void (* constructor) (rtx, int);
 
diff -rup 
orig/egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc 
egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc
--- 
orig/egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc   
    2005-12-23 14:53:23.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4-aux.cc    
2005-12-23 14:49:51.000000000 -0500
@@ -0,0 +1,40 @@
+extern void
+bar (int x);
+
+inline void
+foo (int i)
+{
+  switch (i)
+    {
+    case 3:
+    case 5:
+    case 6:
+    case 9:
+    case 15:
+      bar (1);
+      break;
+    case 2:
+    case 4:
+    case 7:
+    case 10:
+    case 11:
+    case 12:
+      bar (2);
+      break;
+    case 0:
+    case 1:
+    case 8:
+    case 13:
+    case 16:
+      bar (3);
+      break;
+    case 14:
+      bar (4);
+      break;
+    default:
+      bar (5);
+      break;
+    }
+}
+
+void *fooaddr2 = (void *) foo;
diff -rup 
orig/egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4.C 
egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4.C
--- orig/egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4.C    
2005-12-23 14:53:32.000000000 -0500
+++ egcc-3.4-SVN20051222/gcc/testsuite/g++.old-deja/g++.other/comdat4.C 
2005-12-23 14:49:51.000000000 -0500
@@ -0,0 +1,57 @@
+// PR c++/16276
+// { dg-do link }
+// { dg-additional-sources " comdat4-aux.cc" }
+// { dg-options "-O2" }
+
+extern void
+bar (int x);
+
+inline void
+foo (int i)
+{
+  switch (i)
+    {
+    case 3:
+    case 5:
+    case 6:
+    case 9:
+    case 15:
+      bar (1);
+      break;
+    case 2:
+    case 4:
+    case 7:
+    case 10:
+    case 11:
+    case 12:
+      bar (2);
+      break;
+    case 0:
+    case 1:
+    case 8:
+    case 13:
+    case 16:
+      bar (3);
+      break;
+    case 14:
+      bar (4);
+      break;
+    default:
+      bar (5);
+      break;
+    }
+}
+
+void *fooaddr = (void *) foo;
+
+void
+bar (int x)
+{
+  __asm __volatile ("" : : "r" (x));
+}
+
+int
+main (void)
+{
+  return 0;
+}
diff -rup orig/egcc-3.4-SVN20051222/gcc/varasm.c 
egcc-3.4-SVN20051222/gcc/varasm.c
--- orig/egcc-3.4-SVN20051222/gcc/varasm.c      2005-11-03 11:02:46.000000000 
-0500
+++ egcc-3.4-SVN20051222/gcc/varasm.c   2005-12-23 14:49:51.000000000 -0500
@@ -535,6 +535,53 @@ function_section (tree decl)
     text_section ();
 }
 
+/* Switch to read-only data section associated with function DECL.  */
+
+void
+default_function_rodata_section (tree decl)
+{
+  if (decl != NULL_TREE && DECL_SECTION_NAME (decl))
+    {
+      const char *name = TREE_STRING_POINTER (DECL_SECTION_NAME (decl));
+
+      /* For .gnu.linkonce.t.foo we want to use .gnu.linkonce.r.foo.  */
+      if (DECL_ONE_ONLY (decl) && strncmp (name, ".gnu.linkonce.t.", 16) == 0)
+       {
+         size_t len = strlen (name) + 1;
+         char *rname = alloca (len);
+
+         memcpy (rname, name, len);
+         rname[14] = 'r';
+         named_section_flags (rname, SECTION_LINKONCE);
+         return;
+       }
+      /* For .text.foo we want to use .rodata.foo.  */
+      else if (flag_function_sections && flag_data_sections
+              && strncmp (name, ".text.", 6) == 0)
+       {
+         size_t len = strlen (name) + 1;
+         char *rname = alloca (len + 2);
+
+         memcpy (rname, ".rodata", 7);
+         memcpy (rname + 7, name + 5, len - 5);
+         named_section_flags (rname, 0);
+         return;
+       }
+    }
+
+  readonly_data_section ();
+}
+
+/* Switch to read-only data section associated with function DECL
+   for targets where that section should be always the single
+   readonly data section.  */
+
+void
+default_no_function_rodata_section (tree decl ATTRIBUTE_UNUSED)
+{
+  readonly_data_section ();
+}
+
 /* Switch to section for variable DECL.  RELOC is the same as the
    argument to SELECT_SECTION.  */
 

Reply via email to