[LLVMbugs] [Bug 19969] New: IMAGE_COMDAT_SELECT_ASSOCIATIVE sections produced with an invalid comdat

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jun 6 09:14:46 PDT 2014


            Bug ID: 19969
           Summary: IMAGE_COMDAT_SELECT_ASSOCIATIVE sections produced with
                    an invalid comdat
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: rafael.espindola at gmail.com
                CC: llvmbugs at cs.uiuc.edu, rnk at google.com
    Classification: Unclassified


struct foo {
template <class T> struct bar {
  static foo zed;
template <class T>
foo bar<T>::zed;
template class bar<int>;

clang produces (after some simplification)

target triple = "i686-pc-windows-msvc"
%struct.foo = type { i8 }
@"\01?zed@?$bar at H@@2Ufoo@@A" = weak_odr global %struct.foo zeroinitializer,
align 1
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void
()*, i8* } { i32 65535, void ()* @"\01??__Ezed@?$bar at H@@2Ufoo@@A at YAXXZ", i8*
getelementptr inbounds (%struct.foo\
* @"\01?zed@?$bar at H@@2Ufoo@@A", i32 0, i32 0) }]
define linkonce_odr void @"\01??__Ezed@?$bar at H@@2Ufoo@@A at YAXXZ"() {
  %call = call x86_thiscallcc %struct.foo* @"\01??0foo@@QAE at XZ"(%struct.foo*
@"\01?zed@?$bar at H@@2Ufoo@@A")
  ret void
declare x86_thiscallcc %struct.foo* @"\01??0foo@@QAE at XZ"(%struct.foo* returned)

which seems reasonable. The problem is that the llc produced assembly has

.section        .bss,"bw",discard,"?zed@?$bar at H@@2Ufoo@@A"
.section        .CRT$XCU,"rd",associative .bss,"?zed@?$bar at H@@2Ufoo@@A"

The symbol ?zed@?$bar at H@@2Ufoo@@A" cannot be in two sections at the same time.

Given the description of how assoc works in the coff documentation, it looks
like the comdat name is not actually used. It is kept iff the associated
section is kept.

Right now this is not noticed because the comdat is the .section is ignored and
the produce .obj end up having the first output symbol as a comdat, what ever
that happens to be. In the above case, none at all.

msvc seems to create a symbol just for this (...$initializer$...). We probably
just produce a temp symbol.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140606/5d62eb8a/attachment.html>

More information about the llvm-bugs mailing list