re PR target/25376 (section attribute doesn't work on darwin)
authorJosh Conner <jconner@apple.com>
Mon, 13 Feb 2006 18:12:17 +0000 (18:12 +0000)
committerJosh Conner <jconner@gcc.gnu.org>
Mon, 13 Feb 2006 18:12:17 +0000 (18:12 +0000)
PR target/25376
* varasm.c (function_section): Check for section name before
calling select_section on targets that define
USE_SELECT_SECTION_FOR_FUNCTIONS.  On other targets, use
unlikely_text_section instead of hot_function_section if
first_function_block_is_cold.
* gcc.dg/pr25376.c: New test.

* gcc.c-torture/compile/pr23237.c: Only compile test -- don't
assemble.
* lib/target-supports.exp (check_named_sections_available):
Only compile named-sections test -- don't assemble.

From-SVN: r110917

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr23237.c
gcc/testsuite/gcc.dg/pr25376.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp
gcc/varasm.c

index 30cea1587385d5f53d3d204c37cdf49fb861c6bf..2c8fe9527c91c5e69a92b98c5a5db6e02cad6cf8 100644 (file)
@@ -1,3 +1,12 @@
+2006-02-13  Josh Conner  <jconner@apple.com>
+
+       PR target/25376
+       * varasm.c (function_section): Check for section name before
+       calling select_section on targets that define
+       USE_SELECT_SECTION_FOR_FUNCTIONS.  On other targets, use
+       unlikely_text_section instead of hot_function_section if
+       first_function_block_is_cold.
+
 2006-02-13  J"orn Rennecke <joern.rennecke@st.com>
 
        PR middle-end/25335
index 686a2234ede4b56a5467c55430ac8daa9dc7ca96..3338042a72c87ecebf64c588c7ecba55683518ed 100644 (file)
@@ -1,3 +1,13 @@
+2006-02-13  Josh Conner  <jconner@apple.com>
+
+       PR target/25376
+       * gcc.dg/pr25376.c: New test.   
+
+       * gcc.c-torture/compile/pr23237.c: Only compile test -- don't
+       assemble.
+       * lib/target-supports.exp (check_named_sections_available):
+       Only compile named-sections test -- don't assemble.
+
 2006-02-12  Gabriel Dos Reis  <gdr@integrable-solutions.net>
 
        * g++.dg/warn/no-write-strings.C: New test.
index bbb3483a5572b26b1ac6b821be9a9392268da91c..955cdd060ff57d5118e6b0f3e6a4530f3d84a404 100644 (file)
@@ -1,5 +1,9 @@
 /* { dg-require-effective-target named_sections } */
 
+/* Don't assemble, as this section syntax may not be valid on all platforms
+   (e.g., Darwin).  */
+/* { dg-do compile } */
+
 static __attribute__ ((__section__ (".init.data"))) char *message;
 static __attribute__ ((__section__ (".init.data"))) int (*actions[])(void) = {};
 void unpack_to_rootfs(void)
diff --git a/gcc/testsuite/gcc.dg/pr25376.c b/gcc/testsuite/gcc.dg/pr25376.c
new file mode 100644 (file)
index 0000000..3008b09
--- /dev/null
@@ -0,0 +1,9 @@
+/* PR25376.  Verify that a named section is honored.  */
+/* { dg-require-named-sections "" } */
+
+void simple (void) __attribute__((section("my_named_section")));
+void simple (void)
+{
+}
+
+/* { dg-final { scan-assembler "my_named_section" } } */
index f9ca1a1652dc98172a99384f215380cf5d514a5c..88794a3cb98d3963d37678d1a1ed333dcd7b69ea 100644 (file)
@@ -637,7 +637,7 @@ proc check_iconv_available { test_what } {
 # the same test run.
 proc check_named_sections_available { } {
     verbose "check_named_sections_available: compiling source" 2
-    set answer [string match "" [get_compiler_messages named object {
+    set answer [string match "" [get_compiler_messages named assembly {
        int __attribute__ ((section("whatever"))) foo;
     }]]
     verbose "check_named_sections_available: returning $answer" 2
index 68bd026a2791f926b6d6dff6d8c608c1bd689b59..bddf1ad9853b96113328d535c226ef45b8c592b6 100644 (file)
@@ -440,9 +440,14 @@ function_section (tree decl)
     reloc = 1;
 
 #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
-  return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
+  if (decl != NULL_TREE
+      && DECL_SECTION_NAME (decl) != NULL_TREE)
+    return reloc ? unlikely_text_section ()
+                : get_named_section (decl, NULL, 0);
+  else
+    return targetm.asm_out.select_section (decl, reloc, DECL_ALIGN (decl));
 #else
-  return hot_function_section (decl);
+  return reloc ? unlikely_text_section () : hot_function_section (decl);
 #endif
 }
 
@@ -450,9 +455,15 @@ section *
 current_function_section (void)
 {
 #ifdef USE_SELECT_SECTION_FOR_FUNCTIONS
-  return targetm.asm_out.select_section (current_function_decl,
-                                        in_cold_section_p,
-                                        DECL_ALIGN (current_function_decl));
+  if (current_function_decl != NULL_TREE
+      && DECL_SECTION_NAME (current_function_decl) != NULL_TREE)
+    return in_cold_section_p ? unlikely_text_section ()
+                            : get_named_section (current_function_decl,
+                                                 NULL, 0);
+  else
+    return targetm.asm_out.select_section (current_function_decl,
+                                          in_cold_section_p,
+                                          DECL_ALIGN (current_function_decl));
 #else
   return (in_cold_section_p
          ? unlikely_text_section ()