[LLVMbugs] [Bug 12843] New: put ELF reloc section against section with template function instantiation in the same COMDAT group

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Wed May 16 01:39:47 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12843

             Bug #: 12843
           Summary: put ELF reloc section against section with template
                    function instantiation in the same COMDAT group
           Product: new-bugs
           Version: trunk
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: sbn at tbricks.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Hello!

While working with clang on Solaris I found that it doesn't put section with
relocation entries against section with templated function instantiation in the
same COMDAT group.

$ cat -n a.cpp 
     1  #include "a.h"
     2  
     3  void baz()
     4  {
     5      bar(10);
     6  }
$ cat -n a.h
     1  struct S
     2  {
     3      ~S();
     4  };
     5  
     6  template<typename T>
     7  int bar(T t)
     8  {
     9      S s;
    10      return t*3;
    11  }
$ /opt/clang/bin/clang++ -v
clang version 3.1 (branches/release_31 156808)
Target: i386-pc-solaris2.10
Thread model: posix
$ /opt/clang/bin/clang++ -c a.cpp
$ elfdump -c a.o|grep ^Section|grep bar
Section Header[6]:  sh_name: .text._Z3barIiEiT_
Section Header[7]:  sh_name: .rel.text._Z3barIiEiT_
$ elfdump -g a.o

Group Section:  .group
     index    flags / section         signature symbol
       [0]   [ COMDAT ]               _Z3barIiEiT_
       [1]   .text._Z3barIiEiT_ [6]

If the section with function code (.text._Z3barIiEiT_) is discarded during
linking there is no point to have corresponding reloc section.
So it makes sense to put it in the same COMDAT group as .text._Z3barIiEiT_

This is what Sun CC does:

$ CC -V
CC: Sun C++ 5.11 SunOS_i386 145731-02 2011/02/11
usage: CC [ options ] files.  Use 'CC -flags' for details
$ CC -c a.cpp
$ elfdump -g a.o

Group Section:  .group%__1cDbar4Ci_6FTA_i_

    index    flags / section         signature symbol
      [0]   [ COMDAT ]               __1cDbar4Ci_6FTA_i_
      [1]   .text%__1cDbar4Ci_6FTA_i_ [4]
      [2]   .rel.text%__1cDbar4Ci_6FTA_i_ [18]
$ echo __1cDbar4Ci_6FTA_i_ | c++filt
int bar<int>(__type_0)

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list