[PATCH] D143634: [ModuleUtils] Assert correct linkage and visibility of structors' COMDAT key
Marco Elver via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 9 02:27:38 PST 2023
melver created this revision.
melver added reviewers: MaskRay, vitalybuka, fmayer, pcc.
Herald added subscribers: luke, Enna1, kosarev, frasercrmck, kerbowa, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, jvesely.
Herald added a project: All.
melver requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead.
Herald added projects: clang, LLVM.
Currently structors of various sanitizers have internal linkage, even
with a COMDAT set. This means that semantics is not the same with LTO,
because LTO uses linkage to deduplicate and not the COMDAT. The result
is that a target built with LTO currently has numerous duplicate
redundant constructors and destructors generated by the sanitizers.
This can be fixed by marking the structor as having external linkage.
However, care must be taken to also set hidden visibility, otherwise a
DSO may not call its own structor but another, which is usually wrong.
To allow the caller full flexibility over precise linkage and
visibility, we can't just set it for the caller.
Add an assertion that checks the various rules.
Along the way, we now have to fix up ASan, HWASan, and SanCov to emit
the right linkage.
See also: https://maskray.me/blog/2021-07-25-comdat-and-section-group#grp_comdat
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143634
Files:
clang/test/CodeGen/asan-destructor-kind.cpp
clang/test/CodeGen/asan-no-globals-no-comdat.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/lib/Transforms/Utils/ModuleUtils.cpp
llvm/test/CodeGen/AArch64/pacbti-llvm-generated-funcs-1.ll
llvm/test/DebugInfo/AArch64/asan-stack-vars.mir
llvm/test/DebugInfo/COFF/asan-module-ctor.ll
llvm/test/DebugInfo/COFF/asan-module-without-functions.ll
llvm/test/DebugInfo/Generic/incorrect-variable-debugloc.ll
llvm/test/DebugInfo/X86/dbg_value_direct.ll
llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_do_not_instrument_lds.ll
llvm/test/Instrumentation/AddressSanitizer/basic.ll
llvm/test/Instrumentation/AddressSanitizer/instrument_global.ll
llvm/test/Instrumentation/AddressSanitizer/kcfi-offset.ll
llvm/test/Instrumentation/AddressSanitizer/kcfi.ll
llvm/test/Instrumentation/AddressSanitizer/module-flags.ll
llvm/test/Instrumentation/AddressSanitizer/no-global-ctors.ll
llvm/test/Instrumentation/AddressSanitizer/no-globals.ll
llvm/test/Instrumentation/AddressSanitizer/no_global_dtors.ll
llvm/test/Instrumentation/AddressSanitizer/program-addrspace.ll
llvm/test/Instrumentation/AddressSanitizer/version-mismatch-check.ll
llvm/test/Instrumentation/HWAddressSanitizer/RISCV/basic.ll
llvm/test/Instrumentation/HWAddressSanitizer/RISCV/with-calls.ll
llvm/test/Instrumentation/HWAddressSanitizer/basic.ll
llvm/test/Instrumentation/HWAddressSanitizer/with-calls.ll
llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-8bit-counters.ll
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-bool-flag.ll
llvm/test/Instrumentation/SanitizerCoverage/trace-pc-guard.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143634.496058.patch
Type: text/x-patch
Size: 24938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230209/fa166a57/attachment-0001.bin>
More information about the cfe-commits
mailing list