On Thu, Apr 07, 2005 at 03:36:18PM -0700, James E Wilson wrote:
> H. J. Lu wrote:
> >Gcc 4,0 generates
> >.section .gnu.linkonce.t._ZN3FooC1Ev,"axG",@progbits,_ZN3FooC1Ev,comdat
> >for comdat group. Can gcc use
> >.section .text._ZN3FooC1Ev,"axG",@progbits,_ZN3FooC1Ev,comdat
> >instead? At least, there will be less characters for linker to process.
> 
> I know of no reason why we must continue using .gnu.linkonce for targets 
> that have proper comdat support.
> 
> However, I don't think this will be an easy transition, because there 
> are too many places that make assumptions about the fact that 
> .gnu.linkonce has a special meaning.  That might be an argument against 
> even trying.
> 
> For instance, in varasm.c, in default_function_rodata_section, we have
>       /* For .gnu.linkonce.t.foo we want to use .gnu.linkonce.r.foo.  */
>       if (DECL_ONE_ONLY (decl) && strncmp (name, ".gnu.linkonce.t.", 
> 16) == 0)
> and this code fails if you remove the .gnu.linkonce from the section 
> name.  We'd need code to check for and handle a comdat section here.
> 
> dwarf2out.c assumes that comdat sections for debugging start with 
> .gnu.linkonce.

I am not sure if dwarf2out.c supports comdat group at all:

http://gcc.gnu.org/ml/gcc-patches/2005-04/msg00711.html

> 
> There are likely many other places that need fixing also.
> 
> There is also the possible issue that using .text.foo conflicts with the 
> naming scheme used by the -ffunction-sections -fdata-sections options. 
> What happens if we have two sections both named .text.foo, one of which 
> is a comdat section, and one of which came from -ffunction-sections?  We 

The assembler with proper comdat group should be OK. I had to fix
the assembler to support dupulicated section names for comdat group.
For linker, input section names are only used to group sections for
output.

> might still need to use a distinct prefix to make this work, though it 
> doesn't have to be as long as .gnu.linkonce.  And if we do add another 
> prefix, some of the special code for .gnu.linkonce will have to be 
> duplicated, in which case it might have been simpler to just stick with 
> .gnu.linkonce in the first place.

The current linker supports "--sort-section name". .text.foo is easier
to deal with than .gnu.linkonce.t.foo when mixing comdat and non-comdat
sections.


H.J.

Reply via email to