llvm-project/llvm/test/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 Asan use-after-scope: don't poison allocas if there were untraced lifetime intrinsics in the function (PR41481) 2019-04-16 07:54:20 +00:00
BoundsChecking Fix a hang when lowering __builtin_dynamic_object_size 2019-04-10 23:42:11 +00:00
DataFlowSanitizer [DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label. 2018-05-09 02:40:45 +00:00
HWAddressSanitizer hwasan: Enable -hwasan-allow-ifunc by default. 2019-04-09 00:25:59 +00:00
InstrOrderFile Add a module pass for order file instrumentation 2019-02-28 20:13:38 +00:00
InstrProfiling [InstrProf] Use separate comdat group for data and counters 2019-02-27 23:38:44 +00:00
MemorySanitizer MSan: handle llvm.lifetime.start intrinsic 2019-04-30 08:35:14 +00:00
SanitizerCoverage [SanitizerCoverage] Use different module ctor names for trace-pc-guard and inline-8bit-counters 2019-05-07 01:39:37 +00:00
ThreadSanitizer [NewPM][TSan] Reiterate the TSan port 2019-01-16 09:28:01 +00:00
cgprofile.ll [BFI] Use rounding while computing profile counts. 2018-08-16 00:26:59 +00:00