leonardchan created this revision. leonardchan added reviewers: chandlerc, phosek. leonardchan added a project: Sanitizers. Herald added subscribers: cryptoad, kristof.beyls. Herald added a project: clang.
We're running into linker errors from missing sancov sections: ld.lld: error: relocation refers to a discarded section: __sancov_guards >>> defined in user-arm64-ubsan-sancov-full.shlib/obj/third_party/ulib/scudo/scudo.wrappers_c.cc.o >>> referenced by common.h:26 (../../zircon/third_party/ulib/scudo/common.h:26) ... many other references I believe this is due to a pass in the default pipeline that somehow discards these sections. The `ModuleSanitizerCoveragePass` was initially added at the start f the pipeline. This now adds it to the end of the pipeline for optimized and unoptimized builds. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D67323 Files: clang/lib/CodeGen/BackendUtil.cpp Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -1149,16 +1149,6 @@ EntryExitInstrumenterPass(/*PostInlining=*/false))); }); - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { - auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); - PB.registerPipelineStartEPCallback( - [SancovOpts](ModulePassManager &MPM) { - MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); - }); - } - // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out @@ -1226,6 +1216,13 @@ } } + if (CodeGenOpts.SanitizeCoverageType || + CodeGenOpts.SanitizeCoverageIndirectCalls || + CodeGenOpts.SanitizeCoverageTraceCmp) { + auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); + MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); + } + if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) { bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress); MPM.addPass(HWAddressSanitizerPass( @@ -1237,13 +1234,6 @@ } if (CodeGenOpts.OptimizationLevel == 0) { - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { - auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); - MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); - } - addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); } }
Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -1149,16 +1149,6 @@ EntryExitInstrumenterPass(/*PostInlining=*/false))); }); - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { - auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); - PB.registerPipelineStartEPCallback( - [SancovOpts](ModulePassManager &MPM) { - MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); - }); - } - // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. // FIXME: either handle asan/the remaining sanitizers or error out @@ -1226,6 +1216,13 @@ } } + if (CodeGenOpts.SanitizeCoverageType || + CodeGenOpts.SanitizeCoverageIndirectCalls || + CodeGenOpts.SanitizeCoverageTraceCmp) { + auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); + MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); + } + if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) { bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress); MPM.addPass(HWAddressSanitizerPass( @@ -1237,13 +1234,6 @@ } if (CodeGenOpts.OptimizationLevel == 0) { - if (CodeGenOpts.SanitizeCoverageType || - CodeGenOpts.SanitizeCoverageIndirectCalls || - CodeGenOpts.SanitizeCoverageTraceCmp) { - auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts); - MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts)); - } - addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts); } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits