SHT_GROUP sections are used to fully support well controlled COMDAT, as detailed here: http://www.airs.com/blog/archives/52 The support for SHT_GROUP appeared in the gcc 4.x series. Since Solaris has supported SHT_GROUP since shortly after it was defined, once might assume that gcc 4.x would use SHT_GROUP under Solaris, as it does for Linux. However it's not true usually. The macro HAVE_COMDAT_GROUP is used for gcc to direct if SHT_GROUP support is available. It's found that the macro is set to 0 if configured gcc with Solaris linker and/or Solaris assembler, which means gcc has to rely on older mechanism for doing COMDAT sections known as "GNU linkonce". The assembly code as follows .section .text,"axG",@progbits,.foo,comdat is used for gcc configure to check if the specified assembler supports COMDAT group. Solaris assembler failed to assemble the code of GNU-style. For Solaris assembler for sparc, the format for COMDAT group looks like as follows: .group foo,".text%foo",#comdat .section ".text%foo" For Solaris assembler for x86, the format may look like as follows: .group __i686.get_pc_thunk.cx, .text.__i686.get_pc_thunk.cx%__i686.get_pc_thunk.cx, #comdat .section .text.__i686.get_pc_thunk.cx%__i686.get_pc_thunk.cx,"ax" __i686.get_pc_thunk.cx:
Gcc 4.x assume linkers other than GNU ld don't support COMDAT group. However Solaris linkers do support it. It would be better for gcc to be able to use COMDAT group under Solaris. Besides, sparc_elf_asm_named_section in sparc/sparc.c and i386_solaris_elf_named_section in i386/i386.c have to generate COMDAT groups with satisfying format under Solaris. Any thoughts? Thanks, -- Lijuan -- Summary: gcc 4.x needs to utilize better COMDAT mechanism under Solaris Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: regression AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hailijuan at gmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40483