llvm.org GIT mirror llvm / 1fb8dda
[msan] Don't put module constructors in comdats. There is something strange going on with debug info (.eh_frame_hdr) disappearing when msan.module_ctor are placed in comdat sections. Moving this functionality under flag, disabled by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263579 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 4 years ago
3 changed file(s) with 14 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
189189 static cl::opt ClCheckConstantShadow("msan-check-constant-shadow",
190190 cl::desc("Insert checks for constant shadow values"),
191191 cl::Hidden, cl::init(false));
192 static cl::opt ClWithComdat("msan-with-comdat",
193 cl::desc("Place MSan constructors in comdat sections"),
194 cl::Hidden, cl::init(false));
192195
193196 static const char *const kMsanModuleCtorName = "msan.module_ctor";
194197 static const char *const kMsanInitName = "__msan_init";
539542 createSanitizerCtorAndInitFunctions(M, kMsanModuleCtorName, kMsanInitName,
540543 /*InitArgTypes=*/{},
541544 /*InitArgs=*/{});
542 Comdat *MsanCtorComdat = M.getOrInsertComdat(kMsanModuleCtorName);
543 MsanCtorFunction->setComdat(MsanCtorComdat);
544
545 appendToGlobalCtors(M, MsanCtorFunction, 0, MsanCtorFunction);
545 if (ClWithComdat) {
546 Comdat *MsanCtorComdat = M.getOrInsertComdat(kMsanModuleCtorName);
547 MsanCtorFunction->setComdat(MsanCtorComdat);
548 appendToGlobalCtors(M, MsanCtorFunction, 0, MsanCtorFunction);
549 } else {
550 appendToGlobalCtors(M, MsanCtorFunction, 0);
551 }
552
546553
547554 if (TrackOrigins)
548555 new GlobalVariable(M, IRB.getInt32Ty(), true, GlobalValue::WeakODRLinkage,
0 ; MSan converts 2-element global_ctors to 3-element when adding the new entry.
1 ; RUN: opt < %s -msan -S | FileCheck %s
1 ; RUN: opt < %s -msan -msan-with-comdat -S | FileCheck %s
22
33 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
44 target triple = "x86_64-unknown-linux-gnu"
33 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
44 target triple = "x86_64-unknown-linux-gnu"
55
6 ; CHECK: $msan.module_ctor = comdat any
7 ; CHECK: @llvm.global_ctors {{.*}} { i32 0, void ()* @msan.module_ctor, i8* bitcast (void ()* @msan.module_ctor to i8*) }
6 ; CHECK: @llvm.global_ctors {{.*}} { i32 0, void ()* @msan.module_ctor, i8* null }
87
98 ; Check the presence and the linkage type of __msan_track_origins and
109 ; other interface symbols.
981980 ; CHECK-NEXT: ret i8*
982981
983982
984 ; CHECK-LABEL: define internal void @msan.module_ctor() comdat {
983 ; CHECK-LABEL: define internal void @msan.module_ctor() {
985984 ; CHECK: call void @__msan_init()