forked from OSchip/llvm-project
[SanitizerCoverage] Use External on Windows
This should fix https://reviews.llvm.org/D98903#2643589 though it is not clear to me why ExternalWeak does not work.
This commit is contained in:
parent
9fec382601
commit
3c81822ec5
|
@ -330,13 +330,18 @@ ModuleSanitizerCoverage::CreateSecStartEnd(Module &M, const char *Section,
|
|||
Type *Ty) {
|
||||
// Use ExternalWeak so that if all sections are discarded due to section
|
||||
// garbage collection, the linker will not report undefined symbol errors.
|
||||
GlobalVariable *SecStart = new GlobalVariable(
|
||||
M, Ty->getPointerElementType(), false,
|
||||
GlobalVariable::ExternalWeakLinkage, nullptr, getSectionStart(Section));
|
||||
// Windows defines the start/stop symbols in compiler-rt so no need for
|
||||
// ExternalWeak.
|
||||
GlobalValue::LinkageTypes Linkage = TargetTriple.isOSBinFormatCOFF()
|
||||
? GlobalVariable::ExternalLinkage
|
||||
: GlobalVariable::ExternalWeakLinkage;
|
||||
GlobalVariable *SecStart =
|
||||
new GlobalVariable(M, Ty->getPointerElementType(), false, Linkage,
|
||||
nullptr, getSectionStart(Section));
|
||||
SecStart->setVisibility(GlobalValue::HiddenVisibility);
|
||||
GlobalVariable *SecEnd = new GlobalVariable(
|
||||
M, Ty->getPointerElementType(), false,
|
||||
GlobalVariable::ExternalWeakLinkage, nullptr, getSectionEnd(Section));
|
||||
GlobalVariable *SecEnd =
|
||||
new GlobalVariable(M, Ty->getPointerElementType(), false, Linkage,
|
||||
nullptr, getSectionEnd(Section));
|
||||
SecEnd->setVisibility(GlobalValue::HiddenVisibility);
|
||||
IRBuilder<> IRB(M.getContext());
|
||||
if (!TargetTriple.isOSBinFormatCOFF())
|
||||
|
|
|
@ -11,3 +11,5 @@ entry:
|
|||
|
||||
; CHECK-DAG: section ".SCOV{{\$}}CM",
|
||||
; CHECK-DAG: section ".SCOVP{{\$}}M",
|
||||
; CHECK: @__start___sancov_cntrs = external hidden global i8
|
||||
; CHECK: @__stop___sancov_cntrs = external hidden global i8
|
||||
|
|
|
@ -11,3 +11,5 @@ entry:
|
|||
|
||||
; CHECK-DAG: section ".SCOV{{\$}}BM",
|
||||
; CHECK-DAG: section ".SCOVP{{\$}}M",
|
||||
; CHECK: @__start___sancov_bools = external hidden global i1
|
||||
; CHECK: @__stop___sancov_bools = external hidden global i1
|
||||
|
|
Loading…
Reference in New Issue