This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFC: COMDAT group names become anonymouse local symbols


> When assembling this trivial file:
>
> ? ? ? ?.section ? ? ? ?A,"axG",%progbits,B,comdat
> ? ? ? ?# Note that there is no definition of the symbol B.
>
> GAS generates a COMDAT group whose "signature" (in the sense of the
> ELF spec) is an anonymous local symbol:
>
> Section Headers:
> ?[Nr] Name ? ? ? ? ? ? ?Type ? ? ? ? ? ?Address ? ? ? ? ?Off ? ?Size ? ES Flg Lk Inf Al
> ?[ 1] B ? ? ? ? ? ? ? ? GROUP ? ? ? ? ? 0000000000000000 000040 000008 04 ? ? ?7 ? 5 ?4
>
> Symbol table '.symtab' contains 6 entries:
> ? Num: ? ?Value ? ? ? ? ?Size Type ? ?Bind ? Vis ? ? ?Ndx Name
> ? ? 5: 0000000000000000 ? ? 0 SECTION LOCAL ?DEFAULT ? ?1
>
> This seems bad. ?The documentation for the .section directive says
> that B is the group name, and since the linker's collapsing of COMDAT
> groups is done based on the *signature*, not the name referred to by
> the section header itself, this seems wrong.
>
> On the other hand, perhaps GCC shouldn't generate code like this. ?(It
> does, at present, for certain C++ inputs.) ?The assembler certainly
> shouldn't create a global symbol named "B". ?If the assembler were to
> create a local symbol with the name "B", would the linker still
> combine this COMDAT group with another group in another object file
> also named "B", even if both had different local symbols as their
> signatures?

It should; I'm pretty sure that gold will do this correctly, but I
can't say for sure for gnu ld.

If gcc were to generate the local symbol, it looks like gas will do
the right thing and set the name of the SHT_GROUP section to ".group"
with a link field pointing to the key symbol.

I'm guessing that this might be an artifact from gas support for HP's
original comdat implementation on PA-RISC 2.0, where the comdat key
was the name of the SHT_GROUP section.

(The point of using a symbol is that the comdat keys are often
extremely long and are usually already in the symbol table. With my
original design of COMDAT groups at HP, we found that we were bloating
the section string table with strings that were already in the symbol
string table. We fixed this during the Itanium ABI discussions.)

-cary


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]