llvm.org GIT mirror llvm / b046920
[asan] Better workaround for gold PR19002. See the comment for more details. Test in a follow-up CFE commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303113 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 3 years ago
1 changed file(s) with 11 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
612612 bool UseGlobalsGC = true)
613613 : ModulePass(ID), CompileKernel(CompileKernel || ClEnableKasan),
614614 Recover(Recover || ClRecover),
615 UseGlobalsGC(UseGlobalsGC && ClUseGlobalsGC) {}
615 UseGlobalsGC(UseGlobalsGC && ClUseGlobalsGC),
616 // Not a typo: ClWithComdat is almost completely pointless without
617 // ClUseGlobalsGC (because then it only works on modules without
618 // globals, which are rare); it is a prerequisite for ClUseGlobalsGC;
619 // and both suffer from gold PR19002 for which UseGlobalsGC constructor
620 // argument is designed as workaround. Therefore, disable both
621 // ClWithComdat and ClUseGlobalsGC unless the frontend says it's ok to
622 // do globals-gc.
623 UseCtorComdat(UseGlobalsGC && ClWithComdat) {}
616624 bool runOnModule(Module &M) override;
617625 static char ID; // Pass identification, replacement for typeid
618626 StringRef getPassName() const override { return "AddressSanitizerModule"; }
655663 bool CompileKernel;
656664 bool Recover;
657665 bool UseGlobalsGC;
666 bool UseCtorComdat;
658667 Type *IntptrTy;
659668 LLVMContext *C;
660669 Triple TargetTriple;
20712080 // Put the constructor and destructor in comdat if both
20722081 // (1) global instrumentation is not TU-specific
20732082 // (2) target is ELF.
2074 if (ClWithComdat && TargetTriple.isOSBinFormatELF() && CtorComdat) {
2083 if (UseCtorComdat && TargetTriple.isOSBinFormatELF() && CtorComdat) {
20752084 AsanCtorFunction->setComdat(M.getOrInsertComdat(kAsanModuleCtorName));
20762085 appendToGlobalCtors(M, AsanCtorFunction, kAsanCtorAndDtorPriority,
20772086 AsanCtorFunction);