[patch] Add support for comdats to the gold plugin

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Aug 22 09:57:47 PDT 2014


The attached patch adds comdat support to the gold plugin.

There are two parts to it. One is the plugin telling gold the comdat.
That part is really easy, just setting comdat_key.

What gets things a bit more complicated is that gold only seems
symbols. In particular, if A is an alias to B, it only see the symbols
A and B. It can then ask us to keep symbol A but drop symbol B. What
we have to do instead is to create an internal version of B and make A
an alias to that.

There is an example with the problem in llvm.org/pr20617. The patch
includes an extended testcase.

At some point some of this logic should be moved to lib/Linker so that
we don't map a Constant to an internal version just to have lib/Linker
map that again to the destination module. Moving the logic should also
allow us to fix pr20617 in llvm-link.

The reason for implementing this in tools/gold for now is simplicity.
With it in place it should be possible to update clang to use comdats
for constructors and destructors on ELF without breaking the LTO
bootstrap. Once that is done I intend to come back and improve the
interface lib/Linker exposes.

Duncan, do you known if there is anything else that needs to be done
when creating an  local function replacement or is just he call to
splice sufficient?

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: t.patch
Type: text/x-patch
Size: 10395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140822/e47837f8/attachment.bin>


More information about the llvm-commits mailing list