[patch] Correctly set the comdat symbol on COFF

Reid Kleckner rnk at google.com
Thu Jun 5 13:40:25 PDT 2014


This seems wrong for associative comdats.  Won't the comdat symbol
necessarily be in a different section?

Also, I ran into some problems with our assembly parsing:

$ cat t.cpp
int foo();
template <typename T> struct Foo { static int x; };
template <typename T> int Foo<T>::x = foo();
int main() { return Foo<int>::x; }

$ clang -c t.cpp -S -o -  | llvm-mc -o t.s
<stdin>:47:37: error: associated section must be a COMDAT section
        .section        .CRT$XCU,"rd",associative .bss,"?x@?$Foo at H@@2HA"



On Thu, Jun 5, 2014 at 12:20 PM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> We extended the .section syntax to allow multiple sections with the
> same name but different comdats, but currently we don't make sure that
> the output section has that comdat symbol.
>
> That happens to work with the code llc produces currently because it looks
> like
>
> .section secName, "dr", one_only, "COMDATSym"
> .globl COMDATSym
> COMDATSym:
> ....
>
> but that is not very friendly to anyone coding in assembly or even to
> llc once we get comdat support in the IR.
>
> The attached patch changes the coff object writer to make sure the
> comdat symbol is output just after the section symbol, as required by
> the coff spec.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140605/05e36a33/attachment.html>


More information about the llvm-commits mailing list