[SanitizerBinaryMetadata] Make module_[cd]tor external
authorFangrui Song <i@maskray.me>
Wed, 8 Feb 2023 08:58:39 +0000 (00:58 -0800)
committerFangrui Song <i@maskray.me>
Wed, 8 Feb 2023 08:58:39 +0000 (00:58 -0800)
commit6ce8e716bfab4a1d2d8777f9868af5759a515391
tree306e9fee0bf3c58f232b5fe1814a76b9cce64e0e
parent653d823ad22b83fea3019e94e02f8ad99a33b4c0
[SanitizerBinaryMetadata] Make module_[cd]tor external

If a COMDAT key has a local linkage, it behaves as `comdat nodeduplicate` and
llvm/lib/Linker/LinkModules.cpp does not deduplicate its members.
This is not intended. Switch to an external linkage to allow deduplication.

See also https://maskray.me/blog/2021-07-25-comdat-and-section-group#grp_comdat

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D143530
llvm/lib/Transforms/Instrumentation/SanitizerBinaryMetadata.cpp
llvm/test/Instrumentation/SanitizerBinaryMetadata/ctor.ll [new file with mode: 0644]