This revision also fixes the missing SHF_X86_64_LARGE flag on .lbss.*
sections.
---------------------------------------------------------------------------
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.
Similarly, the current assembler output relies on the assembler to set
the SHF_X86_64_LARGE section flag based on the section name. While gcc
emits the necessary flag letter ('l' with gas, 'h' with Solaris as) for
plain .lbss sections, it fails to do so for .lbss.*.
This patch adresses this by moving the gas definition of
MACH_DEP_SECTION_ASM_FLAG to i386/x86_64.h so it's picked up by all
64-bit x86 targets. It also extends ix86_in_large_data_p to also
consider .lbss.* etc. sections as large data sections, not just .lbss,
matching x86_64_elf_section_type_flags.
pr61599-1.o is identical without and with the section letter and section
type specifiec.
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?
Rainer
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University
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.