The gcc.target/i386/pr61599-1.c test has been FAILing on Solaris/x86
with the native assembler for a long time:
FAIL: gcc.target/i386/pr61599-1.c (test for excess errors)
UNRESOLVED: gcc.target/i386/pr61599-1.c compilation failed to produce executable
Excess errors:
ld: fatal: relocation error: R_AMD64_PC32: file gcc/amd64/crtbegin.o: symbol
completed.0: value 0xc01004b9 does not fit
ld: fatal: relocation error: R_AMD64_PC32: file gcc/amd64/crtbegin.o: symbol
completed.0: value 0xc01004a7 does not fit
Looking closer, pr61599-1.o is 3.1 GB large with the native assembler.
Comparing the section headers between as and gas, one sees the
difference:
With as there's
Section Header[3]: sh_name: .lbss.a
sh_addr: 0 sh_flags: [ SHF_WRITE SHF_ALLOC ]
sh_size: 0x40000000 sh_type: [ SHT_PROGBITS ]
while gas creates
Section Header[5]: sh_name: .lbss.a
sh_addr: 0 sh_flags: [ SHF_WRITE SHF_ALLOC SHF_AMD6
4_LARGE ]
sh_size: 0x40000000 sh_type: [ SHT_NOBITS ]
The use of SHT_PROGBITS by as is due to gcc not emitting @nobits for the
.lbss sections, so as uses the default section type:
.section .lbss.a,"aw"
For .bss, we get this instead:
.section .bss.a,"aw",@nobits
as usually doesn't care about section names, but relies on the compiler
to correctly emit section types and flags.
This happens because x86_64_elf_section_type_flags first calls
default_section_type_flags, which doesn't know about .lbss and sets
SECTION_NOTYPE. When default_elf_asm_named_section later emits the
.section directive, @nobits is omitted even though SECTION_BSS has been
added by then.
To work around this, this patch clears SECTION_NOTYPE when SECTION_BSS
is set.
Bootstrapped without regressions on i386-pc-solaris2.11,
amd64-pc-solaris2.11, x86_64-pc-linux-gnu, and i686-pc-linux-gnu.
Ok for trunk?
The lack of SHF_X86_64_LARGE for .lbss above has the same reason.
However, the original Solaris 11.4 as doesn't know about the 'l' section
letter, so this requires a configure test. I'll deal with this
separately.
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
2026-03-14 Rainer Orth <[email protected]>
gcc:
* config/i386/i386.cc (x86_64_elf_section_type_flags): Clear
SECTION_NOTYPE for .lbss etc.
gcc/testsuite:
* gcc.target/i386/pr61599-1.c (dg-options): Add -save-temps.
(scan-assembler-times): Check for @nobits.
# HG changeset patch
# Parent 146cfa08908016229c8dc0f78ecc40b29d88262a
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
@@ -852,7 +852,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/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",@nobits} 3 } } */