[llvm] r209015 - Add comdat key field to llvm.global_ctors and llvm.global_dtors

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed Jun 4 18:17:00 PDT 2014


> Not sure I follow. Given
>

Never mind, looking a bit closer at what ELF linkers do it seems they
have just enough flexibility to handle this. There is a bit of
documentation in
http://www.sco.com/developers/gabi/latest/ch4.sheader.html. The gist
seems to be:

* for local symbols all references must be from withing the comdat.
Not an issue since if the variable is local we don't put it in a
comdat.
* for global symbols the symbol is effectively made undefined if it
pointed to a discarded section and linking continues. In particular,
if the symbol is found in another comdat there is no error.

This explains why the situation with variables is different from the
situation with constructors:

* With variables, if the new comdat with both var and guard is
discarded, the other file is sure to have a comdat with the var and
another with the guard.
* With constructors, if the new comdat with C1 and C2 is discarded,
the other file might have only C1 or C2.

as for my earlier example in assembly, it was just missing a few
.global directives :-)

Now we "just" need to implement comdats in the IR!

Cheers,
Rafael



More information about the llvm-commits mailing list