[llvm-bugs] [Bug 38607] New: Using a private global as a global_ctor key fails when emitting a COFF object

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 16 13:30:42 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38607

            Bug ID: 38607
           Summary: Using a private global as a global_ctor key fails when
                    emitting a COFF object
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: david.majnemer at gmail.com, llvm-bugs at lists.llvm.org

Consider this LLVM IR:

@x = private global i32 0
@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }]
  [{ i32, void ()*, i8* }
   { i32 65535,
     void ()* @register_x,
     i8* bitcast (i32* @x to i8*) }]
define internal void @register_x() {
  ret void
}

We can generate asm for it, but we cannot assemble it to an object. We emit:

$ llc t.ll -o t.o -filetype=obj
LLVM ERROR: Missing associated COMDAT section for section .CRT$XCU

Mechanically, what happens is we try to look up a private label (.Lx) in the
COFF symbol table that we're making, we use GetOrCreate on it, but we don't
have a section for it, so we issue this diagnostic.

However, the input LLVM IR makes some sense. We should run the initializer if
and only if @x is included in the final link, and it's not comdat, so it will
be included, and we can just ignore it and always put @register_x in the main
.CRT$XCU section.

The question is, should we accept the assembly that we generate today?

        .section        .rdata,"dr"
        .p2align        2               # @x
.Lx:
        .long   0                       # 0x0

        .section        .CRT$XCU,"dr",associative,.Lx
        .p2align        3
        .quad   register_x

Does that assembly make sense, i.e. make this .CRT$XCU section associative with
the non-comdat .rdata section?

-- 
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/20180816/8b2cb0a4/attachment.html>


More information about the llvm-bugs mailing list