Gcc's comdat support in glibc missing (was: Re: section() handling changed (or a bug was introduced)?)

Mariusz Mazur mmazur@kernel.pl
Wed Oct 20 17:28:00 GMT 2004


On Âśroda 20 paÂździernik 2004 16:21, Daniel Jacobowitz wrote:
> It's not a global/local question; but it wants there to be only one
> copy.  Then your linker doesn't really support comdat; if it did, they
> would not conflict.

I do have comdat everywhere, but thanks to your hints I've finally tracked 
down what's wrong.

This is what glibc does on sparc:

#   define __make_section_unallocated(section_string)   \
        asm (".section " section_string "\n\t.previous");

__make_section_unallocated
  (".gnu.linkonce.b.__sparc32_atomic_locks, \"aw\", %nobits");

volatile unsigned char __sparc32_atomic_locks[64]
  __attribute__ ((nocommon,
        section (".gnu.linkonce.b.__sparc32_atomic_locks" "\n\t#"),
                  visibility ("hidden")));

On gcc without comdat this results with two .section entries:

    .section .gnu.linkonce.b.__sparc32_atomic_locks, "aw", %nobits

    .section    .gnu.linkonce.b.__sparc32_atomic_locks
    #,"aw",@nobits

As one can see, that's a smart move to define '%nobits' instead of 
'@nobits' (whatever that does :).

On gccs with comdat support the same code results in:

        .section .gnu.linkonce.b.__sparc32_atomic_locks, "aw", %nobits

        .section        .bss,"awG",@nobits,.__sparc32_atomic_locks
        #,comdat

This results in (a) additional definition 
of .gnu.linkonce.b.__sparc32_atomic_locks section (which is empty and kind of 
useless) and (b) commenting out comdat definition which causes conflicts when 
linking (since that definition is supposed to replace .gnu.linkonce).

A fix to just make it compile is simple - removal of "\n\t#". But what about 
that nobits hack? It's there for a reason (right? :) and it can't be 
'rehacked' in the same way since .section syntax changed.

CC: to libc-alpha (hope they accept off-list posts) and would be nice if 
someone reacted with a patch :)

-- 
In the year eighty five ten
God is gonna shake his mighty head
He'll either say,
"I'm pleased where man has been"
Or tear it down, and start again



More information about the Libc-alpha mailing list