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


On 10/20/2010 5:18 PM, Alan Modra wrote:

>> 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.

> I don't see anything bad about this (except possibly if you are using
> a linker other than GNU ld or gold).  That isn't an "anonymous" local
> symbol.  That is the section symbol for the group section named "B".
> GNU ld saves .strtab space by leaving st_name zero on section symbols;
> The name of such a symbol is given by the section sh_name.  So the
> group signature is indeed "B".

The concern here is indeed about compatibility with other linkers.  At
least one linker does not treat the name of the group as "B" in this
case -- and therefore does not correctly collapse COMDAT groups
generated by GAS.

I guess the question is what exactly this bit of the ELF specification
means:

"The name of a symbol from one of the containing object's symbol tables
provides a signature for the section group.  The section header of the
SHT_GROUP section specifies the identifying symbol entry, as described
above: the sh_link member contains the section header index of the
symbol table section that contains the entry. The sh_info member
contains the symbol table index of the identifying entry.

Here, the symbol is the section symbol.  The section symbol has no name,
in the sense that its st_name value is zero.  In fact, the ELF
specification says, in the documentation for "st_name":

"If the value is non-zero, it represents a string table index that gives
the symbol name. Otherwise, the symbol table entry has no name."

I don't see anything that says that the symbol name is implicitly the
name of the associated section; in other words, I don't see how to
justify your statement that "the name of such a symbol is given by the
section sn_name".  So, it seems to me that a literal reading of the ELF
specification says that what Binutils is doing isn't valid and that we
should change the GAS behavior to do:

> In cases like this, where a non-section symbol having the same name a
> the group signature does not already exist, gas could create a normal
> local symbol just for the group name.

Thoughts?

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713


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