From 20804d96d131529e7f7f300458e02b7f1ed30d6c Mon Sep 17 00:00:00 2001
From: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date: Wed, 30 Jan 2013 09:26:21 +0000
Subject: [PATCH] Properly set progbits/nobits for Solaris/SPARC as

	* configure.ac (HAVE_AS_SPARC_NOBITS): New test.
	* configure: Regenerate.
	* config.in: Regenerate.
	* config/sparc/sparc.c (sparc_solaris_elf_asm_named_section): Emit
	#nobits/#progbits if supported.

From-SVN: r195572
---
 gcc/ChangeLog            |  8 ++++++++
 gcc/config.in            | 26 +++++++++++++-------------
 gcc/config/sparc/sparc.c |  9 ++++++++-
 gcc/configure            | 33 +++++++++++++++++++++++++++++++++
 gcc/configure.ac         |  7 +++++++
 5 files changed, 69 insertions(+), 14 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2dbe38241db7..b796e699d383 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2013-01-30  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
+
+	* configure.ac (HAVE_AS_SPARC_NOBITS): New test.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+	* config/sparc/sparc.c (sparc_solaris_elf_asm_named_section): Emit
+	#nobits/#progbits if supported.
+
 2013-01-29  Oleg Endo  <olegendo@gcc.gnu.org>
 
 	PR target/56121
diff --git a/gcc/config.in b/gcc/config.in
index 703890634019..d80fb9f6e113 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -199,12 +199,6 @@
 #endif
 
 
-/* Define if the zone collector is in use */
-#ifndef USED_FOR_TARGET
-#undef GGC_ZONE
-#endif
-
-
 /* mcontext_t fields start with __ */
 #ifndef USED_FOR_TARGET
 #undef HAS_MCONTEXT_T_UNDERSCORES
@@ -266,12 +260,6 @@
 #endif
 
 
-/* Define if your assembler supports SPARC4 instructions. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_AS_SPARC4
-#endif
-
-
 /* Define if your assembler supports fprnd. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_FPRND
@@ -477,12 +465,24 @@
 #endif
 
 
+/* Define if your assembler supports SPARC4 instructions. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_SPARC4
+#endif
+
+
 /* Define if your assembler and linker support GOTDATA_OP relocs. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_SPARC_GOTDATA_OP
 #endif
 
 
+/* Define to 1 if your assembler supports #nobits, 0 otherwise. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_SPARC_NOBITS
+#endif
+
+
 /* Define if your assembler and linker support unaligned PC relative relocs.
    */
 #ifndef USED_FOR_TARGET
@@ -1228,7 +1228,7 @@
 #endif
 
 
-/* Define if your PowerPC64 linker supports a large TOC. */
+/* Define if your AIX linker supports a large TOC. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_LD_LARGE_TOC
 #endif
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 3d7db6070943..08c2894fbbc0 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -9512,7 +9512,14 @@ sparc_solaris_elf_asm_named_section (const char *name, unsigned int flags,
   if (flags & SECTION_CODE)
     fputs (",#execinstr", asm_out_file);
 
-  /* ??? Handle SECTION_BSS.  */
+  /* Sun as only supports #nobits/#progbits since Solaris 10.  */
+  if (HAVE_AS_SPARC_NOBITS)
+    {
+      if (flags & SECTION_BSS)
+	fputs (",#nobits", asm_out_file);
+      else
+	fputs (",#progbits", asm_out_file);
+    }
 
   fputc ('\n', asm_out_file);
 }
diff --git a/gcc/configure b/gcc/configure
index 5730c9d45177..6711c0feb5f7 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -23927,6 +23927,39 @@ $as_echo "#define HAVE_AS_REGISTER_PSEUDO_OP 1" >>confdefs.h
 
 fi
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for #nobits" >&5
+$as_echo_n "checking assembler for #nobits... " >&6; }
+if test "${gcc_cv_as_sparc_nobits+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_sparc_nobits=no
+  if test x$gcc_cv_as != x; then
+    $as_echo '.section "nobits",#alloc,#write,#nobits
+       .section "progbits",#alloc,#write,#progbits' > conftest.s
+    if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+    then
+	gcc_cv_as_sparc_nobits=yes
+    else
+      echo "configure: failed program was" >&5
+      cat conftest.s >&5
+    fi
+    rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_sparc_nobits" >&5
+$as_echo "$gcc_cv_as_sparc_nobits" >&6; }
+
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_AS_SPARC_NOBITS `if test $gcc_cv_as_sparc_nobits = yes; then echo 1; else echo 0; fi`
+_ACEOF
+
+
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -relax option" >&5
 $as_echo_n "checking assembler for -relax option... " >&6; }
 if test "${gcc_cv_as_sparc_relax+set}" = set; then :
diff --git a/gcc/configure.ac b/gcc/configure.ac
index b471faef02f0..9ae560489059 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -3467,6 +3467,13 @@ case "$target" in
       [AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
 		[Define if your assembler supports .register.])])
 
+    gcc_GAS_CHECK_FEATURE([@%:@nobits], gcc_cv_as_sparc_nobits,,,
+      [.section "nobits",#alloc,#write,#nobits
+       .section "progbits",#alloc,#write,#progbits])
+    AC_DEFINE_UNQUOTED(HAVE_AS_SPARC_NOBITS,
+      [`if test $gcc_cv_as_sparc_nobits = yes; then echo 1; else echo 0; fi`],
+      [Define to 1 if your assembler supports #nobits, 0 otherwise.])
+
     gcc_GAS_CHECK_FEATURE([-relax option], gcc_cv_as_sparc_relax,,
       [-relax], [.text],,
       [AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,
-- 
GitLab