[cfe-dev] Why clang creates ELF section group with only one section in it?

Rafael Espíndola rafael.espindola at gmail.com
Thu May 10 20:16:54 PDT 2012


> But, I found that I can workaround this error by avoiding creating
> .group section in object files:
>
> $ elfdump -g a.o
>
> Group Section:  .group
>      index    flags / section         signature symbol
>        [0]   [ COMDAT ]               _Z3barIiEiT_
>        [1]   .text._Z3barIiEiT_ [6]
>
> This group contains only one section, is it really needed?
>
> GCC (4.5.1, 4.7.0) doesn't create one.
> Sun C++ 5.11 creates group with 2 sections: bar<int>() text and relocs.

gcc 4.6 on linux produces an output very similar to what clang does.
The groups (comdats) are a generic way to let the linker discard
sections very quickly. In this case it is used for discarding  a
method instantiated in two files.

Just dropping the group would probably create an executable with two
copies of the method. Is that what you get?

>From your description of the problem, it looks like old version of the
solaris linker cannot handle groups very well and expect sections to
be organized in some particular way. If you can figure that out you
might be able to implement it in llvm.

Cheers,
Rafael




More information about the cfe-dev mailing list