Here's the actual patch:

2026-03-14  Rainer Orth  <[email protected]>

        gcc:
        * config/i386/i386.cc (ix86_in_large_data_p): Check for .lbss etc.
        (x86_64_elf_section_type_flags): Clear SECTION_NOTYPE for .lbss etc.
        * config/i386/x86-64.h (MACH_DEP_SECTION_ASM_FLAG): Define.
        * config/i386/sol2.h [HAVE_SOLARIS_AS]
        (MACH_DEP_SECTION_ASM_FLAG): Redefine as 'h'.

        gcc/testsuite:
        * gcc.target/i386/pr61599-1.c (dg-options): Add -save-temps.
        (scan-assembler-times): Check for @nobits.

# HG changeset patch
# Parent  053fda77a2eb89764ed6335e432377a1bfa26ece
i386: Fix gcc.target/i386/pr61599-1.c on Solaris/x86

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -744,7 +744,10 @@ ix86_in_large_data_p (tree exp)
     {
       const char *section = DECL_SECTION_NAME (exp);
       if (strcmp (section, ".ldata") == 0
-	  || strcmp (section, ".lbss") == 0)
+	  || startswith (section, ".ldata.")
+	  || strcmp (section, ".lbss") == 0
+	  || startswith (section, ".lbss.")
+	  || startswith (section, ".gnu.linkonce.lb."))
 	return true;
       return false;
     }
@@ -852,7 +855,12 @@ x86_64_elf_section_type_flags (tree decl
   if (strcmp (name, ".lbss") == 0
       || startswith (name, ".lbss.")
       || startswith (name, ".gnu.linkonce.lb."))
-    flags |= SECTION_BSS;
+    {
+      flags |= SECTION_BSS;
+      /* Clear SECTION_NOTYPE so .lbss etc. are marked @nobits in
+	 default_elf_asm_named_section.  */
+      flags &= ~SECTION_NOTYPE;
+    }
 
   return flags;
 }
diff --git a/gcc/config/i386/sol2.h b/gcc/config/i386/sol2.h
--- a/gcc/config/i386/sol2.h
+++ b/gcc/config/i386/sol2.h
@@ -202,12 +202,10 @@ along with GCC; see the file COPYING3.  
 #undef TARGET_ASM_NAMED_SECTION
 #define TARGET_ASM_NAMED_SECTION i386_solaris_elf_named_section
 
-/* Sun as requires "h" flag for large sections, GNU as can do without, but
-   accepts "l".  */
+/* Sun as requires the "h" flag for large sections.  */
 #if HAVE_SOLARIS_AS
+#undef MACH_DEP_SECTION_ASM_FLAG
 #define MACH_DEP_SECTION_ASM_FLAG 'h'
-#else
-#define MACH_DEP_SECTION_ASM_FLAG 'l'
 #endif
 
 #if HAVE_SOLARIS_AS
diff --git a/gcc/config/i386/x86-64.h b/gcc/config/i386/x86-64.h
--- a/gcc/config/i386/x86-64.h
+++ b/gcc/config/i386/x86-64.h
@@ -89,3 +89,6 @@ see the files COPYING3 and COPYING.RUNTI
 
 #undef TARGET_SECTION_TYPE_FLAGS
 #define TARGET_SECTION_TYPE_FLAGS  x86_64_elf_section_type_flags
+
+/* GNU as can identify large sections by name, but accepts "l".  */
+#define MACH_DEP_SECTION_ASM_FLAG 'l'
diff --git a/gcc/testsuite/gcc.target/i386/pr61599-1.c b/gcc/testsuite/gcc.target/i386/pr61599-1.c
--- a/gcc/testsuite/gcc.target/i386/pr61599-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr61599-1.c
@@ -2,7 +2,7 @@
 /* { dg-do run { target lp64 } } */
 /* { dg-skip-if "PR90698" { *-*-darwin* } } */
 /* { dg-additional-sources pr61599-2.c } */
-/* { dg-options "-mcmodel=medium -fdata-sections" } */
+/* { dg-options "-mcmodel=medium -fdata-sections -save-temps" } */
 
 char a[1*1024*1024*1024];
 char b[1*1024*1024*1024];
@@ -13,3 +13,5 @@ int main()
 {
   return bar() + c[225];
 }
+
+/* { dg-final { scan-assembler-times {\.section[ \t]+\.lbss\..,"aw[hl]",@nobits} 3 } } */

Reply via email to