[PATCH] D56516: [SanitizerCoverage] Don't create comdat for weak functions.

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 10 13:32:18 PST 2019


bd1976llvm added a comment.

In D56516#1353258 <https://reviews.llvm.org/D56516#1353258>, @morehouse wrote:

> @bd1976llvm: So do you still think this is a compiler bug?  It sounds like ELF provides no guarantees about which COMDAT is kept.  Which would mean we need to keep the weak symbols from going in a COMDAT.


What I mean't by a compiler bug is that, at least on ELF targets, you can't have weak and strong versions of a symbol in the same duplicate COMDAT set (the set of COMDATs with the same name) and expect the linker to always pick a strong version of the symbol, as we have been discussing; therefore, the current output looks incorrect on ELF.

Is not putting weak symbols into COMDATs the way to fix this?

- On targets other than ELF I am unsure.
- For ELF targets, this fix is functionally correct, but it will have the effect of retaining the section content for the weak symbols in the output, potentially slowing the link and making the output larger (unless you use -gc-sections).

I'm afraid I don't have the time to look into the details of your bug ATM. Some other solutions might be:

- To change how the implementation works so that it is not reliant on weak vs strong symbol semantics (if possible).
- To add the weak/strong'ness of the symbol to the COMDAT key for ELF.

Hopefully, someone who is an expert on the other file formats might comment (Reid?).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56516/new/

https://reviews.llvm.org/D56516





More information about the llvm-commits mailing list