http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46916

--- Comment #55 from Iain Sandoe <iains at gcc dot gnu.org> 2010-12-15 12:36:00 
UTC ---
this solves 

FAIL: g++.dg/other/pr22003.C (test for excess errors)

but we have total failure with "-O3 -g" for gcc.
[all fails are warning: no debug symbols in executable (-arch xxxx)]
(looking into that next)

----- your patch + replacing the Darwin bits with this.

Index: gcc/config/darwin.c
===================================================================
--- gcc/config/darwin.c (revision 167849)
+++ gcc/config/darwin.c (working copy)
@@ -1145,19 +1145,6 @@ darwin_mark_decl_preserved (const char *name)
 }

 static section *
-darwin_text_section (int reloc, int weak)
-{
-  if (reloc)
-    return (weak
-           ? darwin_sections[text_unlikely_coal_section]
-           : unlikely_text_section ());
-  else
-    return (weak
-           ? darwin_sections[text_coal_section]
-           : text_section);
-}
-
-static section *
 darwin_rodata_section (int weak, bool zsize)
 {
   return (weak
@@ -1267,17 +1254,7 @@ machopic_select_section (tree decl,
   switch (categorize_decl_for_section (decl, reloc))
     {
     case SECCAT_TEXT:
-      {
-       struct cgraph_node *node;
-       if (decl && TREE_CODE (decl) == FUNCTION_DECL
-           && (node = cgraph_get_node (decl)) != NULL)
-         base_section = darwin_function_section (decl,
-                                                 node->frequency,
-                                                 node->only_called_at_startup,
-                                                 node->only_called_at_exit);
-       if (!base_section)
-          base_section = darwin_text_section (reloc, weak);
-      }
+      gcc_unreachable ();
       break;

     case SECCAT_RODATA:
@@ -2559,17 +2536,6 @@ darwin_override_options (void)
   if (!global_options_set.x_dwarf_strict) 
     dwarf_strict = 1;

-  /* Disable -freorder-blocks-and-partition for darwin_emit_unwind_label.  */
-  if (flag_reorder_blocks_and_partition 
-      && (targetm.asm_out.emit_unwind_label == darwin_emit_unwind_label))
-    {
-      inform (input_location,
-              "-freorder-blocks-and-partition does not work with exceptions "
-              "on this architecture");
-      flag_reorder_blocks_and_partition = 0;
-      flag_reorder_blocks = 1;
-    }
-
   if (flag_mkernel || flag_apple_kext)
     {
       /* -mkernel implies -fapple-kext for C++ */
@@ -2969,32 +2935,42 @@ darwin_function_section (tree decl, enum node_freq
                          bool startup, bool exit)
 {
   if (!flag_reorder_functions)
-    return NULL;
+    return (DECL_WEAK (decl))
+           ? darwin_sections[text_coal_section]
+           : text_section;
+
   /* Startup code should go to startup subsection unless it is
      unlikely executed (this happens especially with function splitting
      where we can split away unnecesary parts of static constructors.  */
   if (startup && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED)
-    return get_named_text_section
-            (decl, "__TEXT,__startup,regular,pure_instructions", "_startup");
+    return (DECL_WEAK (decl))
+           ? darwin_sections[text_startup_coal_section]
+           : darwin_sections[text_startup_section];

   /* Similarly for exit.  */
   if (exit && freq != NODE_FREQUENCY_UNLIKELY_EXECUTED)
-    return get_named_text_section (decl,
-                                  "__TEXT,__exit,regular,pure_instructions",
-                                  "_exit");
+    return (DECL_WEAK (decl))
+           ? darwin_sections[text_exit_coal_section]
+           : darwin_sections[text_exit_section];

   /* Group cold functions together, similarly for hot code.  */
   switch (freq)
     {
       case NODE_FREQUENCY_UNLIKELY_EXECUTED:
-       return get_named_text_section
-                (decl,
-                 "__TEXT,__unlikely,regular,pure_instructions", "_unlikely");
+       return (DECL_WEAK (decl))
+               ? darwin_sections[text_cold_coal_section]
+               : darwin_sections[text_cold_section];
+       break;
       case NODE_FREQUENCY_HOT:
-       return get_named_text_section
-                (decl, "__TEXT,__hot,regular,pure_instructions", "_hot");
+       return (DECL_WEAK (decl))
+               ? darwin_sections[text_hot_coal_section]
+               : darwin_sections[text_hot_section];
+       break;
       default:
-       return NULL;
+       return (DECL_WEAK (decl))
+               ? darwin_sections[text_coal_section]
+               : text_section;
+       break;
     }
 }

Index: gcc/config/darwin-sections.def
===================================================================
--- gcc/config/darwin-sections.def      (revision 167849)
+++ gcc/config/darwin-sections.def      (working copy)
@@ -34,6 +34,24 @@ DEF_SECTION (text_unlikely_coal_section, SECTION_C
             ".section __TEXT,__text_unlikely_coal,"
             "coalesced,pure_instructions", 0)

+DEF_SECTION (text_hot_section, SECTION_CODE,
+            ".section __TEXT,__text_hot,regular,pure_instructions", 0)
+DEF_SECTION (text_cold_section, SECTION_CODE,
+            ".section __TEXT,__text_cold,regular,pure_instructions", 0)
+DEF_SECTION (text_startup_section, SECTION_CODE,
+            ".section __TEXT,__text_startup,regular,pure_instructions", 0)
+DEF_SECTION (text_exit_section, SECTION_CODE,
+            ".section __TEXT,__text_exit,regular,pure_instructions", 0)
+
+DEF_SECTION (text_hot_coal_section, SECTION_CODE,
+            ".section __TEXT,__text_hot_coal,coalesced,pure_instructions", 0)
+DEF_SECTION (text_cold_coal_section, SECTION_CODE,
+            ".section __TEXT,__text_cold_coal,coalesced,pure_instructions", 0)
+DEF_SECTION (text_startup_coal_section, SECTION_CODE,
+            ".section __TEXT,__text_stt_coal,coalesced,pure_instructions", 0)
+DEF_SECTION (text_exit_coal_section, SECTION_CODE,
+            ".section __TEXT,__text_exit_coal,coalesced,pure_instructions", 0)
+
 /* const */
 DEF_SECTION (const_section, 0, ".const", 0)
 DEF_SECTION (const_coal_section, SECTION_NO_ANCHOR,
Index: gcc/config/darwin.h
===================================================================
--- gcc/config/darwin.h (revision 167849)
+++ gcc/config/darwin.h (working copy)
@@ -664,7 +664,7 @@ extern GTY(()) section * darwin_sections[NUM_DARWI

 #undef TARGET_ASM_SELECT_SECTION
 #define TARGET_ASM_SELECT_SECTION machopic_select_section
-#define USE_SELECT_SECTION_FOR_FUNCTIONS
+
 #undef TARGET_ASM_FUNCTION_SECTION
 #define TARGET_ASM_FUNCTION_SECTION darwin_function_section

Reply via email to