llvm-project/llvm/lib/Transforms/Instrumentation
Fangrui Song a400ca3f3d [SanitizerCoverage] Use different module ctor names for trace-pc-guard and inline-8bit-counters
Fixes the main issue in PR41693

When both modes are used, two functions are created:
`sancov.module_ctor`, `sancov.module_ctor.$LastUnique`, where
$LastUnique is the current LastUnique counter that may be different in
another module.

`sancov.module_ctor.$LastUnique` belongs to the comdat group of the same
name (due to the non-null third field of the ctor in llvm.global_ctors).

    COMDAT group section [    9] `.group' [sancov.module_ctor] contains 6 sections:
       [Index]    Name
       [   10]   .text.sancov.module_ctor
       [   11]   .rela.text.sancov.module_ctor
       [   12]   .text.sancov.module_ctor.6
       [   13]   .rela.text.sancov.module_ctor.6
       [   23]   .init_array.2
       [   24]   .rela.init_array.2

    # 2 problems:
    # 1) If sancov.module_ctor in this module is discarded, this group
    # has a relocation to a discarded section. ld.bfd and gold will
    # error. (Another issue: it is silently accepted by lld)
    # 2) The comdat group has an unstable name that may be different in
    # another translation unit. Even if the linker allows the dangling relocation
    # (with --noinhibit-exec), there will be many undesired .init_array entries
    COMDAT group section [   25] `.group' [sancov.module_ctor.6] contains 2 sections:
       [Index]    Name
       [   26]   .init_array.2
       [   27]   .rela.init_array.2

By using different module ctor names, the associated comdat group names
will also be different and thus stable across modules.

Reviewed By: morehouse, phosek

Differential Revision: https://reviews.llvm.org/D61510

llvm-svn: 360107
2019-05-07 01:39:37 +00:00
..
AddressSanitizer.cpp [CommandLine] Provide parser<unsigned long> instantiation to allow cl::opt<uint64_t> on LP64 platforms 2019-04-24 02:40:20 +00:00
BoundsChecking.cpp Add a 'dynamic' parameter to the objectsize intrinsic 2019-01-30 20:34:35 +00:00
CFGMST.h Use llvm::stable_sort 2019-04-23 14:51:27 +00:00
CGProfile.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt Remove esan. 2019-03-11 20:23:40 +00:00
ControlHeightReduction.cpp [PGO][CHR] A bug fix. 2019-05-01 22:49:52 +00:00
DataFlowSanitizer.cpp Add "const" in GetUnderlyingObjects. NFC 2019-04-24 06:55:50 +00:00
GCOVProfiling.cpp [opaque pointer types] Pass value type to GetElementPtr creation. 2019-02-01 20:44:47 +00:00
HWAddressSanitizer.cpp [CommandLine] Provide parser<unsigned long> instantiation to allow cl::opt<uint64_t> on LP64 platforms 2019-04-24 02:40:20 +00:00
IndirectCallPromotion.cpp Change some dyn_cast to more apropriate isa. NFC 2019-04-05 16:16:23 +00:00
InstrOrderFile.cpp Try to fix NetBSD buildbot breakage introduced in D57463. 2019-03-01 15:25:24 +00:00
InstrProfiling.cpp [InstrProf] Use separate comdat group for data and counters 2019-02-27 23:38:44 +00:00
Instrumentation.cpp Assigning to a local object in a return statement prevents copy elision. NFC. 2019-04-25 20:09:00 +00:00
LLVMBuild.txt Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MaximumSpanningTree.h Use llvm::stable_sort 2019-04-23 14:51:27 +00:00
MemorySanitizer.cpp MSan: handle llvm.lifetime.start intrinsic 2019-04-30 08:35:14 +00:00
PGOInstrumentation.cpp The error message for mismatched value sites is very cryptic. 2019-04-23 22:26:55 +00:00
PGOMemOPSizeOpt.cpp Move DomTreeUpdater from IR to Analysis 2019-02-06 02:52:52 +00:00
SanitizerCoverage.cpp [SanitizerCoverage] Use different module ctor names for trace-pc-guard and inline-8bit-counters 2019-05-07 01:39:37 +00:00
ThreadSanitizer.cpp [opaque pointer types] Add a FunctionCallee wrapper type, and use it. 2019-02-01 02:28:03 +00:00